Bug Report Checklist
Description
I have a schema called Item, I have array of Item properties in many schemas so I made an ItemArray alias to make my property definition shorter. I have generateAliasAsModel=true because I have other schema aliases. The generated Java code is
private ItemArray itemArray = new ArrayList<>();
which obviously does not compile. The correct code in this case should be
private List<Item> itemArray = new ArrayList<>();
openapi-generator version
7.23.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Test
version: 0.0.1
paths: {}
components:
schemas:
Item:
type: object
properties:
property:
type: string
ItemArray:
type: array
items:
$ref: '#/components/schemas/Item'
MyObject:
type: object
properties:
id:
type: string
format: uuid
itemArray:
$ref: '#/components/schemas/ItemArray'
Generation Details
config from pom.xml
<generateSupportingFiles>false</generateSupportingFiles>
<generatorName>spring</generatorName>
<strictSpec>true</strictSpec>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateAliasAsModel>true</generateAliasAsModel>
<configOptions>
<legacyDiscriminatorBehavior>true</legacyDiscriminatorBehavior>
<library>spring-boot</library>
<oas3>true</oas3>
<useSpringController>true</useSpringController>
<useSpringBoot3>true</useSpringBoot3>
<useSpringfox>false</useSpringfox>
<interfaceOnly>true</interfaceOnly>
<skipDefaultInterface>true</skipDefaultInterface>
<useBeanValidation>true</useBeanValidation>
<useEnumCaseInsensitive>false</useEnumCaseInsensitive>
<useClassLevelBeanValidation>false</useClassLevelBeanValidation>
<serializableModel>true</serializableModel>
<useTags>true</useTags>
<javaNative>21</javaNative>
<useOptional>false</useOptional>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<dateLibrary>java8</dateLibrary>
<bigDecimalAsString>true</bigDecimalAsString>
<generateApiUtil>false</generateApiUtil>
<openApiNormalizer>RULE_1=true</openApiNormalizer>
<apiPackage>com.test.api</apiPackage>
<modelPackage>com.test.model</modelPackage>
</configOptions>
Steps to reproduce
The generated Java code is always wrong.
Related issues/PRs
Suggest a fix
The generated Java code should be
private List<Item> itemArray = new ArrayList<>();
instead of
private ItemArray itemArray = new ArrayList<>();
Bug Report Checklist
Description
I have a schema called Item, I have array of Item properties in many schemas so I made an ItemArray alias to make my property definition shorter. I have
generateAliasAsModel=truebecause I have other schema aliases. The generated Java code isprivate ItemArray itemArray = new ArrayList<>();which obviously does not compile. The correct code in this case should be
private List<Item> itemArray = new ArrayList<>();openapi-generator version
7.23.0
OpenAPI declaration file content or url
Generation Details
config from pom.xml
Steps to reproduce
The generated Java code is always wrong.
Related issues/PRs
Suggest a fix
The generated Java code should be
private List<Item> itemArray = new ArrayList<>();instead of
private ItemArray itemArray = new ArrayList<>();