-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Swagger 2 integration #1508
Comments
Is SpringFox the new name of Swagger Spring MVC, which we are using? |
Yes, springfox is the new name of swagger spring mvc for version 2.0. |
Just trying to migrate my jhipster app to SpingFox 2.0.1: the API has completely changed! |
Let me know if you need help with this. Swagger core Api is changing as well (package names are moving to The memory footprint is orders of magnitude smaller (no more scala related bloat). There are no more dependencies on Also I might add that, we have a really simple way to pull in the swagger-ui as a resource jar. |
Thanks @dilipkrish with the examples, I was able to make it work. I noted that URLs are different from jhipster had: http://localhost:8080/v2/api-docs for the JSON description http://localhost:8080/swagger-ui.html for the UI |
I have to do some cleanup and then I'll submit a PR |
Here is a commit showing changes required on jhipster sample app. |
@dilipkrish the swagger ui webjar is marked as WIP in your docs. Do you think it is safe to use in jhipster or is it preferable to stay for now with the bower version ? |
@cbornet we haven't updated the readme for the module since 2.0.0-SNAPSHOT 😮 thanks for pointing that out! Here is the official documentation. I'll make a note to fix that! We've had couple of fixes since and I'd like to think its stable as of 2.0.2-SNAPSHOT. Also there other reason for not advertising it as stable is because up until today the web jar was built on a prerelease swagger-ui library. We should be releasing 2.0.2 that pretty soon with the latest swagger-ui (2.1.0) and latest swagger-core (1.5.0 note: that that they changed the package names from |
I my commit, you'll note that I have removed the bower dependency on swagger-ui |
@dilipkrish in dev on localhost:8081, I am getting CORS message "Can't read from server. It may not have the appropriate access-control-origin settings." at the top of the page. I found this issue springfox/springfox#77 but it is for old version and I could not find what is done to workaround this in recent demos. |
@gmarziou Since the webapp and the API are on the same domain this is probably a problem different than CORS hell. |
@gmarziou Is that happening when you actually hit the "try out" button? |
It's happening from the beginning and I get this in the browser's console:
This triggers another error at swagger-ui.html:51
|
@gmarziou that would make sense that you have a CORS issue there, since it reaches out to |
@gmarziou could you create an issue for that! that is definitely not desirable! 😬 |
Here it is springfox/springfox#781 |
Just released 2.0.2 and also polished up the swagger-ui integration. Thanks for your feedback @gmarziou! |
Great, I will update my jhipster sample project and if it's OK for jhipster team, I will propose a PR including migration to SpringFox and static doc generation. |
Here is a commit for sample webapp generated by jhipster 2.16.1 that shows the required changes. It brings:
Static doc generation currently works with maven only but could be easily adapted to gradle as explained here |
If you prefer I could create 2 PRs: one for the springfox migration and one the static doc generation. I'd be curious to know whether people really uses swagger web UI in prod profile, in my projects I enable it only in dev profile and if someone asked for it, I would give the static doc in PDF or HTML. |
@gmarziou this is the next issue I'll have a look at, hopefully tonight. |
OK, I'll wait for your feedback before working on the PR |
I mean I can submit a PR just for migrating to spingfox and then we can work on next steps |
@gmarziou yes please do the SpringFox PR first, it looks like we have a lot of issues with Swagger at the moment |
@dilipkrish : about performance, I was wondering whether we could initialise SpringFox on-demand rather than on application startup. So the price for introspection would be paid only on first request to /v2/api-docs URL. |
That's definitely next on the cards ... And caching of operations, parameters, return types and models. |
Great, keep up the good work 👍 |
👍 for introspection on first request. |
Fixed by #1635 |
Since springfox-swagger2 v2.0.0 got released, it would be great to use it to have a swagger 2.0 api-docs running in parallel of the swagger 1.2 version as it provides a lot more functionalities (for instance support of map objects).
Note : Swagger UI v2.1 will support 2.0 spec and could be used in the future for the on-line doc.
The text was updated successfully, but these errors were encountered: