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
  • #1525
Closed
Open
Issue created Nov 22, 2018 by Administrator@rootContributor

[JAVA][Server] Generated model classes are missing default values

Created by: ccozzolino

Description

Certain java server model classes do not properly declare default values for certain fields. For example, here is the beginning of Pet.java from the samples directory (pulled from undertow, vertx-async, vertx-rx). Note the missing default value for the id, name, and status fields:

@JsonInclude(JsonInclude.Include.NON_NULL) 
public class Pet   {
  
  private Long id = ;
  private Category category = null;
  private String name = ;
  private List<String> photoUrls = new ArrayList<>();
  private List<Tag> tags = new ArrayList<>();


  public enum StatusEnum {
    AVAILABLE("available"),
    PENDING("pending"),
    SOLD("sold");

    private String value;

    StatusEnum(String value) {
      this.value = value;
    }

    @Override
    @JsonValue
    public String toString() {
      return value;
    }
  }

  private StatusEnum status = ;

  public Pet () {

  }
openapi-generator version

This appears to be a regression since 3.3.1.

Reproduced issue with openapi generator 3.3.1, 3.3.2, 3.3.3, and current master.

Testing against 3.3.0 generates models with proper defaults.

OpenAPI declaration file content or url

Issue is reproducible with certain java server samples (undertow, vertx-async, vertx-rx) provided in this project for the versions mentioned above.

Command line used for generation

Generate models from existing sample servers to reproduce the problem:

mvn clean ; ./bin/java-undertow-petstore-server.sh mvn clean ; ./bin/java-vertx-async-petstore-server.sh mvn clean ; ./bin/java-vertx-rx-petstore-server.sh

Assignee
Assign to
Time tracking