'Quarkus: Unable to create custom annotation for microprofile APIResponses - Error - '@APIResponses' not applicable to annotation type

Quarkus with microprofile openapi and swagger. We are trying to create custom annotation for @APIResponses. Is this possible in quarkus?

`org.eclipse.microprofile.openapi.annotations.APIResponses;`
`package org.eclipse.microprofile.openapi.annotations.*;`

`@Target({ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE})`
`@Inherited`
`@Documented`
`@Retention(RetentionPolicy.RUNTIME)`
`@Target(ElementType.TYPE)`
`@ApplicationScoped`
`@APIResponses(value = {`
`@APIResponse(responseCode = "200", description = ".."),`
`@APIResponse(responseCode = "201", description = "..") ,`
`@APIResponse(responseCode = "202", description = "..") }`
`)`
`public @interface customApiResponse {`
`}`


Solution 1:[1]

It is not a question of being possible in Quarkus but more possible with MicroProfile OpenAPI.

The ApiResponses annotation has a target defined to @Target({ ElementType.METHOD }) so you cannot use it on a type, only on methods.

Probably a good idea to raise the issue to the MicroProfile OpenAPI project explaining what you want to do and why and see if something should be changed. Then it will naturally end up in Quarkus.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guillaume Smet