Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions source/OpenAPI-Core-Tests/OAExampleDocumentsTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ OAExampleDocumentsTests >> testPetstoreExpandedIsValid [
self assert: (OADocumentValidator isValidDocument: OAExampleDocuments petstoreExpanded)
]

{ #category : 'tests' }
OAExampleDocumentsTests >> testPetstoreExpandedPetSchemaMergesAllOfBranchesForReading [
"Real-world confirmation: OAExampleDocuments petstoreExpanded's Pet schema is
allOf[$ref NewPet, {required:[id], properties:{id}}] - resolves to JSONSchemaAnyObject.
Reading a response body against it must merge properties/required from BOTH
branches (NewPet contributes name/tag, the inline branch contributes id), not just
pass the raw JSON dictionary through."
| api petSchema result |
api := OpenAPI fromString: OAExampleDocuments petstoreExpanded.
petSchema := api components schemas at: 'Pet'.
result := petSchema readString: '{"id":42,"name":"Rex","tag":"dog"}'.
self assert: result class equals: NeoJSONObject.
self assert: result id equals: 42.
self assert: result name equals: 'Rex'.
self assert: result tag equals: 'dog'.
self should: [ petSchema readString: '{"name":"Rex","tag":"dog"}' ] raise: JSONTypeError
]

{ #category : 'tests' }
OAExampleDocumentsTests >> testPetstoreIsValid [
self assert: (OADocumentValidator isValidDocument: OAExampleDocuments petstore)
Expand Down
Loading