Skip to content

Commit

Permalink
Add support for anyoneof object primitive (#894)
Browse files Browse the repository at this point in the history
* add support for anyoneof object primitive

* add example response for testing

* update test snapshot

* handle object primitive separately to ensure no properties exist

* update test snapshot
  • Loading branch information
sserrata authored Jul 22, 2024
1 parent 73b212d commit 7fd1f42
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions demo/examples/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ paths:
description: Add new pet to the store inventory.
operationId: addPet
responses:
"200":
description: All good
content:
application/json:
schema:
type: object
properties:
data:
oneOf:
- type: string
- type: object
"405":
description: Invalid input
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ function createAnyOneOf(schema: SchemaObject): any {
: `MOD${index + 1}`;
const anyOneChildren = [];

if (
anyOneSchema.type === "object" &&
!anyOneSchema.properties &&
!anyOneSchema.allOf &&
!anyOneSchema.items
) {
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
}

if (anyOneSchema.properties !== undefined) {
anyOneChildren.push(createProperties(anyOneSchema));
delete anyOneSchema.properties;
Expand Down

0 comments on commit 7fd1f42

Please sign in to comment.