swagger-api / swagger-api/swagger-ui

BUG: failing to fetch examples for parameters

Open
#10,121 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: ArchLinux
  • Browser: chrome
  • Version: 127.0.6533.99 (Official Build) (64-bit)
  • Method of installation: Swagger editor
  • Swagger-UI version: 3.10.0
  • Swagger/OpenAPI version: OpenAPI 3.1.0
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in Swagger Editor with the supplied OpenAPI 3.1 YAML, comparing the deprecated singular example with the examples array under the parameter schema. Trace the Swagger UI parameter-example rendering path and verify that the array form displays a usable example value without regressing the singular form.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.