Description
Under some very specific conditions, | null is added to array item type when it shouldn't be there.
openapi-generator version
7.22.0
OpenAPI declaration file content or url
{
"info": {
"description": "Test",
"title": "test",
"version": "1.0"
},
"openapi": "3.1.0",
"servers": [
{
"url": "http://localhost:5000"
}
],
"components": {
"schemas": {
"Response": {
"title": "Response",
"type": "object",
"properties": {
"nullable": {
"type": "array",
"default": null,
"items": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
}
},
"required": [
"nullable"
]
},
"ResponseGet": {
"title": "ResponseGet",
"type": "object",
"properties": {
"nonNullable": {
"type": "array",
"default": null,
"items": {
"type": "string"
}
}
},
"required": [
"nonNullable"
]
}
}
},
"paths": {
"/api": {
"get": {
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ResponseGet"
}
}
},
"description": "OK"
}
}
}
}
}
}
Generation Details
{
"generatorName": "typescript"
}
Steps to reproduce
When generating code for the above API spec, the Response class should have 'nullable': Array<string | null>; and the ResponseGet class should have 'nonNullable': Array<string>;. Instead, both receive Array<string | null>;. I'm unable to determine the exact cause; for example, changing "#/components/schemas/ResponseGet" -> "#/components/schemas/Response" causes both models to be generated correctly. Removing "default": null also seems to somehow fix the bug.
Description
Under some very specific conditions,
| nullis added to array item type when it shouldn't be there.openapi-generator version
7.22.0
OpenAPI declaration file content or url
{ "info": { "description": "Test", "title": "test", "version": "1.0" }, "openapi": "3.1.0", "servers": [ { "url": "http://localhost:5000" } ], "components": { "schemas": { "Response": { "title": "Response", "type": "object", "properties": { "nullable": { "type": "array", "default": null, "items": { "anyOf": [ { "type": "string" }, { "type": "null" } ] } } }, "required": [ "nullable" ] }, "ResponseGet": { "title": "ResponseGet", "type": "object", "properties": { "nonNullable": { "type": "array", "default": null, "items": { "type": "string" } } }, "required": [ "nonNullable" ] } } }, "paths": { "/api": { "get": { "responses": { "200": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ResponseGet" } } }, "description": "OK" } } } } } }Generation Details
{ "generatorName": "typescript" }Steps to reproduce
When generating code for the above API spec, the Response class should have
'nullable': Array<string | null>;and the ResponseGet class should have'nonNullable': Array<string>;. Instead, both receiveArray<string | null>;. I'm unable to determine the exact cause; for example, changing"#/components/schemas/ResponseGet" -> "#/components/schemas/Response"causes both models to be generated correctly. Removing"default": nullalso seems to somehow fix the bug.