Skip to content

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

Open
@cosmopetrich

Description

@cosmopetrich

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions