springdoc-openui Swagger URL 默认为 petstore API,而不是禁用。

huangapple go评论52阅读模式
英文:

springdoc-openui swagger url default to petstore api and not disabling

问题

我正在使用 springdoc-openapi-starter-webmvc-ui 依赖和 spring boot 版本为 3.0.2,使用 JDK 17,但是当我访问 http://localhost:8080/swagger-ui/index.html 时,显示的是默认的 petstore API,而不是我的应用程序 API。

以下是我正在使用的依赖项:

<dependency>
   <groupId>org.springdoc</groupId>
   <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
   <version>2.0.2</version>
   <exclusions>
       <exclusion>
           <artifactId>org.webjars</artifactId>
           <groupId>swagger-ui</groupId>
       </exclusion>
   </exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars/swagger-ui -->
<dependency>
   <groupId>org.webjars</groupId>
   <artifactId>swagger-ui</artifactId>
   <version>4.8.1</version>
</dependency>

还有在 application.yaml 中的配置:

springdoc:
  swagger-ui:
    path: '/swagger-ui.html'
    disable-swagger-default-url: true

但似乎在这种情况下 disable-swagger-default-url 不起作用。请告诉我如何摆脱这个默认的 petstore API 并能够访问我的应用程序 API。

英文:

I am using springdoc-openapi-starter-webmvc-ui dependency and spring boot version is 3.0.2 with JDK 17 but when I am hitting http://localhost:8080/swagger-ui/index.html its showing default petstore API not my application API..

Below are the dependencies which I am using :

&lt;dependency&gt;
   		&lt;groupId&gt;org.springdoc&lt;/groupId&gt;
   		&lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;
   		&lt;version&gt;2.0.2&lt;/version&gt;
   		&lt;exclusions&gt;
   			&lt;exclusion&gt;
   				&lt;artifactId&gt;org.webjars&lt;/artifactId&gt;
   				&lt;groupId&gt;swagger-ui&lt;/groupId&gt;
   			&lt;/exclusion&gt;
   		&lt;/exclusions&gt;
   	&lt;/dependency&gt;
   	&lt;!-- https://mvnrepository.com/artifact/org.webjars/swagger-ui --&gt;
   	&lt;dependency&gt;
   		&lt;groupId&gt;org.webjars&lt;/groupId&gt;
   		&lt;artifactId&gt;swagger-ui&lt;/artifactId&gt;
   		&lt;version&gt;4.8.1&lt;/version&gt;
   	&lt;/dependency&gt;

and in application.yaml

springdoc:
  swagger-ui:
    path: &#39;/swagger-ui.html&#39;
    disable-swagger-default-url: true

but it seems disable-swagger-default-url is not working in this case. Please let me know how can I get rid of this default petstore api and able to hit my application api.

答案1

得分: 1

yaml文件中的配置是正确的,也许你应该将springdoc-openapi-starter-webmvc-ui的版本升级到2.1.0,然后可以从pom文件中删除有关swagger-ui依赖的相关配置。希望这有所帮助。

英文:

The configuration in yaml file is correct, maybe you should upgrade the version of springdoc-openapi-starter-webmvc-ui to 2.1.0, and you can remove the related configuration about swagger-ui dependency from the pom. Hope this helps.

huangapple
  • 本文由 发表于 2023年2月14日 00:50:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75438880.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定