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

Examples set as siblings of a schema ref are not displayed #2609

Open
cosmopetrich opened this issue Oct 24, 2024 · 0 comments
Open

Examples set as siblings of a schema ref are not displayed #2609

cosmopetrich opened this issue Oct 24, 2024 · 0 comments

Comments

@cosmopetrich
Copy link

Describe the bug
Examples set via a sibling of a schema $ref in an OpenAPI 3.1.0 document are not displayed. Instead, the default value for the type is shown ("string", 0, etc).

Expected behavior
The value set in an example/examples field that is the sibling of a $ref where the referenced schema does not contain an example should be displayed.

Minimal reproducible OpenAPI snippet(if possible)

openapi: 3.1.0
info:
  title: Example
  version: "0.0.1"

components:
  schemas:
    ExampleNumber:
      description: "A number"
      type: number
    ExampleRange:
      type: object
      properties:
        Min:
          $ref: "#/components/schemas/ExampleNumber"
          description: "Minimum"
          minimum: 0
          maximum: 50
          example: 10
        Max:
          $ref: "#/components/schemas/ExampleNumber"
          description: "Maximum"
          minimum: 51
          maximum: 100
          examples:
            - 55

paths:
  /example:
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ExampleRange"

Screenshots

Redoc's rendering of the snippet above is shown below. Note that it does show the sibling minimum and maximum ranges (51..100 etc) but does not show the sibling example.

Image

For reference, here is what Swagger-UI shows when I generate an openapi.json with redoc-cli and then load it into Swagger-UI.

Image

Additional context
My understanding is that OAS 3.1 allows references in schemas to be extended with any field, as opposed to non-schema references which only allow summary/description as siblings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant