Package com.wordnik.swagger.annotations

Examples of com.wordnik.swagger.annotations.Api


                return overviewResult;
            }

            List<Map<String, Object>> apis = Lists.newArrayList();
            for (Class<?> clazz : getAnnotatedClasses()) {
                Api info = clazz.getAnnotation(Api.class);
                Path path = clazz.getAnnotation(Path.class);

                if (info == null || path == null) {
                    LOG.debug("Skipping REST resource with no Api or Path annotation: <{}>", clazz.getCanonicalName());
                    continue;
                }

                Map<String, Object> apiDescription = Maps.newHashMap();
                apiDescription.put("name", info.value());
                apiDescription.put("path", path.value());
                apiDescription.put("description", info.description());

                apis.add(apiDescription);
            }
            Collections.sort(apis, new Comparator<Map<String, Object>>() {
                @Override
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    return ComparisonChain.start().compare(o1.get("name").toString(), o2.get("name").toString()).result();
                }
            });
            Map<String, String> info = Maps.newHashMap();
            info.put("title", "Graylog2 REST API");

            overviewResult.put("apiVersion", ServerVersion.VERSION.toString());
            overviewResult.put("swaggerVersion", EMULATED_SWAGGER_VERSION);
            overviewResult.put("apis", apis);
View Full Code Here


        String className = classElementIn.toString();
        classElement.setAttribute("name",className);
        String value = basePath.value();
        value = cleanOutPath(value);
        classElement.setAttribute("path", value);
        Api api = classElementIn.getAnnotation(Api.class);
        if (api!=null) {
            String shortDescription = api.value();
            setOptionalAttribute(classElement, "shortDesc", shortDescription);
            String longDescription = api.description();
            setOptionalAttribute(classElement, "description", longDescription);
            String basePathAttr = api.basePath();
            setOptionalAttribute(classElement, "basePath",basePathAttr);
        }
        Produces produces = classElementIn.getAnnotation(Produces.class);
        if (produces!=null) {
            String[] types = produces.value();
View Full Code Here

  }

  @Override
  public Integer getResourcePosition(RequestMappingInfo requestMappingInfo, HandlerMethod handlerMethod) {
    Class<?> controllerClass = handlerMethod.getBeanType();
    Api apiAnnotation = AnnotationUtils.findAnnotation(controllerClass, Api.class);
    if (null != apiAnnotation && !isBlank(apiAnnotation.value())) {
      return apiAnnotation.position();
    }
    return 0;
  }
View Full Code Here

    return extractAnnotation(controllerClass, valueExtractor()).or(group);
  }

  private Optional<String> extractAnnotation(Class<?> controllerClass, Function<Api,
          Optional<String>> annotationExtractor) {
    Api apiAnnotation = AnnotationUtils.findAnnotation(controllerClass, Api.class);
    return annotationExtractor.apply(apiAnnotation);
  }
View Full Code Here

  private String getDescription(HandlerMethod handlerMethod) {
    Class<?> controllerClass = handlerMethod.getBeanType();
    String description = splitCamelCase(controllerClass.getSimpleName(), " ");

    Api apiAnnotation = AnnotationUtils.findAnnotation(controllerClass, Api.class);
    if (null != apiAnnotation) {
      String descriptionFromAnnotation = Optional.fromNullable(emptyToNull(apiAnnotation.value()))
              .or(apiAnnotation.description());
      if (!isNullOrEmpty(descriptionFromAnnotation)) {
        return descriptionFromAnnotation;
      }
    }
    return description;
View Full Code Here

            }

            Set<Method> requestMappingMethods = AnnotationUtils.getAnnotatedMethods(controllerClass, RequestMapping.class);
            ApiListing apiListing = processControllerApi(controllerClass);
            String description = "";
            Api controllerApi = controllerClass.getAnnotation(Api.class);
            if (controllerApi != null) {
                description = controllerApi.description();
            }

            if (apiListing.apis().size() == 0) {
                apiListing = processMethods(requestMappingMethods, controllerClass, apiListing, description);
            }
View Full Code Here

        return apiListingMap;
    }

    private ApiListing processControllerApi(Class<?> controllerClass) {
        String resourcePath = "";
        Api controllerApi = controllerClass.getAnnotation(Api.class);
        if (controllerApi != null) {
            resourcePath = controllerApi.basePath();
        }

        if (controllerApi == null || resourcePath.isEmpty()) {
            RequestMapping controllerRequestMapping = controllerClass.getAnnotation(RequestMapping.class);
            if (controllerRequestMapping != null && controllerRequestMapping.value() != null &&
View Full Code Here

            info.getTermsOfServiceUrl(), info.getContact(),
            info.getLicense(), info.getLicenseUrl()));
    }

    private ApiListing getDocFromClass(Class c, SwaggerConfig swaggerConfig, String basePath) throws Exception {
        Api resource = (Api) c.getAnnotation(Api.class);

        if (resource == null) return null;
        ClassReader reader = getApiReader();
        Option<ApiListing> apiListing = reader.read(basePath, c, swaggerConfig);
View Full Code Here

TOP

Related Classes of com.wordnik.swagger.annotations.Api

Copyright © 2018 www.massapicom. 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.