Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Including Spring Restdocs snippets in AutoDocumentation.section #248

Closed
kschulst opened this issue Jul 19, 2018 · 3 comments
Closed

Including Spring Restdocs snippets in AutoDocumentation.section #248

kschulst opened this issue Jul 19, 2018 · 3 comments

Comments

@kschulst
Copy link

How can I include snippets generated by core Spring Restdocs into spring-auto-restdocs sections?

I am aware of
https://scacap.github.io/spring-auto-restdocs/#snippets-section-custom-snippet

I want to render core spring restdocs HATEOAS link snippets inside the very convenient section snippet that spring-auto-restdocs provides.

@kschulst
Copy link
Author

I have looked a bit into this and everything leads to:
The SectionSnippet class:

The way spring-auto-restdocs renders the section:

    private SectionSupport getSectionSnippet(Operation operation, String snippetName) {
        return getDefaultSnippets(operation).stream()
                .filter(snippet -> snippet instanceof SectionSupport)
                .map(snippet -> (SectionSupport) snippet)
                .filter(snippet -> snippetName.equals(snippet.getFileName()))
                .findFirst()
                .orElseGet(() -> SnippetRegistry.getClassicSnippet(snippetName));
    }

...requiring the Snippet to implement a spring-auto-restdocs interface (SectionSupport) in effect forces the spring-restdocs snippets to end up in the orElseGet and thus fetched from the capital.scalable.restdocs.SnippetRegistry. But SnippetRegistry is locked down and cannot be expanded upon.

Would you be interested in a pull request to loosen up the SnippetRegistry a bit, making it possible to register other snippets?

And also even maybe preregister all "classic snippets" in the SnippetRegistry?
As of now, only the following snippets are available:

CURL_REQUEST
HTTPIE_REQUEST
HTTP_REQUEST
HTTP_RESPONSE

(And please let me know if there are any other way of accomplishing this.)

@jmisur
Copy link
Contributor

jmisur commented Jul 20, 2018

Hi @kschulst, if you can make a PR proposal how to make SnippetRegistry nicely extensible or configurable, we'll very welcome it.

kschulst added a commit to kschulst/spring-auto-restdocs that referenced this issue Jul 20, 2018
kschulst added a commit to kschulst/spring-auto-restdocs that referenced this issue Jul 20, 2018
kschulst added a commit to kschulst/spring-auto-restdocs that referenced this issue Jul 20, 2018
@kschulst
Copy link
Author

@jmisur I have submitted a pull request for this...

jmisur added a commit that referenced this issue Nov 22, 2018
Fixes #248
Also improves SARD/SRD mix example.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants