Пример #1
0
  private void collectParameters(RequestMappingContext context) {

    HandlerMethod handlerMethod = context.getHandlerMethod();
    Method method = handlerMethod.getMethod();

    LOG.debug(
        "Reading parameters models for handlerMethod |{}|", handlerMethod.getMethod().getName());

    HandlerMethodResolver handlerMethodResolver = new HandlerMethodResolver(typeResolver);
    List<ResolvedMethodParameter> parameterTypes =
        handlerMethodResolver.methodParameters(handlerMethod);
    for (ResolvedMethodParameter parameterType : parameterTypes) {
      Annotation[] parameterAnnotations =
          parameterType.getMethodParameter().getParameterAnnotations();
      for (Annotation annotation : parameterAnnotations) {
        if (annotation instanceof RequestBody || annotation instanceof RequestPart) {
          ResolvedType modelType = context.alternateFor(parameterType.getResolvedParameterType());
          LOG.debug(
              "Adding input parameter of type {}", resolvedTypeSignature(modelType).or("<null>"));
          context.operationModelsBuilder().addInputParam(modelType);
        }
      }
    }
    LOG.debug(
        "Finished reading parameters models for handlerMethod |{}|",
        handlerMethod.getMethod().getName());
  }
Пример #2
0
 private void collectFromReturnType(RequestMappingContext context) {
   ResolvedType modelType =
       new HandlerMethodResolver(typeResolver).methodReturnType(context.getHandlerMethod());
   modelType = context.alternateFor(modelType);
   LOG.debug("Adding return parameter of type {}", resolvedTypeSignature(modelType).or("<null>"));
   context.operationModelsBuilder().addReturn(modelType);
 }
Пример #3
0
  @Override
  //  @Cacheable(value = "operations", keyGenerator = OperationsKeyGenerator.class)
  public List<Operation> read(RequestMappingContext outerContext) {

    List<Operation> operations = newArrayList();

    Set<RequestMethod> requestMethods = outerContext.getMethodsCondition();
    Set<RequestMethod> supportedMethods = supportedMethods(requestMethods);

    // Setup response message list
    Integer currentCount = 0;
    for (RequestMethod httpRequestMethod : supportedMethods) {
      OperationContext operationContext =
          new OperationContext(
              new OperationBuilder(nameGenerator), httpRequestMethod, outerContext, currentCount);

      Operation operation = pluginsManager.operation(operationContext);
      if (!operation.isHidden()) {
        operations.add(operation);
        currentCount++;
      }
    }
    Collections.sort(operations, outerContext.operationOrdering());

    return operations;
  }
Пример #4
0
  public List<ApiDescription> read(RequestMappingContext outerContext) {
    PatternsRequestCondition patternsCondition = outerContext.getPatternsCondition();
    ApiSelector selector = outerContext.getDocumentationContext().getApiSelector();

    List<ApiDescription> apiDescriptionList = newArrayList();
    for (String path : matchingPaths(selector, patternsCondition)) {
      String methodName = outerContext.getName();
      RequestMappingContext operationContext = outerContext.copyPatternUsing(path);

      List<Operation> operations = operationReader.read(operationContext);
      if (operations.size() > 0) {
        operationContext
            .apiDescriptionBuilder()
            .operations(operations)
            .pathDecorator(
                pluginsManager.decorator(new PathContext(outerContext, from(operations).first())))
            .path(path)
            .description(methodName)
            .hidden(false);
        ApiDescription apiDescription = operationContext.apiDescriptionBuilder().build();
        lookup.add(outerContext.key(), apiDescription);
        apiDescriptionList.add(apiDescription);
      }
    }
    return apiDescriptionList;
  }
Пример #5
0
  public List<ApiDescription> read(RequestMappingContext outerContext) {
    RequestMappingInfo requestMappingInfo = outerContext.getRequestMappingInfo();
    HandlerMethod handlerMethod = outerContext.getHandlerMethod();
    PatternsRequestCondition patternsCondition = requestMappingInfo.getPatternsCondition();
    ApiSelector selector = outerContext.getDocumentationContext().getApiSelector();

    List<ApiDescription> apiDescriptionList = newArrayList();
    for (String path : matchingPaths(selector, patternsCondition)) {
      String methodName = handlerMethod.getMethod().getName();
      RequestMappingContext operationContext = outerContext.copyPatternUsing(path);

      List<Operation> operations = operationReader.read(operationContext);
      ApiDescriptionBuilder descriptionBuilder = operationContext.apiDescriptionBuilder();
      descriptionBuilder.operations(operations);
      operationContext.apiDescriptionBuilder().operations(operations);
      operationContext
          .apiDescriptionBuilder()
          .pathDecorator(
              pluginsManager.decorator(new PathContext(outerContext, from(operations).first())));
      descriptionBuilder.path(path);
      descriptionBuilder.description(methodName);
      descriptionBuilder.hidden(false);
      apiDescriptionList.add(descriptionBuilder.build());
    }
    return apiDescriptionList;
  }
Пример #6
0
  public List<ApiDescription> read(RequestMappingContext outerContext) {
    RequestMappingInfo requestMappingInfo = outerContext.getRequestMappingInfo();
    HandlerMethod handlerMethod = outerContext.getHandlerMethod();
    PatternsRequestCondition patternsCondition = requestMappingInfo.getPatternsCondition();
    ApiSelector selector = outerContext.getDocumentationContext().getApiSelector();
    PathProvider pathProvider = outerContext.getDocumentationContext().getPathProvider();

    List<ApiDescription> apiDescriptionList = newArrayList();
    for (String pattern : matchingPaths(selector, patternsCondition)) {
      String cleanedRequestMappingPath = sanitizeRequestMappingPattern(pattern);
      String path = pathProvider.getOperationPath(cleanedRequestMappingPath);
      String methodName = handlerMethod.getMethod().getName();
      RequestMappingContext operationContext =
          outerContext.copyPatternUsing(cleanedRequestMappingPath);
      PathMappingAdjuster adjuster =
          new PathMappingAdjuster(operationContext.getDocumentationContext());
      apiDescriptionList.add(
          new ApiDescriptionBuilder(outerContext.operationOrdering())
              .path(adjuster.adjustedPath(path))
              .description(methodName)
              .operations(operationReader.read(operationContext))
              .hidden(false)
              .build());
    }
    return apiDescriptionList;
  }