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

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

Closed
ccozzolino opened this issue Nov 22, 2018 · 0 comments · Fixed by #1549
Closed

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

ccozzolino opened this issue Nov 22, 2018 · 0 comments · Fixed by #1549

Comments

@ccozzolino
Copy link
Contributor

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

ccozzolino added a commit to ccozzolino/openapi-generator that referenced this issue Nov 27, 2018
wing328 pushed a commit that referenced this issue Dec 12, 2018
…ns (Regression since 3.3.1) (#1549)

* Fixed issue #1525. Adjust class field declarations with proper initializations.

* Adjusted templates to add default only when it is exists.
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this issue Feb 27, 2019
…nitializations (Regression since 3.3.1) (OpenAPITools#1549)

* Fixed issue OpenAPITools#1525. Adjust class field declarations with proper initializations.

* Adjusted templates to add default only when it is exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant