Skip to content

Commit 7fd1f42

Browse files
authored
Add support for anyoneof object primitive (#894)
* 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
1 parent 73b212d commit 7fd1f42

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

demo/examples/petstore.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ paths:
115115
description: Add new pet to the store inventory.
116116
operationId: addPet
117117
responses:
118+
"200":
119+
description: All good
120+
content:
121+
application/json:
122+
schema:
123+
type: object
124+
properties:
125+
data:
126+
oneOf:
127+
- type: string
128+
- type: object
118129
"405":
119130
description: Invalid input
120131
security:

packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ function createAnyOneOf(schema: SchemaObject): any {
7373
: `MOD${index + 1}`;
7474
const anyOneChildren = [];
7575

76+
if (
77+
anyOneSchema.type === "object" &&
78+
!anyOneSchema.properties &&
79+
!anyOneSchema.allOf &&
80+
!anyOneSchema.items
81+
) {
82+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
83+
}
84+
7685
if (anyOneSchema.properties !== undefined) {
7786
anyOneChildren.push(createProperties(anyOneSchema));
7887
delete anyOneSchema.properties;

0 commit comments

Comments
 (0)