Description
When using openapi-generator 7.12.0 with OpenAPI 3.1.0 specification, fields marked as nullable in the referred schema are not properly generated as nullable in the TypeScript output, if the schema is combined using the allOf keyword. The same specification works correctly when using OpenAPI 3.0.0.
When a field is defined with type: [string, "null"] in schema in OpenAPI 3.1.0, if the schema is combined using allOf keyword, the generated TypeScript interface does not maintain the nullable property in the generated code.
openapi-generator version
7.12.0
OpenAPI declaration file content
openapi: 3.1.0
info:
version: 1.0.0
title: Example - OpenAPI 3.1
description: Example
components:
schemas:
TargetSchema:
properties:
id:
type: [string, "null"]
name:
type: string
RefSchemaWithAllOf:
allOf:
- $ref: "#/components/schemas/TargetSchema"
Generated API
/**
*
* @export
* @interface RefSchemaWithAllOf
*/
export interface RefSchemaWithAllOf {
/**
*
* @type {string}
* @memberof RefSchemaWithAllOf
*/
'id'?: string;
/**
*
* @type {string}
* @memberof RefSchemaWithAllOf
*/
'name'?: string;
}
/**
*
* @export
* @interface TargetSchema
*/
export interface TargetSchema {
/**
*
* @type {string}
* @memberof TargetSchema
*/
'id'?: string | null;
/**
*
* @type {string}
* @memberof TargetSchema
*/
'name'?: string;
}
Generation Details
Using CLI:
openapi-generator-cli generate -g typescript-axios -i swagger.yml
Steps to reproduce
- Create the OpenAPI 3.1.0 specification as shown above
- Generate TypeScript code using openapi-generator 7.12.0
- Observe the generated output
Current output:
export interface RefSchemaWithAllOf {
'id'?: string; // Should be string | null
'name'?: string;
}
Expected output:
export interface RefSchemaWithAllOf {
'id'?: string | null;
'name'?: string;
}
Description
When using openapi-generator 7.12.0 with OpenAPI 3.1.0 specification, fields marked as nullable in the referred schema are not properly generated as nullable in the TypeScript output, if the schema is combined using the
allOfkeyword. The same specification works correctly when using OpenAPI 3.0.0.When a field is defined with
type: [string, "null"]in schema in OpenAPI 3.1.0, if the schema is combined usingallOfkeyword, the generated TypeScript interface does not maintain the nullable property in the generated code.openapi-generator version
7.12.0
OpenAPI declaration file content
Generated API
Generation Details
Using CLI:
Steps to reproduce
Current output:
Expected output: