Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema details not shown with oneOf for primitive types #708

Closed
jean-baptiste-exorde opened this issue Jan 18, 2024 · 2 comments
Closed
Labels
bug Something isn't working roadmap Features or bug fixes planned for future release

Comments

@jean-baptiste-exorde
Copy link

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):

expected

Current behavior

Only the type is shown for primitive types:

integer_ko

Full schema is shown for object type:

object_ok

Steps to reproduce

  1. Use the following openapi spec.
  2. run yarn docusaurus gen-api-docs all && yarn start
  3. 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.

@jean-baptiste-exorde jean-baptiste-exorde added the bug Something isn't working label Jan 18, 2024
@sserrata
Copy link
Member

Hi @jean-baptiste-exorde, thanks for reporting. I'll add it to our roadmap.

@sserrata sserrata added the roadmap Features or bug fixes planned for future release label Jun 28, 2024
@sserrata
Copy link
Member

Should be addressed in #895

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working roadmap Features or bug fixes planned for future release
Projects
None yet
Development

No branches or pull requests

2 participants