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

[BUG][Java Spring OAS3] Openapi 2 imports in oas3 mode in the POJOs #11164

Closed
whydoievenneedthis opened this issue Dec 21, 2021 · 1 comment
Closed

Comments

@whydoievenneedthis
Copy link

Description

Every POJO that is generated contains the following two imports in it:

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
openapi-generator version

5.3.1

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Api Documentation
  description: Api Documentation
  termsOfService: urn:tos
  contact: {}
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0
  version: '1.0'
paths:
  /thingy:
    get:
      operationId: get
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseList'
components:
  schemas:
    ResponseList:
      type: array
      items:
        $ref: '#/components/schemas/ResponseEntry'
    ResponseEntry:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
Generation Details

Generator name: spring
Config options: oas3 = true

Generated java code for ResponseEntry class
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.UUID;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
...
Expected java code for ResponseEntry class
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.UUID;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
...
Additional info

The source of these two imports are the model.mustache file, particularly these lines:

{{#imports}}import {{import}};
{{/imports}}

Unfortunately, these are also pulling in other imports, eg.

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

As a result, it is not trivial to try and circumvent this particular bug by tweaking the mustache files.

@wing328
Copy link
Member

wing328 commented Jan 2, 2022

Closed via #11181. Please pull the latest master to give it another try.

@wing328 wing328 closed this as completed Jan 2, 2022
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