I'm having a issue where the response schema for the erros codes, such 400, 500 e etc. not being show as a no content in the swagger UI. It replicate the schema set for the 200 response code, when using the yaml file generated code.
I'm using the springdoc dependency to configure the UI from the swagger, in the documentation of springdoc I found that you can define no content response schema using this annotattions: springdoc-documentation
The main problem is that the code is generated by the swagger codegen, which I cannot modify and applied the solution present in the documentation. Here's my code:
The yaml file:
400:
description: Requisição inválida
content: { }
401:
description: Falha na autenticação
content: { }
500:
description: Erro no sistema
content: { }
The generated code:
@ApiResponses(value = {
@ApiResponse(responseCode = "202", description = "Solicitação recebida com sucesso.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectName.class))),
@ApiResponse(responseCode = "400", description = "Requisição inválida"),
@ApiResponse(responseCode = "401", description = "Falha na autenticação"),
@ApiResponse(responseCode = "500", description = "Erro no sistema") })
@RequestMapping(value = "/evento-nao-financeiro",
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.POST)
default ResponseEntity<StatusSafRepresentation> methodName
As you can see, I need to add the code 'content = @Content(schema = @Schema(hidden = true))' in those apiResponses that isn't the 202 status.
Ps: I'm using the latest dependency from springdoc
<groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.7.0</version>