Closed chameleon82 closed 3 years ago
thanks @chameleon82, could you do a PR?
@chameleon82 most of the OpenAPI generation is done using io.swagger.v3.jaxrs2.Reader which is in a different lib from this - it might be that the fix needs to go there - but have a look yourself
@chameleon82 this is not even the right lib for this issue - maybe https://github.com/swagger-api/swagger-core (for swagger-jaxrs2) or https://github.com/swagger-akka-http/swagger-akka-http but not this - this lib is for generating the models not the request body definitions.
When you add swagger annotations, you could explicity set required = true.
@Operation(summary = "Add integers", description = "Add integers",
requestBody = new RequestBody(required = true, content = Array(new Content(schema = new Schema(implementation = classOf[AddOptionRequest])))),
responses = Array(
new ApiResponse(responseCode = "200", description = "Add response",
content = Array(new Content(schema = new Schema(implementation = classOf[AddOptionResponse])))),
new ApiResponse(responseCode = "500", description = "Internal server error"))
)
@chameleon82 I updated https://github.com/pjfanning/swagger-akka-http-sample to set the required=true in the Operation annotations
Next code will produce optional body
as openapi result:
but OpenApi said
body
is optional and not required by default ( https://swagger.io/docs/specification/describing-request-body/ )Expected behavior is to have parameter
required
because it is defined as mandatory parameter: