Repository navigation
Open
Labels
Description
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.
Activity
KannaKim commentedon Jun 28, 2026
Alternatively, adding
{ "nullable": false }fix the issue.
Full yaml looks like this:
In this case we get
for ResponseGet, as desired