Skip to content

Commit 8b88bdc

Browse files
authored
Merge pull request #21 from zweidenker/development
Development
2 parents 58c8816 + 7c5d2a5 commit 8b88bdc

File tree

82 files changed

+187
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+187
-71
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
baselines
22
mocketry: spec
33
spec baseline: 'Mocketry' with: [
4-
spec repository: 'github://dionisiydk/Mocketry:v4.0.x'. ]
4+
spec repository: 'github://dionisiydk/Mocketry:v4.0.x'. ]

source/OpenAPI-Core-Tests.package/OAParsingTests.class/instance/operationObjectJSON.st

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ operationObjectJSON
1515
"schema": {
1616
"type": "string"
1717
}
18+
},
19+
{
20+
"name": "secondId",
21+
"in": "query",
22+
"description": "an ID to have more than one",
23+
"schema": {
24+
"type": "string"
25+
}
1826
}
1927
],
2028
"requestBody": {

source/OpenAPI-Core-Tests.package/OAParsingTests.class/instance/petStoreApiJsonString.st

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,15 @@ petStoreApiJsonString
113113
"schema": {
114114
"type": "string"
115115
}
116-
}
116+
},
117+
{
118+
"name": "secondId",
119+
"in": "query",
120+
"description": "just an ID to have more than one",
121+
"schema": {
122+
"type": "string"
123+
}
124+
}
117125
],
118126
"responses": {
119127
"200": {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests
2+
testOpenAPISpecHasSortedParameters
3+
| api string json parameters |
4+
api := OpenAPI fromString: self petStoreApiJsonString.
5+
string := api specString.
6+
json := NeoJSONObject fromString: string.
7+
parameters := (json paths at: #'/pets/{petId}') get parameters.
8+
self assert: parameters size equals: 2.
9+
self assert: parameters first name equals: #petId.
10+
self assert: parameters second name equals: #secondId
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
reading
2+
extractParameter: aCall
3+
^ parameter read: (aCall request headers at: parameter name ifAbsent: [ ^ nil ])
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
as yet unclassified
22
read: value object: object
3-
^ schema read: value object: object
3+
^ [schema read: value object: object] on: JSONSchemaError do: [ :ex |
4+
OAInvalidFormat signal: ex description
5+
]

source/OpenAPI-Core.package/OAOperation.class/class/neoJsonMapping..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ neoJsonMapping: mapper
44
for: self
55
do: [ :mapping |
66
mapping mapInstVars: #(tags summary description externalDocs operationId responses callbacks deprecated security servers).
7-
(mapping mapInstVar: #parameters) valueSchema: #ParameterList.
7+
(mapping mapAccessor: #parametersSortedByName mutator: #parameters: to: #parameters) valueSchema: #ParameterList.
88
(mapping mapInstVar: #requestBody) valueSchema: OARequestBody.
99
(mapping mapAccessor: #responses) valueSchema: #ResponsesDictionary. ].
1010
mapper

source/OpenAPI-Core.package/OAOperation.class/instance/deprecated1..st

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
reading
2-
initializeValuesOn: object fromRequest: request
2+
initializeValuesOn: aCall fromRequest: request
33
parameters ifNotNil: [
44
parameters do: [ :each |
5-
each writeParameterValueOn: object request: request]].
5+
each
6+
writeParameterValueOn: aCall parameterValueDelegate
7+
request: request]].
68
requestBody ifNotNil: [
7-
(requestBody readFrom: request object: object) ]
9+
(requestBody
10+
readFrom: request
11+
object: aCall bodyValueDelegate ) ]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
accessing
2+
parametersSortedByName
3+
parameters ifNil: [ ^ nil ].
4+
^ parameters sorted: [ :a :b | a name < b name ]

source/OpenAPI-Core.package/OAParameter.class/instance/extractParameter..st

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
accessing
22
extractParameter: aCall
33
| value |
4-
value := location extractParameter: aCall.
4+
value := [location extractParameter: aCall] on: JSONSchemaError do: [ :ex |
5+
OAInvalidFormat signal: ex description
6+
].
57
value isNil
68
ifTrue: [ required
79
ifTrue: [ OAMissingRequiredParameter signal: 'parameter ' , name , ' is required but not present' ]

source/OpenAPI-Core.package/OAParameter.class/instance/writeParameterValueOn..st

Lines changed: 0 additions & 11 deletions
This file was deleted.

source/OpenAPI-Core.package/OAParameter.class/instance/writeParameterValueOn.request..st

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ writeParameterValueOn: anObject request: request
77
value := self extractParameter: request.
88
value ifNil: [ ^ self ].
99
self shouldUseAccessors
10-
ifTrue: [ anObject perform: name asSymbol asMutator with: value ]
11-
ifFalse: [ anObject instVarNamed: name put: value ]
10+
ifTrue: [
11+
anObject
12+
perform: name asValidSelector asMutator
13+
with: value ]
14+
ifFalse: [
15+
anObject
16+
instVarNamed: name asValidSelector
17+
put: value ]

source/OpenAPI-Core.package/OAPathParameterLocation.class/instance/extractParameter..st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
as yet unclassified
1+
reading
22
extractParameter: aCall
33
| index value |
44
($/ split: aCall class path allButFirst) withIndexDo: [ :each :idx |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
as yet unclassified
1+
writing
22
write: key value: value to: builder
33
builder addPathParameter: key value: value
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
accessing
2+
parameterOptionalPetId
3+
<openApiParameter: #( common )>
4+
^ OAParameter new
5+
name: 'Optional-Pet-Id';
6+
in: #header;
7+
beInteger;
8+
required: false;
9+
description: 'The internal id of the pet in the pet store'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
accessing
2+
parameterRequiredPetId
3+
<openApiParameter: #( common )>
4+
^ OAParameter new
5+
name: 'Required-Pet-Id';
6+
in: #header;
7+
beInteger;
8+
required: true;
9+
description: 'The internal id of the pet in the pet store'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessing
2+
path
3+
^ '/pets/header-missing'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public
2+
get
3+
response := self response: Dictionary new status: 200 contentType: 'application/json'
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
22
"commentStamp" : "",
3-
"super" : "TestCase",
3+
"super" : "OpenAPITestCall",
44
"category" : "OpenAPI-REST-Tests",
55
"classinstvars" : [ ],
66
"pools" : [ ],
77
"classvars" : [ ],
88
"instvars" : [
9-
"serverDelegate",
10-
"server",
11-
"client"
9+
"requiredPetId"
1210
],
13-
"name" : "OARESTTests",
11+
"name" : "OAMissingHeaderPetCall",
1412
"type" : "normal"
1513
}

source/OpenAPI-REST-Tests.package/OARESTTests.class/instance/setUp.st

Lines changed: 0 additions & 12 deletions
This file was deleted.

source/OpenAPI-REST-Tests.package/OARESTTests.class/instance/tearDown.st

Lines changed: 0 additions & 4 deletions
This file was deleted.

source/OpenAPI-REST-Tests.package/OARESTTests.class/instance/testPetCall.st

Lines changed: 0 additions & 5 deletions
This file was deleted.

source/OpenAPI-REST-Tests.package/OARESTTests.class/instance/testPetPostCall.st

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "OpenAPICall",
4+
"category" : "OpenAPI-REST-Tests",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "OpenAPIBasePetCall",
10+
"type" : "normal"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests
2+
testMissingOptionalHeaderParameter
3+
4+
| response |
5+
Pet instances add: (Pet new id: 1; name: 'testpet'; age: 1).
6+
response := self delegate handleRequest: (ZnClient new
7+
url: '/pets/header-missing';
8+
headerAt: 'Required-Pet-Id' add: '123';
9+
method: #GET;
10+
prepareRequest) request.
11+
self assert: response isSuccess
12+
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests
2+
testMissingRequiredHeaderParameter
3+
4+
| response |
5+
Pet instances add: (Pet new id: 1; name: 'testpet'; age: 1).
6+
response := self delegate handleRequest: (ZnClient new
7+
url: '/pets/header-missing';
8+
method: #GET;
9+
prepareRequest) request.
10+
self deny: response isSuccess.
11+
self assert: response status equals: 400.
12+
self assert: (response contents includesSubstring: 'Required-Pet-Id')
13+
14+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "OpenAPIRestTests",
4+
"category" : "OpenAPI-REST-Tests",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "OpenAPIHeaderTests",
10+
"type" : "normal"
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
as yet unclassified
2+
responseOk
3+
<openApiResponse: #(get) status: #(200) contentType: #('application/json')>
4+
^ OAMediaTypeObject new
5+
schema: {
6+
#name -> (JSONSchema string).
7+
#age -> (JSONSchema integer) } asJSONSchema

source/OpenAPI-REST.package/OpenAPIPetCall.class/properties.json renamed to source/OpenAPI-REST-Tests.package/OpenAPIPetCall.class/properties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"commentStamp" : "",
3-
"super" : "OpenAPICall",
4-
"category" : "OpenAPI-REST",
3+
"super" : "OpenAPIBasePetCall",
4+
"category" : "OpenAPI-REST-Tests",
55
"classinstvars" : [ ],
66
"pools" : [ ],
77
"classvars" : [ ],

source/OpenAPI-REST.package/OpenAPIPetCollectionCall.class/properties.json renamed to source/OpenAPI-REST-Tests.package/OpenAPIPetCollectionCall.class/properties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"commentStamp" : "",
3-
"super" : "OpenAPICall",
4-
"category" : "OpenAPI-REST",
3+
"super" : "OpenAPIBasePetCall",
4+
"category" : "OpenAPI-REST-Tests",
55
"classinstvars" : [ ],
66
"pools" : [ ],
77
"classvars" : [ ],
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tests
2+
rootCallClass
3+
^ OpenAPIBasePetCall
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "OpenAPIRestTests",
4+
"category" : "OpenAPI-REST-Tests",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "OpenAPIRestPetTests",
10+
"type" : "normal"
11+
}

source/OpenAPI-REST-Tests.package/OpenAPIRestTests.class/README.md

source/OpenAPI-REST.package/OpenAPIRestTest.class/instance/delegate.st renamed to source/OpenAPI-REST-Tests.package/OpenAPIRestTests.class/instance/delegate.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ delegate
33

44
^ (ZnRestServerDelegate new
55
uriSpace: (OpenAPIUriSpace new
6-
rootClass: OpenAPICall ))
6+
rootClass: self rootCallClass ))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tests
2+
rootCallClass
3+
^ OpenAPITestCall
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"commentStamp" : "",
33
"super" : "TestCase",
4-
"category" : "OpenAPI-REST",
4+
"category" : "OpenAPI-REST-Tests",
55
"classinstvars" : [ ],
66
"pools" : [ ],
77
"classvars" : [ ],
88
"instvars" : [ ],
9-
"name" : "OpenAPIRestTest",
9+
"name" : "OpenAPIRestTests",
1010
"type" : "normal"
1111
}

source/OpenAPI-REST-Tests.package/OpenAPISpecCall.class/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "OpenAPIBasePetCall",
4+
"category" : "OpenAPI-REST-Tests",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "OpenAPISpecCall",
10+
"type" : "normal"
11+
}

source/OpenAPI-REST-Tests.package/OpenAPITestCall.class/README.md

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"commentStamp" : "",
33
"super" : "OpenAPICall",
4-
"category" : "OpenAPI-REST",
4+
"category" : "OpenAPI-REST-Tests",
55
"classinstvars" : [ ],
66
"pools" : [ ],
77
"classvars" : [ ],
88
"instvars" : [ ],
9-
"name" : "OpenAPISpecCall",
9+
"name" : "OpenAPITestCall",
1010
"type" : "normal"
1111
}

source/OpenAPI-REST-Tests.package/Pet.class/README.md

0 commit comments

Comments
 (0)