docusaurus-openapi-docs
docusaurus-openapi-docs copied to clipboard
Schema details not shown with `oneOf` for primitive types
Describe the bug
Hi, I have an issue when using oneOf in the schema. If the schema referenced by oneOf is a primitive type (like integer or string), only the type is shown in the documentation, not the details of the schema. But, if the schema is an object, the details are shown.
Expected behavior
Schema details should be shown for primitive types (example with redocly):
Current behavior
Only the type is shown for primitive types:
Full schema is shown for object type:
Steps to reproduce
- Use the following openapi spec.
- run
yarn docusaurus gen-api-docs all && yarn start - Open docusaurus an go to the page that shows the API schema
In the example below, the Foo schema is an oneOf of 3 base schemas: two primitive types and one object.
I put the Foo schema in in the request body and the response, the result is the same: the object schema is shown as expected, but the integer and string schema are not.
Openapi spec
openapi: 3.0.3
servers:
- url: https://
info:
title: ""
version: "1.0"
paths:
/demo:
get:
summary: Demo
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Foo"
responses:
"200":
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Foo"
components:
securitySchemes:
basicAuth:
type: http
scheme: basic
schemas:
integerSchema:
type: integer
format: int32
description: I'm an integer!
multipleOf: 5
minimum: 5
maximum: 6000
default: 60
stringSchema:
type: string
description: I'm a string!
pattern: ^some.*pattern$
default: some default value
example: example value
objectSchema:
type: object
properties:
id:
$ref: "#/components/schemas/integerSchema"
name:
$ref: "#/components/schemas/stringSchema"
xml:
name: Tag
Foo:
oneOf:
- $ref: "#/components/schemas/integerSchema"
- $ref: "#/components/schemas/stringSchema"
- $ref: "#/components/schemas/objectSchema"
Context
Latest version of Docusaurus and OpenAPI plugin, fresh install.
Hi @jean-baptiste-exorde, thanks for reporting. I'll add it to our roadmap.
Should be addressed in https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/895