Skip to content

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

@JaroslavBeno

Description

@JaroslavBeno

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions