Comments (7)
This may have been addressed by #48. Can you test with a recent version?
from play-swagger.
Would it be possible to verify this fix and publish a new version? The latest published release is definitely still impacted the issue (using Play 2.5).
from play-swagger.
Currently the generate
method takes a string of the routes file and reads it as a resource from the classpath. You should be able to call it with generate("api.routes")
. However, I think we could improve this interface by having another method that takes an implicit application and looks up the value of play.http.router
from the application's configuration. This is likely the most common usage. @kailuowang thoughts?
from play-swagger.
@joprice let's see if @pettyjamesm will be okay with the new generate interface (you can read the root routes file name yourself). I would hesitate adding play application as an dependency.
from play-swagger.
@joprice I'm not sure exactly how that would work. Are you saying that by default it would parse the whole routing tree?
Hooking to the root application router is definitely useful for determining the accurate HTTP paths, but I wouldn't necessarily assume that all routes should be mapped. For instance, my root routes file looks like this:
# Misc Non-API routes that serve dashboards, etc
GET / @controllers.HomeController.index
.... more of these omitted ...
# API docs
GET /docs @controllers.ApiDocController.redirectToDocs
GET /docs/swagger.json @controllers.ApiDocController.fullSpecs
GET /docs/swagger-ui/index.html @controllers.ApiDocController.swaggerHome
GET /docs/swagger-ui/*file @controllers.ApiDocController.swaggerResource(file)
# API resources
-> /api/v1/charge charge.Routes
-> /api/v1/cart cart.Routes
-> /api/v1/inventory inventory.Routes
-> /api/v1/purchase purchase.Routes
Currently I've made the /docs/swagger.json route call into generate once per sub-route and then I manually merge the generated JSON together and fix the http paths. It kinda works, but it's definitely kludgy. Is that helpful?
from play-swagger.
@pettyjamesm , yes by default it will recursively parse the whole tree.
For now, there are two work around in your case
- add
### NoDocs ###
to all the routes you don't want to include.
or 2) have an api.routes file in which you can have
-> /v1/charge charge.Routes
-> /v1/cart cart.Routes
-> /v1/inventory inventory.Routes
-> /v1/purchase purchase.Routes
And have do generate("api.routes")
and then add a root path /api
to your swagger.yml file.
from play-swagger.
@joprice The 2nd workaround is totally fine with me. I just wanted I way to isolate the API resources from the other routes.
Given that my preferred approach is going to be the second option, I think you can proceed with whatever you'd like for the application router traversal.
from play-swagger.
Related Issues (20)
- Request parameters not visible in Swagger ui
- Open API spec generated is incorrect
- Swagger generating type zoneddatetime in the swagger json
- Support for Optional in schemas
- Swagger Custom Mappings not working with multiples parameters HOT 1
- array[byte] transforms to array-byte .Must transform string
- Swagger-ui compatibility HOT 4
- How to request a release? HOT 2
- Which PLAY versions must be supported? HOT 2
- Please release 0.11.0 HOT 2
- Allow passing classloader to DefinitionGenerator HOT 1
- Definitions description based on Scaladoc HOT 2
- Please Release 0.13.0
- Reusable enums are not working HOT 1
- Skip routes w/ no Swagger Spec comment HOT 1
- java.util.zip.ZipException: duplicate entry: public/swagger.json HOT 1
- Support Scala 3 HOT 2
- Wildcard matching for `swaggerDomainNameSpaces` HOT 1
- [Urgent] Deployment Failures of This Repository Since April. HOT 4
- Remove Swagger Json from Public Folder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from play-swagger.