Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11323
Closed
Open
Issue created Jan 15, 2022 by Administrator@rootContributor

[BUG][JAVA][SPRING] missing JsonValue import if allOf used as inline-scheme composition

Created by: souwa

Description

When using allOf as a composition inline-scheme without inheritance/discriminator the import import com.fasterxml.jackson.annotation.JsonValue for the Enum method @JsonValue public String getValue() is not added to the imports of the generated class.

This happens when the inline model doesn't have enums, but the parent does.

Also, the syntax that was used is the only workaround that prevents the generation of the redundant additional ParentTitle+AllOf class (see Java generation of 'extra' class with allOf Workaraound):

    Address:
      type: object
      properties:
        locationType:
          type: string
          enum:
            - VILLAGE
            - SMALL_TOWN
            - BIG_CITY
      allOf:
        - $ref: '#/components/schemas/BasicAddress'

    BasicAddress:
      type: object
      properties:
        street:
          type: string
        housenumber:
          type: string
        zip:
          type: string
        city:
          type: string
        country:
          type: string

The result includes the following imports from Jackson,

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;

but not the JsonValue-Import: although the method is generated

    @JsonValue
    public String getValue() {
      return value;
    }
openapi-generator version

openapi-generator v. 5.3.1 ( for java spring)

Related issues/PRs

If the generation of the additional unnecessary ParentTitle+AllOf class is fixed then I believe that will fix this problem as well. Opt-in solution to remove unnecessary model for inline schema composition

Suggest a fix

For the solution, this method postProcessModelProperty (SpringCodegen) might probably be adapted at the point where Jackson imports are added and the model will be checked if it is or has enums or not.

Assignee
Assign to
Time tracking