如何在WildFly 18+中访问OpenApi端点?

我对microProfile OpenApi注释很感兴趣。当我在Payara或OpenLiberty上运行它时,可以按照规范中的说明在http://localhost:8080/openapi上访问OpenApi文档。

即使它声称支持MP OpenApi,也不适用于WildFly 18或19 Beta 1。我想TCK会检查一下,所以也许我做错了。

yingjianfeng09 回答:如何在WildFly 18+中访问OpenApi端点?

似乎WildFly 19 Beta 1中添加了OpenAPI支持。不幸的是,wildfly.org页面上的当前文档适用于WildFly 18,并且不包括用于包含OpenAPI的管理指南。

尽管如此,您仍然可以找到.adoc文件来支持OpenAPI on GitHub。根据此文件的历史记录,它是在2019年12月添加的(这也许就是为什么我还没有进入主页文档的原因)。

OpenAPI的当前文档声称是默认standalone-microprofile.xml配置的一部分,并且该文档可在http://localhost:8080获得。

如果不使用此配置运行,则可以使用以下命令(我已经在WildFly 19 Beta 1中进行了测试)启用OpenAPI子系统:

➜  bin ./jboss-cli.sh 
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone@localhost:9990 /] /extension=org.wildfly.extension.microprofile.openapi-smallrye:add()
{"outcome" => "success"}

[standalone@localhost:9990 /] /subsystem=microprofile-openapi-smallrye:add()
{
    "outcome" => "success","response-headers" => {
        "operation-requires-reload" => true,"process-state" => "reload-required"
    }
}

[standalone@localhost:9990 /] 

请注意:如果您随后尝试在浏览器中的http://localhost:8080/openapi上访问它,则可能会收到406-不可接受。只需请求它正确的内容类型或使用cURL

curl -v http://localhost:8080/openapi // YAML output
curl -v http://localhost:8080/openapi?format=JSON  // JSON output
本文链接:https://www.f2er.com/2720525.html

大家都在问