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

500 views Asked by At

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 {`
`}`
1

There are 1 answers

3
Guillaume Smet On

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.