redoc icon indicating copy to clipboard operation
redoc copied to clipboard

Examples set as siblings of a schema ref are not displayed

Open cosmopetrich opened this issue 1 year ago • 1 comments

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.

cosmopetrich avatar Oct 24 '24 02:10 cosmopetrich

Looks like reference in Schema Object allows extended any keywords https://learn.openapis.org/referencing/overview.html

AlexVarchuk avatar Dec 30 '24 16:12 AlexVarchuk