예제 #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
  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;
  }
예제 #3
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);
 }
예제 #4
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;
  }