swagger-api / swagger-api/swagger-ui

`anyOf` parameters always listed as `X | (X | Y)`

Open
#10,654 3 comments 2 reactions 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: macOS
  • Browser: FireFox
  • Version: 140.5
  • Method of installation: downloaded the pre-compiled bundle and used the dist/ directory
  • Swagger-UI version: 5.30.3
  • Swagger/OpenAPI version: 3.1.0
Content & configuration

Example Swagger/OpenAPI definition:

{
    "openapi": "3.1.0",
    "paths": {
        "/greet": {
            "get": {
                "parameters": [
                    {
                        "name": "name",
                        "schema": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ]
                        }
                    }
                ]
            }
        }
    }
}

Swagger-UI configuration options:
Not changed from defaults

Describe the bug you're encountering
To reproduce...

Steps to reproduce the behavior:

  1. Create an OpenAPI spec that uses anyOf for a parameter
  2. Look at the generated docs for that parameter
Expected behavior

In the above example, I expect to see string | integer

Screenshots
Image
Additional context or thoughts

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 using the OpenAPI example and the downloaded dist/ directory, then trace how the generated documentation renders the parameter schema. Compare the current anyOf display with the expected string | integer output. Done means the parameter is shown without the redundant nested type expression and the existing behavior remains correct for other schemas.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.