Skip to content

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

Closed
@jianglin8-hub

Description

@jianglin8-hub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions