io.swagger.jaxrs.listing.SwaggerSerializers Java Examples
The following examples show how to use
io.swagger.jaxrs.listing.SwaggerSerializers.
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: MainApplication.java From SciGraph with Apache License 2.0 | 6 votes |
/*** * The context path must be set before configuring swagger * @param environment */ void configureSwagger(Environment environment, String basePath) { environment.jersey().register(new ApiListingResource()); environment.jersey().register(new SwaggerJsonBareService()); environment.jersey().register(new SwaggerSerializers()); ScannerFactory.setScanner(new DefaultJaxrsScanner()); environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); BeanConfig config = new BeanConfig(); // api specific configuration config.setTitle("SciGraph"); config.setVersion("1.0.1"); config.setResourcePackage("io.scigraph.services.resources"); config.setScan(true); // TODO: Fix this so the swagger client generator can work correctly config.setBasePath("/" + basePath); }
Example #2
Source File: BaseApplicaionConfig.java From azeroth with Apache License 2.0 | 6 votes |
public BaseApplicaionConfig() { //设置默认时区 System.setProperty("user.timezone", "Asia/Shanghai"); register(ValidationContextResolver.class); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); this.packages(packages()); register(ObjectMapperResolver.class); register(JacksonFeature.class); register(JacksonJsonProvider.class); register(new BaseExceptionMapper(createExcetionWrapper())); register(RequestContextFilter.class); register(DefaultWebFilter.class); if (FilterConfig.apiDocEnabled()) { register(SwaggerSerializers.class); } }
Example #3
Source File: WebServicesConfiguration.java From microservices-transactions-tcc with Apache License 2.0 | 6 votes |
private void configureSwagger() { // Available at localhost:port/swagger.json this.register(ApiListingResource.class); this.register(SwaggerSerializers.class); BeanConfig config = new BeanConfig(); // config.setConfigId(title); config.setTitle(title); config.setDescription(description); config.setVersion(version); config.setContact(contact); config.setSchemes(schemes.split(",")); config.setBasePath(basePath); config.setResourcePackage(resourcePackage); config.setPrettyPrint(prettyPrint); config.setScan(scan); }
Example #4
Source File: WebServicesConfiguration.java From microservices-transactions-tcc with Apache License 2.0 | 6 votes |
private void configureSwagger() { // Available at localhost:port/swagger.json this.register(ApiListingResource.class); this.register(SwaggerSerializers.class); BeanConfig config = new BeanConfig(); // config.setConfigId(title); config.setTitle(title); config.setDescription(description); config.setVersion(version); config.setContact(contact); config.setSchemes(schemes.split(",")); config.setBasePath(basePath); config.setResourcePackage(resourcePackage); config.setPrettyPrint(prettyPrint); config.setScan(scan); }
Example #5
Source File: BaseApplicaionConfig.java From jeesuite-libs with Apache License 2.0 | 6 votes |
public BaseApplicaionConfig() { //设置默认时区 System.setProperty("user.timezone","Asia/Shanghai"); register(ValidationContextResolver.class); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true); this.packages(packages()); register(ObjectMapperResolver.class); register(JacksonFeature.class); register(JacksonJsonProvider.class); register(new BaseExceptionMapper(createExcetionWrapper())); register(RequestContextFilter.class); register(DefaultWebFilter.class); // if(FilterConfig.apiDocEnabled()){ register(SwaggerSerializers.class); } }
Example #6
Source File: SwaggerModule.java From act-platform with ISC License | 5 votes |
@Override protected void configure() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setBasePath("/"); beanConfig.setResourcePackage(API_PACKAGE); beanConfig.setScan(true); SwaggerModelTransformer transformer = SwaggerModelTransformer.builder() .addTransformation(new ResultContainerTransformation(ResultStash.class, "data")) .build(); bind(SwaggerApiListingResource.class).in(Scopes.SINGLETON); bind(SwaggerSerializers.class).in(Scopes.SINGLETON); bind(SwaggerModelTransformer.class).toInstance(transformer); }
Example #7
Source File: SwaggerSpecResource.java From Cheddar with Apache License 2.0 | 5 votes |
protected synchronized Swagger scanResourcesForJaxrsAnnotations(final Application app, final ServletConfig sc) { Swagger swagger = null; final Scanner scanner = ScannerFactory.getScanner(); LOGGER.debug("using scanner " + scanner); if (scanner != null) { SwaggerSerializers.setPrettyPrint(scanner.getPrettyPrint()); swagger = getSwagger(); Set<Class<?>> classes = null; if (scanner instanceof JaxrsScanner) { final JaxrsScanner jaxrsScanner = (JaxrsScanner) scanner; classes = jaxrsScanner.classesFromContext(app, sc); } else { classes = scanner.classes(); } if (classes != null) { final Reader reader = new Reader(swagger); swagger = reader.read(classes); if (scanner instanceof SwaggerConfig) { swagger = ((SwaggerConfig) scanner).configure(swagger); } else { LOGGER.debug("no configurator"); } } } initialized = true; return swagger; }
Example #8
Source File: ServerModule.java From digdag with Apache License 2.0 | 5 votes |
protected void enableSwagger(ApplicationBindingBuilder builder) { BeanConfig beanConfig = new BeanConfig(); beanConfig.setTitle("Digdag"); beanConfig.setDescription("Digdag server API"); beanConfig.setVersion(DigdagVersion.buildVersion().toString()); beanConfig.setResourcePackage(VersionResource.class.getPackage().getName()); beanConfig.setScan(); builder.addProvider(SwaggerSerializers.class) .addProvider(CorsFilter.class) .addResources(SwaggerApiListingResource.class); logger.info("swagger api enabled on: /api/swagger.{json,yaml}"); }
Example #9
Source File: JerseyConfig.java From maintain with MIT License | 5 votes |
private void configureSwagger() { this.register(ApiListingResource.class); this.register(SwaggerSerializers.class); BeanConfig config = new BeanConfig(); config.setTitle("基于Spring Boot,Jersey, Swagger的Restful API"); config.setVersion("1.0.0"); config.setContact("赵配"); // config.setSchemes(new String[] { "http", "https" }); config.setSchemes(new String[] { "http" }); config.setBasePath(this.apiPath); config.setResourcePackage("online.zhaopei.myproject.jerseyservice"); config.setPrettyPrint(true); config.setScan(true); }
Example #10
Source File: SwaggerRestApplicationInterceptor.java From thorntail with Apache License 2.0 | 5 votes |
/** * As per the JAX-RS specification, if a deployment sub-classes JAX-RS Application and returns a non-empty collection for * either {@link Application#getClasses()} or {@link Application#getSingletons()}, then, only the references mentioned in * those collections should be used as REST resources. This poses a slight problem when the developers <i>expect</i> to see * their Swagger resources, but don't see it (due to specification conformance). This method takes care of adding the * relevant resources (if required). */ @SuppressWarnings("unchecked") @AroundInvoke public Object aroundInvoke(InvocationContext context) throws Exception { Object response = context.proceed(); // Verify if we need to do anything at all or not. This is to avoid the potential misconfiguration where this // interceptor gets added to beans that should not be included. Method method = context.getMethod(); if (Application.class.isAssignableFrom(method.getDeclaringClass())) { if ("getClasses".equals(method.getName())) { Set<Class<?>> classes = new HashSet<>((Set<Class<?>>) response); // Check the response for singletons as well. Method getSingletons = Application.class.getDeclaredMethod("getSingletons"); Set singletons = (Set) getSingletons.invoke(context.getTarget()); if (!classes.isEmpty() || !singletons.isEmpty()) { classes.add(ApiListingResource.class); classes.add(SwaggerSerializers.class); response = classes; SwaggerMessages.MESSAGES.addingSwaggerResourcesToCustomApplicationSubClass(); } } } else { SwaggerMessages.MESSAGES.warnInvalidBeanTarget(method.getDeclaringClass()); } return response; }
Example #11
Source File: SwaggerModule.java From EDDI with Apache License 2.0 | 5 votes |
@Override protected void configure() { registerConfigFiles(this.configFiles); Multibinder.newSetBinder(binder(), ServletContextListener.class) .addBinding().to(SwaggerServletContextListener.class); bind(ApiListingResource.class); bind(SwaggerSerializers.class); }
Example #12
Source File: ManagementApplication.java From graviteeio-access-management with Apache License 2.0 | 5 votes |
public ManagementApplication() { BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion(Version.RUNTIME_VERSION.MAJOR_VERSION); beanConfig.setResourcePackage("io.gravitee.am.management.handlers.management.api.resources"); beanConfig.setTitle("Gravitee.io - Access Management API"); beanConfig.setBasePath("/management"); beanConfig.setScan(true); register(OrganizationsResource.class); register(PlatformResource.class); register(CurrentUserResource.class); register(ObjectMapperResolver.class); register(ManagementExceptionMapper.class); register(UnrecognizedPropertyExceptionMapper.class); register(ThrowableMapper.class); register(ClientErrorExceptionMapper.class); register(Oauth2ExceptionMapper.class); register(ValidationExceptionMapper.class); register(JsonMappingExceptionMapper.class); register(WebApplicationExceptionMapper.class); register(UriBuilderRequestFilter.class); register(ByteArrayOutputStreamWriter.class); register(ApiListingResource.class); register(SwaggerSerializers.class); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); }
Example #13
Source File: RestAPIResourceConfig.java From datacollector with Apache License 2.0 | 4 votes |
public RestAPIResourceConfig() { register(new AbstractBinder() { @Override protected void configure() { bindFactory(PipelineStoreInjector.class).to(PipelineStoreTask.class); bindFactory(AclStoreInjector.class).to(AclStoreTask.class); bindFactory(StageLibraryInjector.class).to(StageLibraryTask.class); bindFactory(PrincipalInjector.class).to(Principal.class); bindFactory(URIInjector.class).to(URI.class); bindFactory(ConfigurationInjector.class).to(Configuration.class); bindFactory(RuntimeInfoInjector.class).to(RuntimeInfo.class); bindFactory(BuildInfoInjector.class).to(BuildInfo.class); bindFactory(StatsCollectorInjector.class).to(StatsCollector.class); bindFactory(StandAndClusterManagerInjector.class).to(Manager.class); bindFactory(SupportBundleInjector.class).to(SupportBundleManager.class); bindFactory(EventHandlerTaskInjector.class).to(EventHandlerTask.class); bindFactory(BlobStoreTaskInjector.class).to(BlobStoreTask.class); bindFactory(CredentialStoreTaskInjector.class).to(CredentialStoresTask.class); bindFactory(UserGroupManagerInjector.class).to(UserGroupManager.class); bindFactory(UsersManagerInjector.class).to(UsersManager.class); bindFactory(ActivationInjector.class).to(Activation.class); } }); register(new PaginationInfoInjectorBinder()); register(RolesAnnotationFilter.class); register(CsrfProtectionFilter.class); register(MultiPartFeature.class); //Hooking up Swagger-Core register(ApiListingResource.class); register(SwaggerSerializers.class); register(RestResponseFilter.class); //Configure and Initialize Swagger BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.0"); beanConfig.setBasePath("/rest"); beanConfig.setResourcePackage(RestAPI.class.getPackage().getName()); beanConfig.setScan(true); beanConfig.setTitle("Data Collector RESTful API"); Info info = new Info(); info.setTitle("Data Collector RESTful API"); info.setDescription("An Enterprise-Grade Approach to Managing Big Data in Motion"); info.setVersion("1.0.0"); beanConfig.setInfo(info); }
Example #14
Source File: CampRestResources.java From brooklyn-server with Apache License 2.0 | 4 votes |
public static Iterable<Object> getMiscResources() { List<Object> resources = new ArrayList<>(); resources.add(new SwaggerSerializers()); resources.add(new JacksonJsonProvider()); return resources; }
Example #15
Source File: BrooklynRestApi.java From brooklyn-server with Apache License 2.0 | 4 votes |
public static Iterable<Object> getApidocResources() { List<Object> resources = new ArrayList<Object>(); resources.add(new SwaggerSerializers()); resources.add(new ApidocResource()); return resources; }
Example #16
Source File: Server.java From redpipe with Apache License 2.0 | 4 votes |
protected void setupSwagger(VertxResteasyDeployment deployment) { ModelConverters.getInstance().addConverter(new RxModelConverter()); // Swagger ServletContext servletContext = new RedpipeServletContext(); AppGlobals.get().setGlobal(ServletContext.class, servletContext); ServletConfig servletConfig = new ServletConfig(){ @Override public String getServletName() { return "pretend-servlet"; } @Override public ServletContext getServletContext() { return servletContext; } @Override public String getInitParameter(String name) { return getServletContext().getInitParameter(name); } @Override public Enumeration<String> getInitParameterNames() { return getServletContext().getInitParameterNames(); } }; AppGlobals.get().setGlobal(ServletConfig.class, servletConfig); ReaderConfigUtils.initReaderConfig(servletConfig); BeanConfig swaggerConfig = new MyBeanConfig(); swaggerConfig.setVersion("1.0"); swaggerConfig.setSchemes(new String[]{"http"}); swaggerConfig.setHost("localhost:"+AppGlobals.get().getConfig().getInteger("http_port", 9000)); swaggerConfig.setBasePath("/"); Set<String> resourcePackages = new HashSet<>(); for (Class<?> klass : deployment.getActualResourceClasses()) { resourcePackages.add(klass.getPackage().getName()); } swaggerConfig.setResourcePackage(String.join(",", resourcePackages)); swaggerConfig.setServletConfig(servletConfig); swaggerConfig.setPrettyPrint(true); swaggerConfig.setScan(true); deployment.getRegistry().addPerInstanceResource(ApiListingResource.class); deployment.getProviderFactory().register(SwaggerSerializers.class); }
Example #17
Source File: ApiDocConfig.java From ambari-logsearch with Apache License 2.0 | 4 votes |
@Bean public SwaggerSerializers swaggerSerializers() { return new SwaggerSerializers(); }
Example #18
Source File: Swagger2Feature.java From cxf with Apache License 2.0 | 4 votes |
@Override protected void addSwaggerResource(Server server, Bus bus) { JAXRSServiceFactoryBean sfb = (JAXRSServiceFactoryBean) server.getEndpoint().get(JAXRSServiceFactoryBean.class.getName()); ServerProviderFactory factory = (ServerProviderFactory)server.getEndpoint().get(ServerProviderFactory.class.getName()); final ApplicationInfo appInfo = DefaultApplicationFactory.createApplicationInfoOrDefault(server, factory, sfb, bus, isScan()); List<Object> swaggerResources = new LinkedList<>(); if (customizer == null) { customizer = new Swagger2Customizer(); } ApiListingResource apiListingResource = new Swagger2ApiListingResource(customizer); swaggerResources.add(apiListingResource); List<Object> providers = new ArrayList<>(); providers.add(new SwaggerSerializers()); if (isRunAsFilter()) { providers.add(new SwaggerContainerRequestFilter(appInfo == null ? null : appInfo.getProvider(), customizer)); } final Properties swaggerProps = getSwaggerProperties(propertiesLocation, bus); final Registration swaggerUiRegistration = getSwaggerUi(bus, swaggerProps, isRunAsFilter()); if (!isRunAsFilter()) { swaggerResources.addAll(swaggerUiRegistration.getResources()); } providers.addAll(swaggerUiRegistration.getProviders()); sfb.setResourceClassesFromBeans(swaggerResources); List<ClassResourceInfo> cris = sfb.getClassResourceInfo(); if (!isRunAsFilter()) { for (ClassResourceInfo cri : cris) { if (ApiListingResource.class.isAssignableFrom(cri.getResourceClass())) { InjectionUtils.injectContextProxies(cri, apiListingResource); } } } customizer.setClassResourceInfos(cris); customizer.setDynamicBasePath(dynamicBasePath); BeanConfig beanConfig = appInfo == null ? new BeanConfig() : new ApplicationBeanConfig(appInfo.getProvider()); initBeanConfig(beanConfig, swaggerProps); Swagger swagger = beanConfig.getSwagger(); if (swagger != null && securityDefinitions != null) { swagger.setSecurityDefinitions(securityDefinitions); } customizer.setBeanConfig(beanConfig); providers.add(new ReaderConfigFilter()); if (beanConfig.isUsePathBasedConfig()) { providers.add(new ServletConfigProvider()); } factory.setUserProviders(providers); }