Skip to content
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

Support for named path parameters #1939

Open
jarekkar opened this issue Sep 17, 2023 · 2 comments
Open

Support for named path parameters #1939

jarekkar opened this issue Sep 17, 2023 · 2 comments

Comments

@jarekkar
Copy link

Describe the bug

I have a technical question regarding my usage of the Spring Cloud Contract and Spring Rest Docs projects. So far, everything has been functioning as anticipated. However, I'm now looking to generate snippets for path parameters, specifically for a path like /movies/123. When I attempt this, Spring Rest Docs raises an error: "Snippet Path parameters with the following names were not found in the request: [movieId]." This error makes sense because I haven't named the path parameter in the URL definition.

My question is whether it's possible to provide such information within Spring Cloud Contract, which is written in Groovy?

Sample

Contract

package contracts.web

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    name("fetch_a_movie")
    description("Should fetch a movie")
    request {
        method GET()
        url "/movies/${anyUuid()}" // /movie/{movieId}
    }
    response {
        status OK()
        headers {
            contentType(applicationJson())
        }
        body("""
        {
            "title": "${anyNonBlankString()}"
        }
        """)
    }
}

Rest Docs

RequestDocumentation.parameterWithName("movieId").description("Movie id");
@jarekkar
Copy link
Author

jarekkar commented Nov 7, 2023

Hi Team

Just a gentle reminder about this issue. I understand you're all busy, but I'm eagerly awaiting any updates. If there's any way I can assist or provide more information, please let me know.

Looking forward to your response.

@marcingrzejszczak
Copy link
Contributor

We have the metadata section that could be reused to allow you add additional information (https://docs.spring.io/spring-cloud-contract/reference/project-features-contract/common-top-elements.html#contract-dsl-metadata). We could have the restdocs entry there that would allow making additional mappings. WDYT?

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

No branches or pull requests

3 participants