Open
Description
Q&A
- OS: Any
- Browser: Any
- Method of installation: dist assets
- Swagger-UI version: 3.18.2
- Swagger/OpenAPI version: OpenAPI 3.1
Content & configuration
Order of "null" in "anyOf"/"oneOf" array change displaing info in SwaggerUI
This OAS (where null is the first element)
{
"info": {
"title": "Test API",
"version": "0.0.1"
},
"openapi": "3.1.0",
"servers": [
{
"url": "/"
}
],
"paths": {
"/": {
"get": {
"summary": "Test",
"operationId": "Test",
"parameters": [
{
"name": "environment",
"in": "query",
"schema": {
"anyOf": [
{
"type": "null"
},
{
"$ref": "#/components/schemas/Environment"
}
],
"title": "Environment",
"description": "The environment to filter by."
},
"description": "The environment to filter by.",
"required": false,
"deprecated": false,
"allowEmptyValue": false,
"allowReserved": false
}
],
"responses": {
"200": {
"description": "Request fulfilled, document follows",
"headers": {
},
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Environment"
},
{
"type": "null"
}
]
}
}
}
},
"400": {
"description": "Bad request syntax or unsupported method",
"content": {
"application/json": {
"schema": {
"properties": {
"status_code": {
"type": "integer"
},
"detail": {
"type": "string"
},
"extra": {
"additionalProperties": {
},
"type": [
"null",
"object",
"array"
]
}
},
"type": "object",
"required": [
"detail",
"status_code"
],
"description": "Validation Exception",
"examples": [
{
"status_code": 400,
"detail": "Bad Request",
"extra": {
}
}
]
}
}
}
}
},
"deprecated": false
}
}
},
"components": {
"schemas": {
"Environment": {
"type": "string",
"enum": [
"dev",
"test",
"qa"
],
"title": "Environment"
}
}
}
}
This OAS (where null is the last):
{
"info": {
"title": "Test API",
"version": "0.0.1"
},
"openapi": "3.1.0",
"servers": [
{
"url": "/"
}
],
"paths": {
"/": {
"get": {
"summary": "Test",
"operationId": "Test",
"parameters": [
{
"name": "environment",
"in": "query",
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Environment"
},
{
"type": "null"
}
],
"title": "Environment",
"description": "The environment to filter by."
},
"description": "The environment to filter by.",
"required": false,
"deprecated": false,
"allowEmptyValue": false,
"allowReserved": false
}
],
"responses": {
"200": {
"description": "Request fulfilled, document follows",
"headers": {
},
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/Environment"
},
{
"type": "null"
}
]
}
}
}
},
"400": {
"description": "Bad request syntax or unsupported method",
"content": {
"application/json": {
"schema": {
"properties": {
"status_code": {
"type": "integer"
},
"detail": {
"type": "string"
},
"extra": {
"additionalProperties": {
},
"type": [
"null",
"object",
"array"
]
}
},
"type": "object",
"required": [
"detail",
"status_code"
],
"description": "Validation Exception",
"examples": [
{
"status_code": 400,
"detail": "Bad Request",
"extra": {
}
}
]
}
}
}
}
},
"deprecated": false
}
}
},
"components": {
"schemas": {
"Environment": {
"type": "string",
"enum": [
"dev",
"test",
"qa"
],
"title": "Environment"
}
}
}
}
Swagger-UI configuration options:
SwaggerUI(
{
url: 'XXX'
dom_id: '#swagger-container',
deepLinking: true,
showExtensions: true,
showCommonExtensions: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIBundle.SwaggerUIStandalonePreset
],
}
)