Quarkus:无法为MicroProfile apiresponses创建自定义注释 - 错误 - @@apiresponses'不适用于注释类型

发布于 2025-01-26 19:59:11 字数 641 浏览 4 评论 0原文

Quarkus,带有微型露天和招摇。 我们正在尝试为@apirespons创建自定义注释。 这可能在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 {`
`}`

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不顾 2025-02-02 19:59:11

这不是在夸克(Quarkus)中可能存在的问题,而是微型露天的可能性。

apiresponses注释的目标定义为@target({emementType.method}),因此您不能在类型上使用它,仅在方法上。

将问题提高到微填充openapi项目可能是一个好主意,以解释您要做什么以及为什么要做什么,并查看是否应该更改某些东西。然后,它自然会在Quarkus中结束。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文