diff --git a/demo/examples/petstore.yaml b/demo/examples/petstore.yaml index c31ac04ae..1382c5b93 100644 --- a/demo/examples/petstore.yaml +++ b/demo/examples/petstore.yaml @@ -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: diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts index 7331ed3c2..eb42062f0 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts @@ -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;