rest - How to get swagger json separately? -
i try generate swagger.json java rest endpoints.
pom
<dependency> <groupid>io.swagger</groupid> <artifactid>swagger-jaxrs</artifactid> <version>1.5.9</version> </dependency>
applicationpath
import javax.ws.rs.applicationpath; @applicationpath("/rest") public class restapplication extends application { public restapplication() { beanconfig beanconfig = new beanconfig(); //beanconfig.setversion("1.0"); beanconfig.setschemes(new string[] { "http" }); beanconfig.settitle("my api"); beanconfig.setbasepath("/rest"); beanconfig.setresourcepackage("com.test.rest"); beanconfig.setscan(true); } @override public set<class<?>> getclasses() { hashset<class<?>> set = new hashset<class<?>>(); set.add(com.test.addressendpoint.class); set.add(com.test.atgendpoint.class); set.add(com.test.companyendpoint.class) set.add(io.swagger.jaxrs.listing.apilistingresource.class); set.add(io.swagger.jaxrs.listing.swaggerserializers.class); return set; } }
addressendpoint
@api @singleton @path("/addresss") @produces("application/json") @concurrencymanagement @lock(locktype.read) public class addressendpoint { private static final logger log = logger.getlogger(addressendpoint.class.getname()); @context private httprequest httprequest; @inject addressservice addressservice; /** * @description creates new address * @status 400 address country cannot null * @status 400 address address2 cannot null * @status 400 address city cannot null * @status 400 address address1 cannot null * @status 400 address postcode cannot null * @status 400 address id cannot null * @status 400 address state cannot null * @status 201 address created */ @post @consumes("application/json") public response create(address entity) { addressservice.insert(entity); return response.created(uribuilder.fromresource(addressendpoint.class).path(string.valueof(entity.getid())).build()).build(); }
...
when deploy testdbwar in wildfly, try access json like; http://localhost:8080/testdbwar/rest/swagger.json?
and big json contains jsons .
- how can json separately each endpoint?
- can them generated locally in file system?
- the big json file loads ui @ once. have separate links each endpoint type.
- generally swagger library,
all_resource_listing_url/pathname
. when googled jax-rs, this 1 found related problem though wordnik.swagger library. in case, shouldhttp://localhost:8080/testdbwar/rest/swagger.json/addresss
apis listed under path'addresss'
. don't know, whether misspelled 'addresss' 'sss' , tried 'ss' already. , please try lower-case path name. - i don't think there's automated way swagger configuration itself. can manually small-code right? anyway looks like, kind of support available there commercial tools ibm.
- a solution q1 applicable 1 too, right? inside swagger-ui, can invoke swagger doc urls differently each different paths.
Comments
Post a Comment