Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model not generated for free-form object for Java client #2037

Closed
zslajosfalvi opened this issue Feb 1, 2019 · 11 comments · Fixed by #2044
Closed

Model not generated for free-form object for Java client #2037

zslajosfalvi opened this issue Feb 1, 2019 · 11 comments · Fixed by #2044

Comments

@zslajosfalvi
Copy link

zslajosfalvi commented Feb 1, 2019

    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.

@jmini
Copy link
Member

jmini commented Feb 1, 2019

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

@zslajosfalvi zslajosfalvi changed the title Model not generated for free-form object Model not generated for free-form object for Java client Feb 1, 2019
@zslajosfalvi
Copy link
Author

I tried this option but it has no effect on the code generation.
The HungarianCreditTransfer class is still not generated.

@wing328
Copy link
Member

wing328 commented Feb 1, 2019

@zslajosfalvi thanks for reporting the issue. I think I know where to fix it and will try to submit a PR over the weekend.

@wing328
Copy link
Member

wing328 commented Feb 4, 2019

@zslajosfalvi the issue has been addressed with #2044

Please give it another try with the latest master.

@wing328 wing328 added this to the 4.0.0 milestone Feb 4, 2019
@zslajosfalvi
Copy link
Author

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.

@wing328
Copy link
Member

wing328 commented Feb 4, 2019

@zslajosfalvi
Copy link
Author

zslajosfalvi commented Feb 4, 2019

Thanks.
Actually I use the Maven plugin to run the code generator.
Has it also a snapshot version?

@jmini
Copy link
Member

jmini commented Feb 4, 2019

@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.

@zslajosfalvi
Copy link
Author

I tried the fix in 4.0.0-SNAPSHOT as you suggested and the problem seems to be resolved.
Thanks for fixing it!

@ahrooran
Copy link

ahrooran commented Feb 2, 2023

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?

@v1shva
Copy link

v1shva commented Apr 17, 2023

I was also facing the same issue and I manually removed following properties and then it worked without an issue.

      type: object
      properties: {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants