Skip to content

withResponseDefaults works but withRequestDefaults does not in kotlin #786

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

Closed
JogoShugh opened this issue Feb 17, 2022 · 1 comment
Closed
Labels
status: invalid Suggestion or bug report that we don't feel is valid

Comments

@JogoShugh
Copy link

Hello,
I thought the following would work to remove the string " - i " from the request snippet rendered as curl requests, but I'm thinking now that I would have to somehow post process the snippet instead. Is that possible?

Thanks!

    @BeforeEach
    fun setUp(webApplicationContext : WebApplicationContext,
              restDocumentation : RestDocumentationContextProvider) {
        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
            .apply<DefaultMockMvcBuilder?>(documentationConfiguration(restDocumentation)
                .uris()
                .withScheme("https")
                .withHost("site.tech")
                .withPort(443)
                .and()
                .operationPreprocessors()
                .withRequestDefaults(prettyPrint(),
                    replacePattern(Pattern.compile(" -i "), "")
                    )
                .and()
                .operationPreprocessors()
                .withResponseDefaults(prettyPrint())
            )
            .build()
    }
@wilkinsona
Copy link
Member

wilkinsona commented Feb 17, 2022

The request and response defaults are applied to the HTTP request and HTTP response. All this happens before any of the snippet generation is performed. It appears that what you are trying to do is to post-process the output of the curl snippet but what you have configured is pre-processing of the HTTP request before it's documented.

It sounds like what you'd like to be able to do is covered by #552. That issue also shows a workaround with a custom CurlRequestSnippet sub-class that removes the -i.

@wilkinsona wilkinsona added status: invalid Suggestion or bug report that we don't feel is valid and removed status: waiting-for-triage Untriaged issue labels Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid Suggestion or bug report that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants