Skip to content

[BUG][JAVA] Maven plugin generates an Interface with Lombok annotations #13917

@luciano-fiandesio

Description

@luciano-fiandesio

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

Given this configuration of the openapi-generator-maven-plugin:

<configuration>
    <inputSpec>
        ${project.basedir}/src/main/resources/openapi/api.yaml
    </inputSpec>

    <generatorName>spring</generatorName>
    <apiPackage>org.openapitools.codegen.api</apiPackage>
    <modelPackage>org.openapitools.codegen.api.model</modelPackage>
    <configOptions>
        <interfaceOnly>true</interfaceOnly>
        <apiPackage>org.openapitools.codegen.controller</apiPackage>
        <serializableModel>true</serializableModel>
        <documentationProvider>springdoc</documentationProvider>

        <additionalModelTypeAnnotations>@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor</additionalModelTypeAnnotations>
    </configOptions>
</configuration>

And given a component schema like the following:

components:
  schemas:
    PatchRequest:
      type: array
      items:
        oneOf:
          - $ref: '#/components/schemas/A'
          - $ref: '#/components/schemas/B'
          - $ref: '#/components/schemas/C'

    A:
      type: object
      ...
    B:
      type: object
      ...
    C:
      type: object
      ...

The generator generates a Java interface annotated with Lombok annotations:

lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2022-11-04T13:47:46.119673+01:00[Europe/Berlin]")
public interface PatchRequestInner extends Serializable {
}

Which makes the compilation to fail.

Please, look at this repository to reproduce the bug: https://github.com/luciano-fiandesio/openapi-generator-plugin-bug

openapi-generator version
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.2.1</version>
OpenAPI declaration file content or url

https://raw.githubusercontent.com/luciano-fiandesio/openapi-generator-plugin-bug/main/src/main/resources/openapi/api.yaml

Generation Details

Incorrectly annotated Interface:

lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor

@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2022-11-04T13:47:46.119673+01:00[Europe/Berlin]")
public interface PatchRequestInner extends Serializable {
}
Steps to reproduce

Please see this repository: https://github.com/luciano-fiandesio/openapi-generator-plugin-bug

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