You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (annotations == null || annotations.length == 0) {
Why is this only executed when the Array in the line above is null or empty? In this case ApiResponse Annotations made in a custom annotation to centralize error responses or other common responses like for example:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@ApiResponses(value = {
@ApiResponse(
responseCode = "500",
description = "Returns Object of Type: MyException in case of an error." +
" Please check the MyException for further details.",
content = @Content(schema = @Schema(implementation = MyException.class))
)
})
public @interface CommonResponses {}
Which later is used like this for example:
@CommonResponses@Operation(
summary = "Inserts a new thing",
description = "Use this method to insert a new thing",
operationId = "insertThing",
tags = {"thing"}
)
@ApiResponse(responseCode = "201",
description = "Returns the the created thing.",
content = @Content(schema = @Schema(implementation = Result.class)),
headers = {@Header(name = HttpHeaders.LOCATION, description = "The location of the newly created thing.")}
)
@ApiResponse(responseCode = "400",
description = "Returns 400 if required parameters are missing.",
content = @Content(schema = @Schema(implementation = Result.class))
)
@POST@Produces(MediaType.APPLICATION_JSON)
publicResponseinsertThing(
@ContextUriInfouriInfo,
@ContextSecurityContextsecurityContext,
Thingthing) {
.....
returnResponse.created(newURI(locationHeader)).entity(result).build();
}
When using my CommonResponses like this, the 500 Response (would like to place some more there...) from that is ignored.
If I don't use ApiResponse annotations on the method itself, only then my meta annotation is picked up.
Is it possible to always include meta annotations or what's the point against doing this?
Thanks for reply / fixing this
/Soeren
The text was updated successfully, but these errors were encountered:
SHSolution
changed the title
ApiResponse from from custom meta annotations are ignored in certain case
ApiResponse from custom meta annotations are ignored in certain case
Apr 15, 2021
swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ReflectionUtils.java
Line 321 in 96b072c
Why is this only executed when the Array in the line above is null or empty? In this case ApiResponse Annotations made in a custom annotation to centralize error responses or other common responses like for example:
Which later is used like this for example:
When using my CommonResponses like this, the 500 Response (would like to place some more there...) from that is ignored.
If I don't use ApiResponse annotations on the method itself, only then my meta annotation is picked up.
Is it possible to always include meta annotations or what's the point against doing this?
Thanks for reply / fixing this
/Soeren
The text was updated successfully, but these errors were encountered: