Forum Discussion

Blago's avatar
Blago
New Contributor
4 years ago
Solved

Unable to set header parameter to optional

I'm using Java 11.0.2, Spring Boot 2.2.6 and Spring OpenApi Core 1.1.49 to create an OpenApi documentation using annotations. The issue:   During the request for creating a client in the Controller...
  • Blago's avatar
    4 years ago

    Found the solution - the problem wasn't in OpenApi annotation @Parameter, but in Spring binding annotation @RequestHeader, which binds the header field to the method parameter. @RequestHeader has also field "required" and by default, it's set on "true" and it overrides the one in @Parameter. So the solution was the following syntax - @RequestHeader(name = "X-Request-Correlation-Id", required = false).