org.apache.cxf.jaxrs.swagger.Swagger2Feature Java Examples
The following examples show how to use
org.apache.cxf.jaxrs.swagger.Swagger2Feature.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestOrderApplication.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Override public Set<Object> getSingletons() { Swagger2Feature swagger = new Swagger2Feature(); swagger.setBasePath("/"); swagger.setHost("localhost:9000"); swagger.setTitle("Order Service"); swagger.setDescription("Rider Auto Parts Order Service"); swagger.setVersion("2.0.0"); swagger.setContact("[email protected]"); swagger.setPrettyPrint(true); Set<Object> answer = new HashSet<>(); answer.add(orderService); answer.add(new JacksonJsonProvider()); answer.add(swagger); // to turn on verbose logging answer.add(new LoggingFeature()); return answer; }
Example #2
Source File: Server.java From cxf with Apache License 2.0 | 6 votes |
protected Server() throws Exception { org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000); final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet()); final ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); context.addServlet(servletHolder, "/*"); servletHolder.setInitParameter("jaxrs.serviceClasses", Sample.class.getName()); servletHolder.setInitParameter("jaxrs.features", Swagger2Feature.class.getName()); servletHolder.setInitParameter("jaxrs.providers", StringUtils.join( new String[] { MultipartProvider.class.getName(), JacksonJsonProvider.class.getName(), ApiOriginFilter.class.getName() }, ",") ); server.setHandler(context); server.start(); server.join(); }
Example #3
Source File: Swagger2NonAnnotatedServiceDescriptionTest.java From cxf with Apache License 2.0 | 6 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); sf.setResourceClasses(BookStoreStylesheetsSwagger2.class); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = createSwagger2Feature(); //FIXME swagger-jaxrs 1.5.3 can't handle a self-recursive subresource like Book // so we need to exclude "org.apache.cxf.systest.jaxrs" for now. feature.setResourcePackage("org.apache.cxf.systest.jaxrs.description.group1"); feature.setScanAllResources(true); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.create(); }
Example #4
Source File: CxfConfig.java From coditori with Apache License 2.0 | 5 votes |
@Bean public Server rsServer() { final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setProvider(new JacksonJsonProvider()); endpoint.setProvider(getExceptionHandler()); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setServiceBeans(Arrays.<Object>asList(indexController(), userController())); endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); return endpoint.create(); }
Example #5
Source File: CxfConfig.java From coditori with Apache License 2.0 | 5 votes |
@Bean public Server rsServer() { final JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setProvider(new JacksonJsonProvider()); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setServiceBeans(Arrays.<Object>asList(userController())); endpoint.setFeatures(Arrays.asList(new Swagger2Feature())); return endpoint.create(); }
Example #6
Source File: AbstractSwagger2ServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceClasses(BookStoreStylesheetsSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = createSwagger2Feature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + port + "/"); sf.setExtensionMappings( Collections.singletonMap("json", "application/json;charset=UTF-8")); sf.create(); }
Example #7
Source File: AbstractSwagger2ServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
protected Swagger2Feature createSwagger2Feature() { final Swagger2Feature feature = new Swagger2Feature(); feature.setRunAsFilter(runAsFilter); feature.setContact(CONTACT); feature.setTitle(TITLE); feature.setDescription(DESCRIPTION); feature.setLicense(LICENSE); feature.setLicenseUrl(LICENSE_URL); feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME, new io.swagger.models.auth.BasicAuthDefinition())); return feature; }
Example #8
Source File: SwaggerUiConfigurationTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new JacksonJsonProvider()); final Swagger2Feature feature = new Swagger2Feature(); feature.setRunAsFilter(false); feature.setSwaggerUiConfig(new SwaggerUiConfig().url("/swagger.json")); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #9
Source File: Swagger2CustomPropertiesTest.java From cxf with Apache License 2.0 | 5 votes |
protected Swagger2Feature createSwagger2Feature() { final Swagger2Feature feature = new Swagger2Feature(); feature.setRunAsFilter(runAsFilter); feature.setPropertiesLocation("/files/swagger.properties"); feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME, new io.swagger.models.auth.BasicAuthDefinition())); return feature; }
Example #10
Source File: SwaggerToOpenApiConversionTest.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void run() { final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStoreSwagger2.class); sf.setResourceProvider(BookStoreSwagger2.class, new SingletonResourceProvider(new BookStoreSwagger2())); sf.setProvider(new SwaggerToOpenApiConversionFilter()); final Swagger2Feature feature = createSwagger2Feature(); sf.setFeatures(Arrays.asList(feature)); sf.setAddress("http://localhost:" + PORT + "/"); sf.create(); }
Example #11
Source File: SwaggerToOpenApiConversionTest.java From cxf with Apache License 2.0 | 5 votes |
protected Swagger2Feature createSwagger2Feature() { final Swagger2Feature feature = new Swagger2Feature(); feature.setContact(CONTACT); feature.setTitle(TITLE); feature.setDescription(DESCRIPTION); feature.setLicense(LICENSE); feature.setLicenseUrl(LICENSE_URL); feature.setSecurityDefinitions(Collections.singletonMap(SECURITY_DEFINITION_NAME, new io.swagger.models.auth.BasicAuthDefinition())); return feature; }
Example #12
Source File: WebServicesConfiguration.java From microservices-transactions-tcc with Apache License 2.0 | 4 votes |
@Bean public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(bus); endpoint.setAddress("/"); endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new ExceptionRestHandler())); Map<Object, Object> mappings = new HashMap<Object, Object>(); mappings.put("json", "application/json"); endpoint.setExtensionMappings(mappings); Swagger2Feature swagger2Feature = new Swagger2Feature(); swagger2Feature.setTitle(title); swagger2Feature.setDescription(description); swagger2Feature.setVersion(version); swagger2Feature.setContact(contact); swagger2Feature.setSchemes(schemes.split(",")); swagger2Feature.setBasePath(basePath); swagger2Feature.setResourcePackage(resourcePackage); swagger2Feature.setPrettyPrint(prettyPrint); swagger2Feature.setScan(scan); endpoint.setFeatures(Arrays.asList(new LoggingFeature(), swagger2Feature)); endpoint.setServiceBeans(Arrays.asList(tccCoordinatorService, compositeController)); return endpoint.create(); }