5

Java プロジェクトの pom ファイルで次のアーティファクトを使用して、swagger-ui をインストールしました。

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

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-security</artifactId>
      <version>1.5.2</version>
   </dependency>

この URL にアクセスすると、RESTful エンドポイントの Swagger UI を表示できます

http://localhost:8081/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config

しかし、このリンクではありません

http://localhost:8081/swagger-ui/index.html

どうしてこれなの?期待される URL に戻すにはどうすればよいですか?

4

2 に答える 2

4

ペット ストアのデフォルトの swagger をロードするhttp://localhost:8081/swagger-ui.html代わりに、swagger ui にアクセスする必要があります。http://localhost:8081/swagger-ui/index.htmlで回避策を確認できます

https://github.com/springdoc/springdoc-openapi/issues/43

URLhttp://localhost:8081/swagger-ui.htmlは常に にリダイレクトされ http://localhost:8081/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-configます。

application.properties で次のようにカスタマイズできます

springdoc.api-docs.path=/api-docs 
springdoc.swagger-ui.path=/swagger-ui-custom.html

これで、URLhttp://localhost:8081/swagger-ui-custom.htmlが にリダイレクトされ http://localhost:8081/swagger-ui/index.html?configUrl=/api-docs/swagger-configます。

于 2021-01-21T06:35:08.927 に答える