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 SPRING] Error type generated for enum integer type. #5177

Open
paranoid945 opened this issue Mar 23, 2017 · 1 comment
Open

[JAVA SPRING] Error type generated for enum integer type. #5177

paranoid945 opened this issue Mar 23, 2017 · 1 comment

Comments

@paranoid945
Copy link

Description

integer type should generate integer output instead of string.

Swagger-codegen version

2.2.2

Swagger declaration file content or url
definitions:
  BaseModel:
    discriminator: baseModelType
    properties:
      code:
        type: integer
        format: int32
        default: 0
        enum: [0, 1]
        description:  0 normal, 1 error.
    required:
      - code
      - baseModelType
Command line used for generation

-l spring --library spring-mvc

Generated Java Model
public class BaseModel   {
  /**
   * 0 normal, 1 error.
   */
  public enum CodeEnum {
    NUMBER_0(0),
    
    NUMBER_1(1);

    private Integer value;

    CodeEnum(Integer value) {
      this.value = value;
    }

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

which output string json value instead of integer:

{
  "code": "0"
}
@ePaul
Copy link
Contributor

ePaul commented Apr 2, 2017

Not related to your issue, but I think you need to also define the baseModelType as a property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants