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

JavaSpring codegen ignores per-field required setting #1310

Open
radarsh opened this issue Aug 30, 2024 · 0 comments
Open

JavaSpring codegen ignores per-field required setting #1310

radarsh opened this issue Aug 30, 2024 · 0 comments

Comments

@radarsh
Copy link
Contributor

radarsh commented Aug 30, 2024

Given the below OAS 3 spec

paths:
  /survey:
    post:
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                name:
                  type: string
                age: 
                  type: integer
              required:
                - name

The expectation is to require a non-null request body but only name to be mandatory. The age property should become optional. However, when code is generated it produces:

    @RequestMapping(value = "/survey",
        consumes = { "application/x-www-form-urlencoded" },
        method = RequestMethod.POST)
    default ResponseEntity<Void> operation(
        @Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="name", required=true)  String name, 
        @Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="age", required=true)  Integer age) {

Observe that age parameter in the generated method signature has required=true when it's clearly not required in the spec.

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

1 participant