swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.61k stars 8.97k forks source link

BUG: failing to fetch examples for parameters #10121

Open ThePrimeJnr opened 2 months ago

ThePrimeJnr commented 2 months ago

Q&A (please complete the following information)

Content & configuration

Example Swagger/OpenAPI definition:

  /api/resource/User:
    get:
      tags:
        - user
      summary: "Get All Users"
      description: "Retrieve a list of all User records."
      parameters:
        - name: fields
          in: query
          description: "Comma-separated list of fields to include in the response."
          schema:
            type: string
            examples: 
              - 'field'

Describe the bug you're encountering

Swagger UI doesn't use example or parameter when using the examples key (as an array). I got it to work using the deprecated example

To reproduce...

Steps to reproduce the behavior:

  1. write a sample swagger yaml in swagger editor
  2. add a path and add a param field.
  3. add example example to the properties and you can see the example value.
  4. replace with examples as an array and you'd lose the example value

Expected behavior

should be able to render the example vaue when using examples

Screenshots

image image

Additional context or thoughts

Willing to attempt fixing this - if it gets approved to be a bug