Skip to content

springdoc.swagger-ui.url not working as expected #2225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
crazycatMyopic opened this issue May 1, 2023 · 16 comments
Closed

springdoc.swagger-ui.url not working as expected #2225

crazycatMyopic opened this issue May 1, 2023 · 16 comments
Labels
question Further information is requested

Comments

@crazycatMyopic
Copy link

based on this url I should be able to use a custom json file (with the Open 3 specification) but i'm unable to, my code keeps giving me 404 not found. The path placed is correct btw.

why is this feature not working?

@moravcik94
Copy link

Hello,
I have same problem,
temporary workaround is to add dependency:

<dependency>
	<groupId>org.webjars</groupId>
	<artifactId>webjars-locator</artifactId>
	<version>0.45</version>
</dependency>

More here: #2204

@uc4w6c
Copy link
Collaborator

uc4w6c commented May 4, 2023

Your issue is not reproducible.
Please provide a minimal reproducible example that reproduces the problem.

I think that the files placed in resources are probably set to not be published.
For example, it will be private if spring.web.resources.add-mappings is set to false.

@destebanm
Copy link

Hi!
I have the same issue with

<dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
      <version>2.1.0</version>
</dependency>

http://localhost:8080/v3/api-docs OK
http://localhost:8080/swagger-ui.html KO 404

I have tried @moravcik94 workaround but it is not working in my case.

Any advice?

Thanks!

@youtae
Copy link

youtae commented May 15, 2023

I have the same issue in 2.1.0.

now, I solved this issue like this

I added this to my property file

springdoc.packagesToScan=your.package

@elgleidson
Copy link

elgleidson commented May 17, 2023

I have similar issue, but with webflux and I'm not using the url property (I have no property at all apart from the @youtae suggestion but even with that it's not working):

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>3.0.6</version>
   <relativePath/> <!-- lookup parent from repository -->
</parent>

My dependencies:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
...
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webflux-api</artifactId>
    <version>2.1.0</version>
</dependency>

http://localhost:8080/v3/api-docs -> OK
http://localhost:8080/swagger-ui.html -> 404
http://localhost:8080/swagger-ui/index.html -> 404
http://localhost:8080/webjars/swagger-ui/index.html -> 404

I've tried @moravcik94 workaround dependency + @youtae property but it is not working in my case.

@elgleidson
Copy link

Previously it was working fine:

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.7.11</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

Dependencies:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-webflux-ui</artifactId>
    <version>1.7.0</version>
</dependency>

http://localhost:8080/v3/api-docs -> OK
http://localhost:8080/swagger-ui.html -> OK
http://localhost:8080/webjars/swagger-ui/index.html -> OK

@elgleidson
Copy link

elgleidson commented May 17, 2023

I've created a reproducible example: https://github.com/elgleidson/springdoc-webflux-issue

@elgleidson
Copy link

elgleidson commented May 18, 2023

Sorry guys, I must have copied the dependency wrong 🙈
Wrong:

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webflux-api</artifactId>
    <version>2.1.0</version>
</dependency>

Correct:

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

It's working with the right dependency.

@crazycatMyopic
Copy link
Author

crazycatMyopic commented May 30, 2023

Your issue is not reproducible. Please provide a minimal reproducible example that reproduces the problem.

I think that the files placed in resources are probably set to not be published. For example, it will be private if spring.web.resources.add-mappings is set to false.

@uc4w6c find the minimum reproducible code here https://github.com/crazycatMyopic/issue_2/tree/main
as stated it is not considering my custom json but rather the default generated one

@uc4w6c
Copy link
Collaborator

uc4w6c commented May 31, 2023

@crazycatMyopic
Thank you.
Please access http://localhost:9090/test/webjars/swagger-ui/index.html

スクリーンショット 2023-05-31 21 32 14

@crazycatMyopic
Copy link
Author

crazycatMyopic commented May 31, 2023

@uc4w6c i'm not sure what changes we both might have made, cause for me it's still giving the old one, it is not taking the custom json

Screenshot 2023-05-31 223331

@uc4w6c
Copy link
Collaborator

uc4w6c commented May 31, 2023

@crazycatMyopic
Did you remove the comment below?
#springdoc.swagger-ui.url=/apidocs.json

@bnasslahsen bnasslahsen added the question Further information is requested label Jun 3, 2023
@GodayMax
Copy link

GodayMax commented Jun 7, 2023

same issue
2023-06-08T02:13:49.969+08:00 WARN 25172 --- [nio-8000-exec-6] o.s.web.servlet.PageNotFound : No mapping for GET /swagger-ui/index.html

@uc4w6c
Copy link
Collaborator

uc4w6c commented Jun 8, 2023

displayed using the minimum reproducible code created by the creator of this issue (@crazycatMyopic), so I will close it.
If it still doesn't work, you can open it again.

What other people are commenting on may be different.
Please prepare a separate issue with minimum reproducible code.
or for any question post it on stackoverflow

@uc4w6c uc4w6c closed this as completed Jun 8, 2023
@crazycatMyopic
Copy link
Author

@uc4w6c sorry for late reply's, this is my current properties

server.port=9090
spring.webflux.base-path=/test

#Open Api 3.0
#springdoc.swagger-ui.config-url=/v3/apidocs.json
springdoc.swagger-ui.url=/apidocs.json
#springdoc.swagger-ui.path=/apiDocuments
spring.web.resources.add-mappings=false

I'm still facing the issue, can you please let me know if this is correct?

@crazycatMyopic
Copy link
Author

crazycatMyopic commented Jun 10, 2023

@uc4w6c also i'm unable to reopen the issue, please re open it It's working fine now, please ignore the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

8 participants