We use swagger in spring project to generate documentation. I have task to generate documentation for production version which doesn't yet use swagger. So i injected the dependency, copied the configuration files and the swagger controller from the develop version. When i start the project (production version with no documentation yet) and open the swagger-ui i get all the data from the develop version. If i change swagger mapping path to something different example :
Original "/api/.*"
, New "/api2/.*"
.
I get clean page with no documentation, to check if it's working properly i added few annotations and everything works. So i suppose that swagger save some files on my computer but i cannot find them. This is my first time dealing with swagger so if i'm wrong correct me. Any help will be appreciated. Thanks in advance.
Asked
Active
Viewed 1,089 times
1

Ivaylo Hristov
- 43
- 8
-
You say you generate the documentation. Is this done using the swagger annotations in your code, if so is the code in production annotated already? If yes then it is not strange that swagger generates the documentation on production based on the annotation in the code. – Gerben Jongerius Aug 07 '19 at 10:34
-
No production version doesn't use swagger. My job is to create some documentation for the clients before we release the next version which will have full documentation. – Ivaylo Hristov Aug 07 '19 at 10:36
-
Then how did you 'inject' the swagger dependencies. And are you using springfox swagger or regular swagger. If you use the latter it could be that you copied the generated swagger.json file containing the documentation to the production version? – Gerben Jongerius Aug 07 '19 at 10:44
-
I put them in the grandle file. We use springfox swagger. Where can i find the json file ? – Ivaylo Hristov Aug 07 '19 at 10:47
-
Possibly related: [How to export a Swagger JSON/YAML file from Swagger UI?](https://stackoverflow.com/q/48525546/113116) – Helen Aug 07 '19 at 11:53
-
1Springfox swagger scans annotation of Spring MVC to generate documentation (the swagger.json file). So if swagger springfox is configured in your production code base (not just the dependency) then the documentation will be generated automatically. – Gerben Jongerius Aug 07 '19 at 12:52
-
1Interesting question ... and welcome to upvote levels ... which will allow you to show your appreciation in even more ways ;-) – GhostCat Nov 15 '19 at 10:11
1 Answers
1
Swagger won't save any files to your computer. The information you add by annotating your endpoints is used to generate the swagger file (usually YAML or JSON format).
Swagger-UI simply downloads the generated file and visualizes this information.
You can of course download the file yourself (URL that you point swagger-ui to), modify any dev-specific paths in there and upload this static file to your prod server. Of course this might not reflect the correct prod endpoints if there are differences between prod and dev.

dpr
- 10,591
- 3
- 41
- 71
-
I test the project on localhost. Still there might be some configuration that connects to dev. I will look up on that. Thanks. – Ivaylo Hristov Aug 07 '19 at 10:44