Redocly / Redocly/redoc

Improve order of drop-down items when using discriminator (since #1462 is closed)

Open
#2,494 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
TypeScript
Stars
25.9k
Forks
2.4k
Avg merge
13h 10m
Merged PRs (30d)
4

Description

Describe the bug
Please refer to https://github.com/Redocly/redoc/issues/1462 for the description.

Expected behavior
The dropdown is shown in the reverse order in some cases.

Minimal reproducible OpenAPI snippet(if possible)

I created a test schema that can be used to reproduce the problem.

Attached please find the redoc-issue-1462.yaml.txt file that contains one API endpoint which is a simplified version of the "new pet" for the pet store example.

Can you download the file, remove the .txt extension, and test it? Github doesn't allow uploading YAML file.

A few differences between this sample schema and the openapi.yaml for the pet store:

  • First, requestBodies is not used for the request body schema, e.g., "#/components/requestBodies/Pet". I set it to "#/components/schemas/requestBody" instead
  • The requestBody schema contains oneOf and discriminator with mapping,
  • The petType field is defined in the Cat, Dog, and Honeybee schemas with the enum values set.

Screenshots

Below are the screenshots showing the problem. I used the "OpenAPI ​(Swagger)​ Editor" IntelliJ plugin to show the problem on the Chrome browser.

  1. Problem: The dropdown shows "bee", "dog", and "cat" from the sample schema, though "cat" is the default.
    The expected list is "cat", "dog", and "bee".
image

Compared to the [redoc-issue-1462.yaml.txt](https://github.com/Redocly/redoc/files/14381183/redoc-issue-1462.yaml.txt) (pet store) which shows the dropdown properly.
image

  1. No problem with the example dropdown on the right pane. (Good)
image

Additional context
Add any other context about the problem here.

redoc-issue-1462.yaml.txt

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

Start by loading redoc-issue-1462.yaml.txt, after removing its .txt extension, in Redoc and compare the discriminator dropdown with the expected order. Trace the dropdown entry point for the requestBody schema using oneOf and discriminator mapping; done means the list displays cat, dog, then bee while the existing example dropdown remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.