Q&A (please complete the following information)
- OS: Debian GNU/Linux 13.5 (Trixie)
- Browser: Firefox 151.0.1 / Chromium 149.0.7827.102 (Official Build) built on Debian GNU/Linux 13 (trixie) (64-bit)
- Method of installation: npm
- Swagger-UI version: current HEAD in master (but the issue is also present in version 5.32.0)
- Swagger/OpenAPI version: OpenAPI 3.1.0
Content & configuration
Minimal repro for OpenAPI definition:
{
"openapi": "3.1.0",
"info": {
"title": "Minimal error reproduction",
"version": "0.0.1"
},
"paths": {
"/api/some-path": {
"get": {
"parameters": [
{
"in": "query",
"name": "sort-by",
"required": true,
"schema": {
"default": [
[
"triggered-at",
"desc-nulls-last"
]
],
"type": "array",
"items": {
"type": "array",
"prefixItems": [
{
"type": "string",
"enum": [
"triggered-at"
]
},
{
"type": "string",
"enum": [
"asc-nulls-first",
"asc-nulls-last",
"desc-nulls-first",
"desc-nulls-last"
]
}
],
"items": false
}
}
}
],
"summary": "Minimal repro API def",
"tags": [
"minimal-repro"
]
}
}
}
}
Swagger-UI configuration options:
The default configuration used by the instructions given at https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/development/setting-up.md (except for the url: setting, that points to a local file with the OpenAPI JSON file shown above).
Describe the bug you're encountering
The Swagger UI doesn't render the parameters details of the /api/some-path path, when clicked on it. It shows an error instead (see screen shots below), and displays several Javascript error and call stack traces in the Javascript console.
To reproduce
Steps to reproduce the behavior:
- Launch the development environment as documented at https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/development/setting-up.md (after saving the OpenAPI JSON schema shown above in the
dev-helpers/examples directory, with a suitable name and updating the url: setting in dev-helpers/dev-helper-initializer.js file as suggested in the same previous link)
- Go to
http://localhost:3200
- Click on the
/api/some-path endpoint definition expand it.
- See the error.
Expected behavior
The /api/some-path endpoint definition is expanded without issues, and the sort-by parameter is correctly rendered.
Screenshots
First error shown when clicking to expand the endpoint definition:
Second error shown when clicking on the "Next >" button:
Error shown when clicking on the "x Close" button:
Additional context or thoughts
The code is blowing up at this line:
|
if (List.isList(schemaItems?.get("type")) && (schemaItemsType === "array" || schemaItemsType === "object")) { |
It looks like the support for JSON Schema Draft 2012-12 (the one used by OpenAPI 3.1.x) is not complete, when it comes to the tuple validation syntax, specially about the additional items in a tuple.
If we remove the final "items": false key from the tuple definition object, the Swagger UI is rendered successfully. Although the restrictions about not being able to add more entries to the tuple is not enforced (for obvious reasons).
Q&A (please complete the following information)
Content & configuration
Minimal repro for OpenAPI definition:
{ "openapi": "3.1.0", "info": { "title": "Minimal error reproduction", "version": "0.0.1" }, "paths": { "/api/some-path": { "get": { "parameters": [ { "in": "query", "name": "sort-by", "required": true, "schema": { "default": [ [ "triggered-at", "desc-nulls-last" ] ], "type": "array", "items": { "type": "array", "prefixItems": [ { "type": "string", "enum": [ "triggered-at" ] }, { "type": "string", "enum": [ "asc-nulls-first", "asc-nulls-last", "desc-nulls-first", "desc-nulls-last" ] } ], "items": false } } } ], "summary": "Minimal repro API def", "tags": [ "minimal-repro" ] } } } }Swagger-UI configuration options:
The default configuration used by the instructions given at https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/development/setting-up.md (except for the
url:setting, that points to a local file with the OpenAPI JSON file shown above).Describe the bug you're encountering
The Swagger UI doesn't render the parameters details of the
/api/some-pathpath, when clicked on it. It shows an error instead (see screen shots below), and displays several Javascript error and call stack traces in the Javascript console.To reproduce
Steps to reproduce the behavior:
dev-helpers/examplesdirectory, with a suitable name and updating theurl:setting indev-helpers/dev-helper-initializer.jsfile as suggested in the same previous link)http://localhost:3200/api/some-pathendpoint definition expand it.Expected behavior
The
/api/some-pathendpoint definition is expanded without issues, and thesort-byparameter is correctly rendered.Screenshots
First error shown when clicking to expand the endpoint definition:
Second error shown when clicking on the "Next >" button:
Error shown when clicking on the "x Close" button:
Additional context or thoughts
The code is blowing up at this line:
swagger-ui/src/core/plugins/json-schema-5/components/json-schema-components.jsx
Line 209 in e5d1cd3
It looks like the support for JSON Schema Draft 2012-12 (the one used by OpenAPI 3.1.x) is not complete, when it comes to the tuple validation syntax, specially about the additional items in a tuple.
If we remove the final
"items": falsekey from the tuple definition object, the Swagger UI is rendered successfully. Although the restrictions about not being able to add more entries to the tuple is not enforced (for obvious reasons).