swagger-api / swagger-api/swagger-ui
Illustrating the inline schema naming issue in Swagger UI when using a list
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: WSL
- Browser: chrome
- Version: Version 134.0.6998.89
- Method of installation: pip
- Swagger-UI version: [e.g. 3.10.0]
- Swagger version: 5.20.1
- OpenAPI version: 3.1.0
Content & configuration
https://github.com/Tanvir786123/fastapi-swagger-ui-issue/tree/main contains a complete rundown of what this issue is, i.e., the inability to correctly display the name of the return object if it is a List.
Example Swagger/OpenAPI definition:
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/item": {
"get": {
"summary": "Get a single book",
"description": "Returns a single book with full details.",
"operationId": "get_book_item_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Book"
}
}
}
}
}
}
},
"/items": {
"get": {
"summary": "Get list of books",
"description": "Returns a list of books with full details.",
"operationId": "get_books_items_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/Book"
},
"type": "array",
"title": "Response Get Books Items Get"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Book": {
"properties": {
"id": {
"type": "integer",
"title": "Id"
},
"title": {
"type": "string",
"title": "Title"
},
"author": {
"type": "string",
"title": "Author"
},
"summary": {
"type": "string",
"title": "Summary"
}
},
"type": "object",
"required": [
"id",
"title",
"author",
"summary"
],
"title": "Book"
}
}
}
}
Swagger-UI configuration options:
SwaggerUI({
// your config options here
})
?yourQueryStringConfig
Describe the bug you're encountering
https://github.com/Tanvir786123/fastapi-swagger-ui-issue/tree/main contains a complete rundown of what this issue is, i.e., the inability to correctly display the name of the return object if it is a List.
To reproduce...
Steps to reproduce the behavior:
Please follow the steps on the linked repository.
Expected behavior
The inline schema name for the second endpoint should have been: Books.
Screenshots
Inside https://github.com/Tanvir786123/fastapi-swagger-ui-issue/tree/main.
Additional context or thoughts
This problem may potentially extend to more objects than just List. However, the objective of this issue is to solve the problem using a List type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked fastapi-swagger-ui-issue reproduction and the supplied OpenAPI 3.1 definition, focusing on how Swagger UI renders the inline array response schema. Done means the second endpoint displays the inline schema name as “Books” while preserving the existing single-book display and supporting the reported List case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100