public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }
public ContextMetaBuilder addService(String alias, Class<?> serviceClass) { final ClassMeta<?> classMeta = ClassMeta.classMeta(serviceClass); String name = alias != null ? alias : getServiceName(classMeta); final List<String> requestPaths = getRequestPathsByAnnotated(classMeta, name); if (alias != null) { requestPaths.add(asPath(alias)); } final String description = getDescriptionFromRequestMapping(classMeta); final ServiceMetaBuilder serviceMetaBuilder = ServiceMetaBuilder.serviceMetaBuilder() .setRequestPaths(requestPaths).setName(name).setDescription(description) .setResponseHeaders(getResponseHeaders(classMeta)); serviceMetaBuilder.addMethods(this.getRootURI(), Lists.list(classMeta.methods())); addService(serviceMetaBuilder.build()); return this; }
@Before public void setUp() throws Exception { contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( SampleService.class); provider = new StandardMetaDataProvider(contextMetaBuilder.build(), RequestMethod.GET); }
contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(SampleService.class);
@Test public void testBuild() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(service("myService", "/myservice", method( "hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) ) )); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod(method("hello", getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ) )) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Test public void testBuildNestedBuilder2() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint(getRequest( "/callme/", stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) )).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
@Before public void setUp() throws Exception { contextMetaBuilder = ContextMetaBuilder.contextMetaBuilder(); contextMetaBuilder.setContactEmail("rick@rick.com"); contextMetaBuilder.setContactName("Rick Hightower"); contextMetaBuilder.setContactURL("https://github.com/advantageous/qbit"); contextMetaBuilder.setHostAddress("localhost:9090"); contextMetaBuilder.setDescription("Test set of services"); contextMetaBuilder.setLicenseName("APACHE 2"); contextMetaBuilder.setLicenseURL("https://github.com/advantageous/qbit/blob/master/License"); metaToSwagger = new MetaTransformerFromQbitMetaToSwagger(); contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService(SampleService.class); final ContextMeta context = contextMetaBuilder.build(); final ServiceEndpointInfo serviceEndpointInfo = metaToSwagger.serviceEndpointInfo(context); JsonSerializer jsonSerializer = new JsonSerializerFactory().setUseAnnotations(true).create(); System.out.println(jsonSerializer.serialize(serviceEndpointInfo)); }
@Test public void testBuildNestedBuilder3() throws Exception { contextMetaBuilder.setRootURI(contextMetaBuilder.getRootURI() + "Engine"); contextMetaBuilder.addService( serviceMetaBuilder() .setName("myService") .addRequestPath("/myservice") .addMethod( serviceMethodMetaBuilder().setName("hello") .addRequestEndpoint( requestMetaBuilder().setRequestURI("/callme/").addParameters( stringParam( headParam("foobarHeader") ), intParam( requestParam("helloMom") ), doubleParam( pathParam("score", 9) ) ).build() ).build() ) .build()); contextMetaBuilder.setServices(contextMetaBuilder.getServices()); ContextMeta context = contextMetaBuilder.build(); assertEquals("hello", context.getServices().get(0).getMethods().get(0).getName()); assertEquals("/callme/", context.getServices() .get(0).getMethods().get(0).getRequestEndpoints().get(0).getRequestURI()); }
public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }
public ContextMeta build() { return new ContextMeta(getTitle(), getRootURI(), getServices(), getDescription(), getContactName(), getContactURL(), getContactEmail(), getLicenseName(), getLicenseURL(), getVersion(), getHostAddress()); }
public ContextMetaBuilder addService(String alias, Class<?> serviceClass) { final ClassMeta<?> classMeta = ClassMeta.classMeta(serviceClass); String name = alias != null ? alias : getServiceName(classMeta); final List<String> requestPaths = getRequestPathsByAnnotated(classMeta, name); if (alias != null) { requestPaths.add(asPath(alias)); } final String description = getDescriptionFromRequestMapping(classMeta); final ServiceMetaBuilder serviceMetaBuilder = ServiceMetaBuilder.serviceMetaBuilder() .setRequestPaths(requestPaths).setName(name).setDescription(description) .setResponseHeaders(getResponseHeaders(classMeta)); serviceMetaBuilder.addMethods(this.getRootURI(), Lists.list(classMeta.methods())); addService(serviceMetaBuilder.build()); return this; }
public ContextMetaBuilder addService(final Class<?> serviceClass) { final ClassMeta<?> classMeta = ClassMeta.classMeta(serviceClass); String name = getServiceName(classMeta); final List<String> requestPaths = getRequestPathsByAnnotated(classMeta, name); final String description = getDescriptionFromRequestMapping(classMeta); final ServiceMetaBuilder serviceMetaBuilder = ServiceMetaBuilder.serviceMetaBuilder() .setRequestPaths(requestPaths).setName(name).setDescription(description) .setResponseHeaders(getResponseHeaders(classMeta)); serviceMetaBuilder.addMethods(this.getRootURI(), Lists.list(classMeta.methods())); addService(serviceMetaBuilder.build()); return this; }