Java Code Examples for org.springframework.restdocs.payload.FieldDescriptor#getPath()

The following examples show how to use org.springframework.restdocs.payload.FieldDescriptor#getPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardTableSnippet.java    From spring-auto-restdocs with Apache License 2.0 6 votes vote down vote up
protected Map<String, Object> createModelForDescriptor(FieldDescriptor descriptor,
        TemplateFormatting templateFormatting, SnippetTranslationResolver translationResolver) {
    String path = descriptor.getPath();
    String type = toString(descriptor.getType());
    String methodComment = resolveComment(descriptor);
    String deprecatedComment = resolveDeprecated(descriptor, translationResolver);
    String completeComment = join("<p>", deprecatedComment, methodComment);
    String description = convertFromJavadoc(completeComment, templateFormatting);

    String optional = resolveOptional(descriptor, templateFormatting);
    List<String> constraints = resolveConstraints(descriptor);
    final String defaultValue = resolveDefaultValue(descriptor, translationResolver);
    description = joinAndFormat(description, constraints, defaultValue, templateFormatting);

    Map<String, Object> model = new HashMap<>();
    model.put("path", path);
    model.put("type", type);
    model.put("optional", optional);
    model.put("description", description);
    return model;
}
 
Example 2
Source File: JsonSchemaFromFieldDescriptorsGenerator.java    From restdocs-raml with MIT License 5 votes vote down vote up
private FieldDescriptor reduceToSingleIfAllEqual(List<FieldDescriptor> fieldDescriptors) {
    if (fieldDescriptors.size() == 1) {
        return fieldDescriptors.get(0);
    }
    FieldDescriptor first = fieldDescriptors.get(0);
    final boolean hasDifferentDiscriptors = fieldDescriptors.subList(1, fieldDescriptors.size()).stream()
            .anyMatch(fieldDescriptor -> !equalsOnFields(first, fieldDescriptor));
    if (hasDifferentDiscriptors) {
        throw new MultipleNonEqualFieldDescriptors(first.getPath());
    } else {
        return first;
    }
}
 
Example 3
Source File: ExtendedFieldDescriptor.java    From spring-auto-restdocs with Apache License 2.0 5 votes vote down vote up
public ExtendedFieldDescriptor(FieldDescriptor descriptor) {
    this.path = descriptor.getPath();
    this.type = descriptor.getType();
    this.optionals = (List<String>) descriptor.getAttributes().get(OPTIONAL_ATTRIBUTE);
    this.description = descriptor.getDescription();
    this.constraints = (List<String>) descriptor.getAttributes().get(CONSTRAINTS_ATTRIBUTE);
}