当前位置: 首页 > 知识库问答 >
问题:

如何使用springdoc-openapi-webflux-UI显示应用程序API文档?

裴理
2023-03-14

我阅读了https://springdoc.github.io/springdoc-openapi-demos/文档,以使用springdoc-openapi-webflux-UI。正如文档所说,我刚刚向我的应用程序添加了springdoc-openapi-webflux-ui库:实现('org.springdoc:springdoc-openapi-webflux-ui:1.2.26')

此外,我在application.yml中定制了API的路径:

springdoc:
  swagger-ui:
    path: /swagger-ui.html

当我启动应用程序并转到http://localhost:8080/swagger-ui.html时,它会将我重定向到http://localhost:8080/webjars/swagger-ui/index.html?configurl=/v3/api-docs/swagger-config。在那一页中,我得到了一个错误:

Whitelabel Error Page
This application has no configured error view, so you are seeing this as a fallback.
Mon Jan 20 05:16:10 UTC 2020
[7192d9dc] There was an unexpected error (type=Not Found, status=404).
No matching handler

问题是:我是否应该向我的应用程序添加额外的配置来显示API文档?

共有1个答案

益英逸
2023-03-14

默认情况下,您只需要添加springdoc-openapi-webflux-UI的依赖项。

 <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-webflux-ui</artifactId>
      <version>1.2.32</version>
   </dependency>

您可以查看演示代码

  • https://github.com/springdoc/springdoc-openapi-demos.git-
    null

正如Spring Boot参考文档中所述,当您使用@enableWebFlux时,您告诉Spring Boot您希望完全控制WebFlux配置,并为此禁用所有自动配置(包括静态资源):

  • https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-webflux-auto-configuration

您有两种解决方案:

    null

这里已经讨论过了:

  • https://github.com/springdoc/springdoc-openapi/issues/402
 类似资料:
  • 我有一个小型Spring Boot微服务,它使用webflux将其endpoint公开为反应式。 当我运行应用程序从IntelliJ,Gradle或从cmd行与SpringDoc网络流量支持: 和我去我得到一个500错误,日志显示: 根本原因是:

  • 是否可以使用接口而不是实现这些接口的控制器类来生成swagger ui文档? 将文档放在实现类中会使它看起来杂乱无章。Springfox有这个选项,它在springdoc中可用吗?如果是,怎么做?

  • 我正在使用版本为(1.2.32)的SpringDocOpenAPI。现在,我想在UI中按HTTP方法(反向顺序)对endpoint进行排序,并且我没有在endpoint方法上使用任何标记。 如果我有4个endpoint发布,获取,放置,删除,然后我想显示方法放置,发布,获取,删除 我尝试了以下方法,但似乎不起作用: springdoc.swagger-ui.operations排序器=(方法和al

  • 我有一个Spring Boot应用程序,其中API被指定为OpenAPI 3.0.2 YAML文档。我使用openapi生成器maven插件从规范生成代码http://localhost:8080/swagger-用户界面。html,它显示:“规范中未定义任何操作!” 在规范中,我有: 这导致控制器类中出现以下情况: 如果我加载openapi定义。编辑亚马尔。大摇大摆io,它显示了预期的定义。 如

  • 关于如何使用springdocs-openapi库(1.5.7)获得以下输出,网络上没有很好的示例。我希望得到以下输出: 这是基于提供的示例的代码。 这将产生以下输出 如何通过springdocs openapi库实现上面列出的输出[“A”、“B”、“C”]?

  • 我们最近从springfox迁移到springdoc openapi 3。其中一个API返回大约2MB的数据,它在springfox中正常工作,但是springdoc openapi用户界面在几分钟内没有响应,渲染也需要2分钟以上。有什么办法可以解决吗?