Helidon MP OpenAPI不会生成更新的openapi端点响应

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Helidon MP OpenAPI不会生成更新的openapi端点响应相关的知识,希望对你有一定的参考价值。

我目前正在按照Oracle本身的指南和教程构建基于Helidon Microprofile的微服务,但是在使用注释时,我遇到了与“自动OpenAPI规范生成器”相关的问题。

我的POM包含一个MP捆绑包和集成使其可以与Hibernate提供的JPA一起使用。

即使在我的资源上设置了所有注释之后,它也不会生成更新的规范。

POM

<dependencies>
    <dependency>
        <groupId>io.helidon.microprofile.bundles</groupId>
        <artifactId>helidon-microprofile</artifactId>
        <version>1.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.jboss</groupId>
        <artifactId>jandex</artifactId>
        <version>2.1.1.Final</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.199</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.helidon.integrations.cdi</groupId>
        <artifactId>helidon-integrations-cdi-datasource-hikaricp</artifactId>
        <version>1.4.0</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.helidon.integrations.cdi</groupId>
        <artifactId>helidon-integrations-cdi-jta-weld</artifactId>
        <version>1.4.0</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.helidon.integrations.cdi</groupId>
        <artifactId>helidon-integrations-cdi-hibernate</artifactId>
        <version>1.4.0</version>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>javax.transaction-api</artifactId>
        <version>1.3</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>jakarta.persistence</groupId>
        <artifactId>jakarta.persistence-api</artifactId>
        <version>2.2.3</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

我仅使用指南中指定的注释和@OpenAPIDefinition来定义标题和许可证之类的内容。

资源

    @OpenAPIDefinition(
        info = @Info(
                title = "Newsletter Microservice",
                version = "1.0", description = "Microservice in charge of handling newsletter",
                license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"),
                contact = @Contact(name = "Email", url = "mailto:email")
        ),
        tags = {
                @Tag(name = "public"), @Tag(name = "private")
        }
)

@Path("/newsletter")
@RequestScoped
public class NewsletterClientResource {

LOG

Connected to the target VM, address: '127.0.0.1:0', transport: 'socket'
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2019.12.02 20:01:19 INFO org.jboss.weld.Version Thread[main,5,main]: WELD-000900: 3.1.1 (Final)
2019.12.02 20:01:20 INFO org.jboss.weld.Bootstrap Thread[main,5,main]: WELD-ENV-000020: Using jandex for bean discovery
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jboss.weld.util.bytecode.ClassFileUtils$1 (file:/C:/Users/Brenno%20Fagundes/.m2/repository/org/jboss/weld/weld-core-impl/3.1.1.Final/weld-core-impl-3.1.1.Final.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of org.jboss.weld.util.bytecode.ClassFileUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019.12.02 20:01:21 INFO org.jboss.weld.Event Thread[main,5,main]: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jersey.ext.cdi1x.internal.ProcessAllAnnotatedTypes.processAnnotatedType(@Observes ProcessAnnotatedType<?>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2019.12.02 20:01:21 INFO org.jboss.weld.Event Thread[main,5,main]: WELD-000411: Observer method [BackedAnnotatedMethod] private io.helidon.microprofile.openapi.IndexBuilder.processAnnotatedType(@Observes ProcessAnnotatedType<X>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
2019.12.02 20:01:22 INFO org.jboss.weld.Bootstrap Thread[main,5,main]: WELD-ENV-002003: Weld SE container 404f642b-892f-4676-960e-8df848aee3a3 initialized
2019.12.02 20:01:22 INFO io.helidon.microprofile.security.SecurityMpService Thread[main,5,main]: Security extension for microprofile is enabled, yet security configuration is missing from config (requires providers configuration at key security.providers). Security will not have any valid provider.
2019.12.02 20:01:22 INFO io.smallrye.openapi.api.OpenApiDocument Thread[main,5,main]: OpenAPI document initialized: io.smallrye.openapi.api.models.OpenAPIImpl@7793ad58
2019.12.02 20:01:23 INFO io.helidon.webserver.NettyWebServer Thread[main,5,main]: Version: 1.4.0
2019.12.02 20:01:24 INFO io.helidon.webserver.NettyWebServer Thread[nioEventLoopGroup-2-1,10,main]: Channel '@default' started: [id: 0x4e1f119b, L:/0:0:0:0:0:0:0:0:7200]
2019.12.02 20:01:24 INFO io.helidon.microprofile.server.ServerImpl Thread[nioEventLoopGroup-2-1,10,main]: Server initialized on http://localhost:7200 (and all other host addresses) in 5254 milliseconds.
答案

Brenno,

您没有显示更新的源代码,但是我假设您在快速入门@OpenAPIDefinition类中添加了GreetResource注释,对吗?

以上是关于Helidon MP OpenAPI不会生成更新的openapi端点响应的主要内容,如果未能解决你的问题,请参考以下文章

轻量简单!Oracle重磅开源 Java 微服务框架 Helidon

REST easy with kbmMW #20 – OpenAPI and Swagger UI

openapi3.0是手动这还是生成的

从 OpenAPI 规范生成 JSDoc

合约优先 OpenAPI 生成

springdoc-openapi 在没有服务器的情况下生成 openapi yaml