Esempio n. 1
0
  @Test
  public void descriptionAppearsInGetterJavadoc() throws IOException {

    JavaMethod javaMethod = classWithTitle.getMethodBySignature("getTitle", new Type[] {});
    String javaDocComment = javaMethod.getComment();

    assertThat(javaDocComment, containsString("A title for this property"));
  }
Esempio n. 2
0
  private void processRestMethod(
      JavaMethod javaMethod,
      String method,
      Map<String, ObjectNode> pathMap,
      String resourcePath,
      ArrayNode tagArray,
      ObjectNode definitions) {
    String fullPath = resourcePath, consumes = "", produces = "", comment = javaMethod.getComment();
    DocletTag tag = javaMethod.getTagByName("rsModel");
    for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
      String name = annotation.getType().getName();
      if (name.equals(PATH)) {
        fullPath = resourcePath + "/" + getPath(annotation);
        fullPath = fullPath.replaceFirst("^//", "/");
      }
      if (name.equals(CONSUMES)) {
        consumes = getIOType(annotation);
      }
      if (name.equals(PRODUCES)) {
        produces = getIOType(annotation);
      }
    }
    ObjectNode methodNode = mapper.createObjectNode();
    methodNode.set("tags", tagArray);

    addSummaryDescriptions(methodNode, comment);
    addJsonSchemaDefinition(definitions, tag);
    addJsonSchemaDefinition(definitions, tag);

    processParameters(javaMethod, methodNode, method, tag);

    processConsumesProduces(methodNode, "consumes", consumes);
    processConsumesProduces(methodNode, "produces", produces);
    if (tag == null
        || ((method.toLowerCase().equals("post") || method.toLowerCase().equals("put"))
            && !(tag.getParameters().size() > 1))) {
      addResponses(methodNode, tag, false);
    } else {
      addResponses(methodNode, tag, true);
    }

    ObjectNode operations = pathMap.get(fullPath);
    if (operations == null) {
      operations = mapper.createObjectNode();
      operations.set(method, methodNode);
      pathMap.put(fullPath, operations);
    } else {
      operations.set(method, methodNode);
    }
  }
Esempio n. 3
0
  private void processRestMethod(
      JavaMethod javaMethod,
      String method,
      Map<String, ObjectNode> pathMap,
      String resourcePath,
      ArrayNode tagArray) {
    String fullPath = resourcePath, consumes = "", produces = "", comment = javaMethod.getComment();
    for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
      String name = annotation.getType().getName();
      if (name.equals(PATH)) {
        fullPath = resourcePath + "/" + getPath(annotation);
        fullPath = fullPath.replaceFirst("^//", "/");
      }
      if (name.equals(CONSUMES)) {
        consumes = getIOType(annotation);
      }
      if (name.equals(PRODUCES)) {
        produces = getIOType(annotation);
      }
    }
    ObjectNode methodNode = mapper.createObjectNode();
    methodNode.set("tags", tagArray);

    addSummaryDescriptions(methodNode, comment);
    processParameters(javaMethod, methodNode);

    processConsumesProduces(methodNode, "consumes", consumes);
    processConsumesProduces(methodNode, "produces", produces);

    addResponses(methodNode);

    ObjectNode operations = pathMap.get(fullPath);
    if (operations == null) {
      operations = mapper.createObjectNode();
      operations.set(method, methodNode);
      pathMap.put(fullPath, operations);
    } else {
      operations.set(method, methodNode);
    }
  }
Esempio n. 4
0
 private void buildDescription(MethodDocument document, JavaMethod javaMethod) {
   document.setDescription(javaMethod.getComment());
 }