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

Request parameter parsing error after using @NotBlank in the from type interface field #2519

Closed
jianglin8-hub opened this issue Mar 3, 2024 · 0 comments

Comments

@jianglin8-hub
Copy link

Describe the bug

    @PostMapping("/test1")
    public Result test1(String ip) {
        return new Result();
    }

    @PostMapping("/test2")
    public Result test2(@NotBlank String ip) {
        return new Result();
    }
{"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://127.0.0.1:8080","description":"Generated server url"}],"paths":{"/test2":{"post":{"tags":["test-controller"],"operationId":"test2","requestBody":{"content":{"application/json":{"schema":{"type":"string"}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}}}}}},"/test1":{"post":{"tags":["test-controller"],"operationId":"test1","parameters":[{"name":"ip","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Result"}}}}}}}},"components":{"schemas":{"Result":{"type":"object","properties":{"data":{"type":"object"},"code":{"type":"integer","format":"int32"}}}}}}

image

These are two API interfaces with the same functionality, the only difference being the addition of @ NotBlank to the parameter IP, where the/test2 interface does not display the request parameter IP field in v3/api-docs

  • If you are reporting a bug, please help to speed up problem diagnosis by providing as
    much information as possible:
  • A clear and concise description of what the bug is: the title of an issue is not enough

To Reproduce
Steps to reproduce the behavior:

This is the demonstration code
https://github.com/jianglin8-hub/openapi3Test
  • What version of spring-boot you are using?
  • What modules and versions of springdoc-openapi are you using?
  • What is the actual and the expected result using OpenAPI Description (yml or json)?
  • Provide with a sample code (HelloController) or Test that reproduces the problem

Expected behavior
Correctly parsing the request parameters of the form interface, I believe that after using the @ NotBlank annotation, the IP parameter should be displayed in docs and marked as mandatory

  • A clear and concise description of what you expected to happen.
  • What is the expected result using OpenAPI Description (yml or json)?

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

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