Skip to content

feat: Add document method accepting ResourceSnippetParametersBuilder #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arachneee
Copy link

@Arachneee Arachneee commented Apr 5, 2025

I'm using your library well.

It's possible to write like the code below, but there's a bug where responsefields and requestfields are initialized. So I added document parameters.

There will be no problem in the process of introducing the restdocs-api-spec library to restdoc, but if you write it with the restdocs-api-spec library from the beginning, it is very useful to write it as follows.

resultActions
                .andExpect(status().isOk())
                .andDo(document("cart-get",
                                new ResourceSnippetParametersBuilder()
                                        .tag("cart")
                                        .description("Get a cart by id")
                                        .responseSchema(Schema.schema("ResponseCart"))
                                        .pathParameters(
                                                parameterWithName("id").description("the cart id"))
                                        .responseFields(
                                                fieldWithPath("total").description("Total amount of the cart."),
                                                fieldWithPath("products").description("The product line item of the cart."),
                                                subsectionWithPath("products[]._links.product").description("Link to the product."),
                                                fieldWithPath("products[].quantity").description("The quantity of the line item."),
                                                subsectionWithPath("products[].product").description("The product the line item relates to."),
                                                subsectionWithPath("_links").description("Links section."))
                                        .links(
                                                linkWithRel("self").ignored(),
                                                linkWithRel("order").description("Link to order the cart."))
                        )
                );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant