Package com.wordnik.swagger.annotations

Examples of com.wordnik.swagger.annotations.ApiOperation


                    if (!method.isAnnotationPresent(ApiOperation.class)) {
                        LOG.debug("Method <{}> has no ApiOperation annotation. Skipping.", method.toGenericString());
                        continue;
                    }

                    ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);

                    Map<String, Object> api = Maps.newHashMap();
                    List<Map<String, Object>> operations = Lists.newArrayList();

                    String methodPath;
                    if (method.isAnnotationPresent(Path.class)) {
                        // Method has annotated Path.
                        methodPath = cleanRoute(method.getAnnotation(Path.class).value());

                        if (clazz.isAnnotationPresent(Path.class)) {
                            // The class has a Path, too. Prepend.
                            String classPath = cleanRoute(clazz.getAnnotation(Path.class).value());
                            methodPath = classPath + methodPath;
                        }
                    } else {
                        // Method has no annotated Path. We read from it's class.
                        if (clazz.isAnnotationPresent(Path.class)) {
                            methodPath = cleanRoute(clazz.getAnnotation(Path.class).value());
                        } else {
                            LOG.debug("Method <{}> has no Path annotation. Skipping.", method.toGenericString());
                            continue;
                        }
                    }

                    Produces produces = null;
                    if (clazz.isAnnotationPresent(Produces.class) || method.isAnnotationPresent(Produces.class)) {
                        produces = clazz.getAnnotation(Produces.class);
                        if (method.isAnnotationPresent(Produces.class)) {
                            produces = method.getAnnotation(Produces.class);
                        }
                    }
                    api.put("path", methodPath);

                    Map<String, Object> operation = Maps.newHashMap();
                    operation.put("method", determineHttpMethod(method));
                    operation.put("summary", apiOperation.value());
                    operation.put("notes", apiOperation.notes());
                    operation.put("nickname", method.getName());
                    if (produces != null) {
                        operation.put("produces", produces.value());
                    }
                    // skip Response.class because we can't reliably infer any schema information from its payload anyway.
View Full Code Here


        methodElement.setAttribute("method",httpMethod);
        GZIP gzip = td.getAnnotation(GZIP.class);
        if (gzip!=null) {
            methodElement.setAttribute("gzip","true");
        }
        ApiOperation apiOperation = td.getAnnotation(ApiOperation.class);
        String responseClass = null;
        if (apiOperation!=null) {
            String description = apiOperation.value();
            setOptionalAttribute(methodElement, "description", description);
            if (!apiOperation.responseClass().equals("void")) {
                responseClass = apiOperation.responseClass();
                if (apiOperation.multiValueResponse())
                    responseClass = responseClass + " (multi)";
            }
            processNotes(doc, methodElement, apiOperation);
        }
View Full Code Here

    Set<MediaType> producesMediaTypes = producesRequestCondition.getProducibleMediaTypes();

    List<String> consumesList = toList(consumesMediaTypes);
    List<String> producesList = toList(producesMediaTypes);

    ApiOperation annotation = context.getApiOperationAnnotation();
    if (null != annotation && !isBlank(annotation.consumes())) {
      consumesList = asList(annotation.consumes());
    }

    if (handlerMethodHasFileParameter(context, swaggerGlobalSettings)) {
      //Swagger spec requires consumes is multipart/form-data for file parameter types
      consumesList = Arrays.asList("multipart/form-data");
    }

    if (null != annotation && !isBlank(annotation.produces())) {
      producesList = asList(annotation.produces());
    }

    context.put("consumes", consumesList);
    context.put("produces", producesList);
  }
View Full Code Here

  @Override
  public void execute(RequestMappingContext context) {

    HandlerMethod handlerMethod = context.getHandlerMethod();
    String notes = handlerMethod.getMethod().getName();
    ApiOperation methodAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);
    if ((null != methodAnnotation) && !StringUtils.isBlank(methodAnnotation.notes())) {
      notes = methodAnnotation.notes();
    }
    context.put("notes", notes);
  }
View Full Code Here

  @Override
  public void execute(RequestMappingContext context) {
    int origPosition = (Integer) context.get("currentCount");
    Integer operationPosition = origPosition;
    ApiOperation apiOperation = context.getApiOperationAnnotation();
    if (null != apiOperation && apiOperation.position() > 0) {
      operationPosition = apiOperation.position();
    }
    context.put("position", operationPosition);
    int next = max((origPosition + 1), operationPosition);
    context.put("currentCount", next);
    log.debug("Added operation at position: {}. Next position is: {}", operationPosition, next);
View Full Code Here

    if (null != authorizationContext) {
      authorizations = authorizationContext.getAuthorizationsForPath(requestMappingPattern);
    }

    ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);

    if (null != apiOperationAnnotation && null != apiOperationAnnotation.authorizations()) {
      Authorization[] authorizationAnnotations = apiOperationAnnotation.authorizations();
      if (authorizationAnnotations != null
              && authorizationAnnotations.length > 0
              && !StringUtils.isBlank(authorizationAnnotations[0].value())) {

        authorizations = newArrayList();
View Full Code Here

  public void execute(RequestMappingContext context) {
    RequestMethod currentHttpMethod = (RequestMethod) context.get("currentHttpMethod");
    HandlerMethod handlerMethod = context.getHandlerMethod();

    String requestMethod = currentHttpMethod.toString();
    ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);

    if (apiOperationAnnotation != null && !StringUtils.isBlank(apiOperationAnnotation.httpMethod())) {
      String apiMethod = apiOperationAnnotation.httpMethod();
      try {
        RequestMethod.valueOf(apiMethod);
        requestMethod = apiMethod;
      } catch (IllegalArgumentException e) {
        log.error("Invalid http method: " + apiMethod + "Valid ones are [" + RequestMethod.values() + "]", e);
View Full Code Here

public class OperationSummaryReader implements RequestMappingReader {
  @Override
  public void execute(RequestMappingContext context) {
    HandlerMethod handlerMethod = context.getHandlerMethod();
    ApiOperation apiOperationAnnotation = context.getApiOperationAnnotation();

    String summary = handlerMethod.getMethod().getName();
    if (null != apiOperationAnnotation && !StringUtils.isBlank(apiOperationAnnotation.value())) {
      summary = apiOperationAnnotation.value();
    }
    context.put("summary", summary);
  }
View Full Code Here

  @Override
  public void execute(RequestMappingContext context) {
    SwaggerGlobalSettings swaggerGlobalSettings = (SwaggerGlobalSettings) context.get("swaggerGlobalSettings");
    HandlerMethod handlerMethod = context.getHandlerMethod();
    ApiOperation methodAnnotation = AnnotationUtils.findAnnotation(handlerMethod.getMethod(), ApiOperation.class);
    ResolvedType returnType;
    if ((null != methodAnnotation) && Void.class != methodAnnotation.response()) {
      log.debug("Overriding response class with annotated response class");
      returnType = swaggerGlobalSettings.getTypeResolver().resolve(methodAnnotation.response());
    } else {
      returnType = handlerReturnType(swaggerGlobalSettings.getTypeResolver(), handlerMethod);
      returnType = swaggerGlobalSettings.getAlternateTypeProvider().alternateFor(returnType);
    }
    if (Void.class.equals(returnType.getErasedType()) || Void.TYPE.equals(returnType.getErasedType())) {
View Full Code Here

    HandlerMethodResolver handlerMethodResolver
            = new HandlerMethodResolver(swaggerGlobalSettings.getTypeResolver());
    ResolvedType modelType = ModelUtils.handlerReturnType(swaggerGlobalSettings.getTypeResolver(), handlerMethod);
    modelType = swaggerGlobalSettings.getAlternateTypeProvider().alternateFor(modelType);

    ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);
    if (null != apiOperationAnnotation && Void.class != apiOperationAnnotation.response()) {
      modelType = asResolved(swaggerGlobalSettings.getTypeResolver(), apiOperationAnnotation.response());
    }
    if (!swaggerGlobalSettings.getIgnorableParameterTypes().contains(modelType.getErasedType())) {
      ModelContext modelContext = ModelContext.returnValue(modelType);
      markIgnorablesAsHasSeen(swaggerGlobalSettings.getTypeResolver(),
              swaggerGlobalSettings.getIgnorableParameterTypes(),
View Full Code Here

TOP

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

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.