Examples of SwaggerConfig


Examples of com.wordnik.swagger.config.SwaggerConfig

        return new SwaggerEndpoint(swaggerEndpointProps());
    }

    @Bean
    SwaggerConfig swaggerConfig() {
        SwaggerConfig config = ConfigFactory.config();
        config.setApiVersion(swaggerProperties().getApiVersion().get());
        config.setBasePath(swaggerProperties().getBasePath().get());
        ScannerFactory.setScanner(new DefaultJaxrsScanner());
        ClassReaders.setReader(new DefaultJaxrsApiReader());

        //TODO: move to another module?
        objectMapper.registerModule(new DefaultScalaModule());
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

    @Test
    public void testReaderRead() throws Exception {
        RestDefinition rest = context.getRestDefinitions().get(0);
        assertNotNull(rest);

        SwaggerConfig config = new SwaggerConfig();
        config.setBasePath("http://localhost:8080/api");
        RestSwaggerReader reader = new RestSwaggerReader();
        Option<ApiListing> option = reader.read(rest, config);
        assertNotNull(option);
        ApiListing listing = option.get();
        assertNotNull(listing);
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

    @RequestMapping(value = "/partials/{partial}")
    public ModelAndView partial(@PathVariable("partial") String partial) {
        ModelAndView mav = new ModelAndView("/developer/public/partials/" + partial);
        String release = env.get("release");
        mav.addObject("release", release);
        final SwaggerConfig config = ConfigFactory.config();
        final String apiDocsURL = config.getBasePath()+"/api-docs";
        mav.addObject("apiDocsURL", apiDocsURL);
        return mav;
    }
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

                serve("/*").with(ServletContainer.class, props);

                ReflectiveJaxrsScanner scanner = new ReflectiveJaxrsScanner();
                scanner.setResourcePackage(getClass().getPackage().getName());
                ScannerFactory.setScanner(scanner);
                SwaggerConfig config = ConfigFactory.config();
                config.setApiVersion("1.0.0");

                String basePath = "http://localhost:8002/api";
                if (System.getProperties().contains("swagger.basePath")) {
                    basePath = System.getProperty("swagger.basePath");
                }
                config.setBasePath(basePath);
                ConfigFactory.setConfig(config);

                FilterFactory.setFilter(new ApiAuthorizationFilterImpl());
                ScannerFactory.setScanner(new DefaultJaxrsScanner());
                ClassReaders.setReader(new DefaultJaxrsApiReader());
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

    environment.jersey().register(new ApiListingResourceJSON());
    environment.jersey().register(new ApiDeclarationProvider());
    environment.jersey().register(new ResourceListingProvider());
    ScannerFactory.setScanner(new DefaultJaxrsScanner());
    ClassReaders.setReader(new DefaultJaxrsApiReader());
    SwaggerConfig swaggerConfig = ConfigFactory.config();
    swaggerConfig.setApiVersion("1");
    swaggerConfig.setBasePath("/rest");

    // cache configuration
    // prevent caching on REST resources, except for favicons
    environment.servlets().addFilter("cache-filter", new CacheBustingFilter() {
      @Override
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

        this.ignorableAnnotations = ignorableAnnotations;
        this.ignoreUnusedPathVariables = ignoreUnusedPathVariables;
        this.basePath = basePath;
        this.apiVersion = apiVersion;

        swaggerConfig = new SwaggerConfig();
        if (apiInfo != null) {
            swaggerConfig.setApiInfo(apiInfo);
        }
        swaggerConfig.setApiPath(servletPath);
        swaggerConfig.setApiVersion(apiVersion);
View Full Code Here

Examples of com.wordnik.swagger.config.SwaggerConfig

        this.apiSource = apiSource;
    }

    @Override
    public void loadDocuments() throws GenerateException {
        SwaggerConfig swaggerConfig = new SwaggerConfig();
        swaggerConfig.setApiVersion(apiSource.getApiVersion());
        swaggerConfig.setSwaggerVersion(SwaggerSpec.version());
        List<ApiListingReference> apiListingReferences = new ArrayList<ApiListingReference>();

        if (apiSource.getSwaggerInternalFilter() != null) {
            FilterFactory$ filterFactory = FilterFactory$.MODULE$;
            try {
                LOG.info("Setting filter configuration: " + apiSource.getSwaggerInternalFilter());
                filterFactory.filter_$eq((SwaggerSpecFilter) Class.forName(apiSource.getSwaggerInternalFilter()).newInstance());
            } catch (Exception e) {
                throw new GenerateException("Cannot load: " + apiSource.getSwaggerInternalFilter(), e);
            }
        }

        List<AuthorizationType> authorizationTypes = new ArrayList<AuthorizationType>();
        for (Class c : apiSource.getValidClasses()) {
            ApiListing doc;
            try {
                doc = getDocFromClass(c, swaggerConfig, getBasePath());
            } catch (Exception e) {
                throw new GenerateException(e);
            }
            if (doc == null) continue;
            LOG.info("Detect Resource:" + c.getName());

            Buffer<AuthorizationType> buffer = doc.authorizations().toBuffer();
            authorizationTypes.addAll(JavaConversions.asJavaList(buffer));
            ApiListingReference apiListingReference = new ApiListingReference(doc.resourcePath(), doc.description(), doc.position());
            apiListingReferences.add(apiListingReference);
            acceptDocument(doc);
        }
        // sort apiListingRefernce by position
        Collections.sort(apiListingReferences, new Comparator<ApiListingReference>() {
            @Override
            public int compare(ApiListingReference o1, ApiListingReference o2) {
                if (o1 == null && o2 == null) return 0;
                if (o1 == null && o2 != null) return -1;
                if (o1 != null && o2 == null) return 1;
                return o1.position() - o2.position();
            }
        });
        serviceDocument = new ResourceListing(swaggerConfig.apiVersion(), swaggerConfig.swaggerVersion(),
                                              scala.collection.immutable.List.fromIterator(JavaConversions.asScalaIterator(apiListingReferences.iterator())),
                                              scala.collection.immutable.List.fromIterator(JavaConversions.asScalaIterator(authorizationTypes.iterator())),
                                              toSwaggerApiInfo(apiSource.getApiInfo()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.