Model not generated for free-form object for Java client
SinglePayment:
type: object
description: Single payment
properties:
endToEndIdentification:
type: string
HungarianCreditTransferIG2:
type: object
description: Single payment IG2 fields
properties:
payerId:
type: string
HungarianCreditTransfer:
type: object
allOf:
- $ref: '#/components/schemas/SinglePayment'
- $ref: '#/components/schemas/HungarianCreditTransferIG2'
PostHungarianCreditTransferRequest:
description: Hungarian credit transfer request
allOf:
- $ref: '#/components/schemas/HungarianCreditTransfer'
paths:
/payments/hungarian-credit-transfers:
post:
tags:
- payment-initiation-service
operationId: postHungarianCreditTransferPayments
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostHungarianCreditTransferRequest'
responses:
'201':
description: Payment created
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/PostPaymentsResponse'
I used Maven OpenAPI codegen 4.0.0 beta2 with config
<configuration>
<generateModelTests>false</generateModelTests>
<generateApiTests>false</generateApiTests>
<generateSupportingFiles>false</generateSupportingFiles>
<inputSpec>${project.build.directory}/classes/xs2a-pisp.yaml</inputSpec>
<validateSpec>false</validateSpec>
<generatorName>jaxrs-cxf</generatorName>
<output>${project.build.directory}/generated-sources</output>
<configOptions>
<sourceFolder>java</sourceFolder>
<apiPackage>${api.package}</apiPackage>
<modelPackage>${model.package}</modelPackage>
<useGenericResponse>true</useGenericResponse>
<useBeanValidation>${useBeanValidation}</useBeanValidation>
<interfaceOnly>true</interfaceOnly>
</configOptions>
</configuration>
SinglePayment HungarianCreditTransferIG2 model classes gets generated, but HungarianCreditTransfer not.
I get the following INFO message: [INFO] Model PeriodicHungarianCreditTransfer not generated since it's a free-form object
Maybe this looks like not a bug, but I need the HungarianCreditTransfer class in my code. Is it possible to force generate this class? With previous version (3.3.4) the HungarianCreditTransfer class is generated.
Thank you for trying 4.0.0-beta2
I tend to agree with you, if HungarianCreditTransfer = allOf ( SinglePayment, HungarianCreditTransferIG2) then it is not a free-form object.
There is a flag generateAliasAsModel that you can set to true but I am not sure if it will impact the generation in your case.
Maybe related issue: #453
I tried this option but it has no effect on the code generation. The HungarianCreditTransfer class is still not generated.
@zslajosfalvi thanks for reporting the issue. I think I know where to fix it and will try to submit a PR over the weekend.
@zslajosfalvi the issue has been addressed with #2044
Please give it another try with the latest master.
Thanks for the fix. However I have to wait for the new beta or final release since I don't build the code from source.
@zslajosfalvi you can use the SNAPSHOT version instead: https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/
Thanks. Actually I use the Maven plugin to run the code generator. Has it also a snapshot version?
@zslajosfalvi Yes there is one: https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-maven-plugin/4.0.0-SNAPSHOT/
Depending on your setting, you might need https://oss.sonatype.org/content/repositories/ as pluginRepository in your pom or setting xml.
I tried the fix in 4.0.0-SNAPSHOT as you suggested and the problem seems to be resolved. Thanks for fixing it!
We are seeing this issue in version 6.2.1, config:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
<executions>
<execution>
<id>redacted</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/myopenapispec.yaml
</inputSpec>
<apiPackage>uk.co.redacted.oa.swagger.api</apiPackage>
<modelPackage>uk.co.redacted.oa.swagger.model</modelPackage>
<invokerPackage>uk.co.redacted.oa.swagger.invoker</invokerPackage>
<modelNamePrefix>redacted</modelNamePrefix>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<useJaxbAnnotations>true</useJaxbAnnotations>
<dateLibrary>java8</dateLibrary>
<delegatePattern>true</delegatePattern>
<interfaceOnly>true</interfaceOnly>
<openApiNullable>false</openApiNullable>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Swagger spec:
OtherData1:
type: object
properties: {}
additionalProperties: true
description: >-
Additional information that can not be captured in the structured fields
and/or any other specific block.
Everything else is being generated fine, its only this free form object that fails. Any thoughts on this? Is anyone else able to replicate this issue?
I was also facing the same issue and I manually removed following properties and then it worked without an issue.
type: object
properties: {}
Same here, without any impact of generateAliasAsModel on the described issue. Using version 2.17.0 of openapi-generator CLI with "--additional-properties=generateAliasAsModel=true". Please provide an alternative.