Closed croudet closed 5 years ago
@croudet Can you please try with setting mediaType
to @Content
? For example:
@ApiResponse(responseCode = "200", description = "Returns a dummy", content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = Dummy.class)))
@puneetbehl That did the trick, thanks. But the RequestBody
annotation works out of the box without the mediaType
attribute.
I have this problem with a Groovy controller. When I add the mediaType as suggested, I am getting this error:
Error reading Swagger Operation for element [io.micronaut.ast.groovy.visitor.GroovyMethodElement@a27e3e0]: Cannot construct instance of io.swagger.v3.oas.models.media.MediaType
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('application/json')
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: io.swagger.v3.oas.models.responses.ApiResponse["content"]->io.swagger.v3.oas.models.media.Content["mediaType"]) (through reference chain: io.swagger.v3.oas.models.Operation["responses"])
And the endpoint does not exist at all in the generated YAML.
Thanks for reporting an issue for Micronaut, please review the task list below before submitting the issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.
NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/micronaut) or Gitter (https://gitter.im/micronautfw/). DO NOT use the issue tracker to ask questions.
Task List
Steps to Reproduce
Expected Behaviour
In a Controller, when you have
ApiResponse
s withSchema
annotations, the generated yaml does not use the schema.The
content
should point toDummy
Actual Behaviour
The
content
part is empty.Environment Information
Example Application
See
HelloOperations
andHelloController
in: