Resource Path vs API path

1,504 views
Skip to first unread message

Sahar

unread,
Jul 25, 2013, 4:34:27 PM7/25/13
to swagger-sw...@googlegroups.com
Hi Tony, 

I have started using the new version of the swagger and everything works fine; however, the resourcePath of the API should match the path of the API itself to make things work.  Look at the example below:

If these are the annotation for my ws:

@Path("/samplehub/sample")

@Api(value = "/fetch", description = "Fetch Sample Data")


then in the API declaration, I have:


apiVersion":"1.0.0","swaggerVersion":"1.2","basePath":"http://localhost:8080/samplehub_ws","resourcePath":"/fetch","produces":["application/json","application/xml"],"apis":[{"path":"/fetch/{id}"}

while the resourcePath should point to the API decl (/fetch) and the path in apis array should point to the api itself /samplehub/sample. Due to this issue, I have to use @Api(value="/samplehub/sample"). it would be nice to be able to separate these two especially when using Swagger UI, since it uses the "value" as the name of the API.  

Another issue is that Swagger UI, uses the name after the last "/" in the path as the name of the API. Being able to define a display name for APIs when listed in the Swagger UI would be great.

One last thing, is there a way to rename "api-docs" to "resources"? 

Thanks,
Sahar


tony tam

unread,
Jul 26, 2013, 12:17:37 AM7/26/13
to swagger-sw...@googlegroups.com
The api path in the Resource Listing is now relative--so if you have http://localhost:8080/samplehub_ws/resources as the Resource Listing, the api path of "/fetch" would be available under http://localhost:8080/samplehub_ws/resources/fetch

* We're looking at alternatives for naming the api itself
* To change the Resource Listing path, just make your own version of this:


package com.wordnik.swagger.jaxrs.listing

import com.wordnik.swagger.annotations._
import com.wordnik.swagger.jaxrs._

import javax.ws.rs._
import javax.ws.rs.core.MediaType

@Path("/api-docs")
@Api("/api-docs")
@Produces(Array(MediaType.APPLICATION_JSON))
class ApiListingResourceJSON extends ApiListingResource

with whatever path you like.  Just update your web.xml to point to your new listing class in the providers configuration.
Reply all
Reply to author
Forward
0 new messages