Skip to content

[BUG] x-class-extra-annotation will not generate annotation to interface when using oneOf #20110

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

Open
5 of 6 tasks
JaroslavBeno opened this issue Nov 15, 2024 · 1 comment
Open
5 of 6 tasks

Comments

@JaroslavBeno
Copy link

JaroslavBeno commented Nov 15, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

7.4.0

pom.xml :
<plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>7.4.0</version>
                <executions>
                    <!-- generate serve stub out of open API definition. -->
                    <!-- execute the plugin only when install is called -->
                    <execution>
                        <id>generate-ips-server-skeleton</id>
                        <phase>install</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>
                                ${project.basedir}/api_spec/openapi.yaml
                            </inputSpec>
                            <generatorName>spring</generatorName>
                            <library>spring-boot</library>
                            <apiPackage>com.jaroslavbeno.controller</apiPackage>
                            <modelPackage>com.jaroslavbeno.model</modelPackage>
                            <supportingFilesToGenerate>
                                ApiUtil.java
                            </supportingFilesToGenerate>
                            <globalProperties>
                                <skipFormModel>false</skipFormModel>
                            </globalProperties>

                            <configOptions>
                                <delegatePattern>true</delegatePattern>
                                <sourceFolder>/src/main/java</sourceFolder>
                                <implFolder>/src/main/java</implFolder>
                                <additionalModelTypeAnnotations>
                                    @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)
                                </additionalModelTypeAnnotations>
                                <hideGenerationTimestamp>true</hideGenerationTimestamp>
                                <useJakartaEe>true</useJakartaEe>
                            </configOptions>
                        </configuration>
                    </execution>
Steps to reproduce

I have got:

      requestBody:
        description: "Search Institutional Member Accounts based on search criteria.If there are no matches, an empty array will be returned"
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/SearchMemberRequest'
                - $ref: '#/components/schemas/SearchMemberCardRequest'
              x-class-extra-annotation: "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.jaroslavbeno.SearchDeserializer.class)"
        required: true

Now it will generate one interface and two classes implementing that interface.
I have to manually add annotation to interface:

@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.jaroslavbeno.SearchDeserializer.class)

x-class-extra-annotation is ignored

x-class-extra-annotation: "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.jaroslavbeno.SearchDeserializer.class)"

Can you add a special x- for interfaces?
x-interface-extra-annotation

@katepol
Copy link

katepol commented Dec 31, 2024

I'd like to note that using openapi-generator of version 7.10.0
the CodegenProperty for optionalRefData is missing deprecated, description and x-field-extra-annotation values.

openapi: 3.1.0
info:
  title: ref_properties
  version: "dev"
paths: {}
components:
  schemas:
    SomeObject:
      type: object
      properties:
        info:
          type: string
      required:
      - info
    RequestParameters:
      type: object
      properties:
        optionalRefData:
          deprecated: true
          description: optional ref
          x-field-extra-annotation: '@com.example.SomeExtraAnnotation'
          oneOf:
          - $ref: '#/components/schemas/SomeObject'
          - type: 'null'

cc @wing328 I found your changes around allOf schema #19986, may be you are the right person to address this

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

No branches or pull requests

2 participants