openapi-codegen
openapi-codegen copied to clipboard
feat: Support nullable on allOf schemas
I'm currently using @nestjs/swagger and for nested references it generates the following openapi schema (trimmed for readability):
{
"openapi": "3.0.0",
"paths": {},
"components": {
"schemas": {
"HydratedAssetDto": {
"type": "object",
"properties": {}
},
"HydratedPackageDto": {
"type": "object",
"properties": {
"asset": {
"nullable": true,
"allOf": [{ "$ref": "#/components/schemas/HydratedAssetDto" }]
}
}
}
}
}
}
In my case I need to ensure HydratedPackageDto.asset will have type HydratedAssetDto | null
I was using https://www.npmjs.com/package/openapi-typescript before and it was generating that type for allOf with nullable
I didn't go through the spec to 100% confirm this is legal, but it looks fine 😅
If you have a suggestion on how to get to the same result with a different schema I'm all ears