swagger-api / swagger-api/swagger-codegen

Generated code is not validation boolean values

Open
#9,621 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

If we have this spec

 exp_list:       
        type: object
        properties:
          exclude:            
            type: boolean
          names:
            type: array
            items:
              type: string
        required:
          - exclude
          - names

maven-swagger-plugin will generated models with method

/**
   * calculate SKUs exclude SKU in names list
   * @return exclude
  **/
  @ApiModelProperty(required = true, value = "calculate SKUs exclude SKU in names list")
  @NotNull


  public Boolean isExclude() {
    return exclude;
  }

But need to generate method getExclude for spring validation work properly. Now really Boolean fields is not validated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generated Java model from the YAML example using the maven-swagger-plugin, then trace the Java model template or generator path that emits isExclude(). Verify how Spring validation handles the generated Boolean field. Done means the generated accessor is getExclude() and Boolean validation works for the required field.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.