Skip to content

Commit

Permalink
Merge pull request #21 from zweidenker/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
noha authored Aug 5, 2020
2 parents 58c8816 + 7c5d2a5 commit 8b88bdc
Show file tree
Hide file tree
Showing 82 changed files with 187 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baselines
mocketry: spec
spec baseline: 'Mocketry' with: [
spec repository: 'github://dionisiydk/Mocketry:v4.0.x'. ]
spec repository: 'github://dionisiydk/Mocketry:v4.0.x'. ]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ operationObjectJSON
"schema": {
"type": "string"
}
},
{
"name": "secondId",
"in": "query",
"description": "an ID to have more than one",
"schema": {
"type": "string"
}
}
],
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ petStoreApiJsonString
"schema": {
"type": "string"
}
}
},
{
"name": "secondId",
"in": "query",
"description": "just an ID to have more than one",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
tests
testOpenAPISpecHasSortedParameters
| api string json parameters |
api := OpenAPI fromString: self petStoreApiJsonString.
string := api specString.
json := NeoJSONObject fromString: string.
parameters := (json paths at: #'/pets/{petId}') get parameters.
self assert: parameters size equals: 2.
self assert: parameters first name equals: #petId.
self assert: parameters second name equals: #secondId
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reading
extractParameter: aCall
^ parameter read: (aCall request headers at: parameter name ifAbsent: [ ^ nil ])
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
as yet unclassified
read: value object: object
^ schema read: value object: object
^ [schema read: value object: object] on: JSONSchemaError do: [ :ex |
OAInvalidFormat signal: ex description
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ neoJsonMapping: mapper
for: self
do: [ :mapping |
mapping mapInstVars: #(tags summary description externalDocs operationId responses callbacks deprecated security servers).
(mapping mapInstVar: #parameters) valueSchema: #ParameterList.
(mapping mapAccessor: #parametersSortedByName mutator: #parameters: to: #parameters) valueSchema: #ParameterList.
(mapping mapInstVar: #requestBody) valueSchema: OARequestBody.
(mapping mapAccessor: #responses) valueSchema: #ResponsesDictionary. ].
mapper
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
reading
initializeValuesOn: object fromRequest: request
initializeValuesOn: aCall fromRequest: request
parameters ifNotNil: [
parameters do: [ :each |
each writeParameterValueOn: object request: request]].
each
writeParameterValueOn: aCall parameterValueDelegate
request: request]].
requestBody ifNotNil: [
(requestBody readFrom: request object: object) ]
(requestBody
readFrom: request
object: aCall bodyValueDelegate ) ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
parametersSortedByName
parameters ifNil: [ ^ nil ].
^ parameters sorted: [ :a :b | a name < b name ]
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
accessing
extractParameter: aCall
| value |
value := location extractParameter: aCall.
value := [location extractParameter: aCall] on: JSONSchemaError do: [ :ex |
OAInvalidFormat signal: ex description
].
value isNil
ifTrue: [ required
ifTrue: [ OAMissingRequiredParameter signal: 'parameter ' , name , ' is required but not present' ]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ writeParameterValueOn: anObject request: request
value := self extractParameter: request.
value ifNil: [ ^ self ].
self shouldUseAccessors
ifTrue: [ anObject perform: name asSymbol asMutator with: value ]
ifFalse: [ anObject instVarNamed: name put: value ]
ifTrue: [
anObject
perform: name asValidSelector asMutator
with: value ]
ifFalse: [
anObject
instVarNamed: name asValidSelector
put: value ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
as yet unclassified
reading
extractParameter: aCall
| index value |
($/ split: aCall class path allButFirst) withIndexDo: [ :each :idx |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
as yet unclassified
writing
write: key value: value to: builder
builder addPathParameter: key value: value
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
accessing
parameterOptionalPetId
<openApiParameter: #( common )>
^ OAParameter new
name: 'Optional-Pet-Id';
in: #header;
beInteger;
required: false;
description: 'The internal id of the pet in the pet store'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
accessing
parameterRequiredPetId
<openApiParameter: #( common )>
^ OAParameter new
name: 'Required-Pet-Id';
in: #header;
beInteger;
required: true;
description: 'The internal id of the pet in the pet store'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
path
^ '/pets/header-missing'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public
get
response := self response: Dictionary new status: 200 contentType: 'application/json'
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"commentStamp" : "",
"super" : "TestCase",
"super" : "OpenAPITestCall",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"serverDelegate",
"server",
"client"
"requiredPetId"
],
"name" : "OARESTTests",
"name" : "OAMissingHeaderPetCall",
"type" : "normal"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "OpenAPICall",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPIBasePetCall",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests
testMissingOptionalHeaderParameter

| response |
Pet instances add: (Pet new id: 1; name: 'testpet'; age: 1).
response := self delegate handleRequest: (ZnClient new
url: '/pets/header-missing';
headerAt: 'Required-Pet-Id' add: '123';
method: #GET;
prepareRequest) request.
self assert: response isSuccess


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests
testMissingRequiredHeaderParameter

| response |
Pet instances add: (Pet new id: 1; name: 'testpet'; age: 1).
response := self delegate handleRequest: (ZnClient new
url: '/pets/header-missing';
method: #GET;
prepareRequest) request.
self deny: response isSuccess.
self assert: response status equals: 400.
self assert: (response contents includesSubstring: 'Required-Pet-Id')


Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "OpenAPIRestTests",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPIHeaderTests",
"type" : "normal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
as yet unclassified
responseOk
<openApiResponse: #(get) status: #(200) contentType: #('application/json')>
^ OAMediaTypeObject new
schema: {
#name -> (JSONSchema string).
#age -> (JSONSchema integer) } asJSONSchema
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"commentStamp" : "",
"super" : "OpenAPICall",
"category" : "OpenAPI-REST",
"super" : "OpenAPIBasePetCall",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"commentStamp" : "",
"super" : "OpenAPICall",
"category" : "OpenAPI-REST",
"super" : "OpenAPIBasePetCall",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests
rootCallClass
^ OpenAPIBasePetCall
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "OpenAPIRestTests",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPIRestPetTests",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ delegate

^ (ZnRestServerDelegate new
uriSpace: (OpenAPIUriSpace new
rootClass: OpenAPICall ))
rootClass: self rootCallClass ))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tests
rootCallClass
^ OpenAPITestCall
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commentStamp" : "",
"super" : "TestCase",
"category" : "OpenAPI-REST",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPIRestTest",
"name" : "OpenAPIRestTests",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "OpenAPIBasePetCall",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPISpecCall",
"type" : "normal"
}
Empty file.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"commentStamp" : "",
"super" : "OpenAPICall",
"category" : "OpenAPI-REST",
"category" : "OpenAPI-REST-Tests",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "OpenAPISpecCall",
"name" : "OpenAPITestCall",
"type" : "normal"
}
Empty file.
Loading

0 comments on commit 8b88bdc

Please sign in to comment.