ePages-de / restdocs-raml

Adds RAML support for Spring REST Docs
MIT License
26 stars 7 forks source link

Ignored LinkDescriptors without description will fail validation #10

Closed ooz closed 6 years ago

ooz commented 6 years ago

If I try to pass a LinkDescriptor, which is ignored and does not have a description, to the RamlResourceSnippetParameters I will get a FieldDescriptor validation error by Spring Restdocs.

The reason for this is in com.epages.restdocs.raml.RamlResourceSnippetParameters:

    List<FieldDescriptor> getResponseFieldsWithLinks() {
        List<FieldDescriptor> combinedDescriptors = new ArrayList<>(getResponseFields());
        combinedDescriptors.addAll(
                getLinks().stream()
                        .flatMap(l -> Stream.of(
                                fieldWithPath("_links." + l.getRel())
                                        .description(l.getDescription())
                                        .type(JsonFieldType.OBJECT),
                                fieldWithPath("_links." + l.getRel() + ".href")
                                        .type(JsonFieldType.STRING)
                                        .ignored()
                        ))
                        .collect(Collectors.toList())
        );
        return combinedDescriptors;
    }

It will convert all LinkDescriptors to FieldDescriptors, but it will not carry over the ignored information.

ooz commented 6 years ago

Solved