Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
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;
  }