-
-
Notifications
You must be signed in to change notification settings - Fork 559
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
Using Param() to map path parameters to attributes results in a runtime error #3462
Comments
Just a note that there is indeed a bug in that Goa should never panic. That being said the correct DSL here would be: var _ = Service("products", func() {
Description("The product service provides an API for managing products.")
HTTP(func() {
Path("/products")
})
// update product by id
Method("update by id", func() {
Payload(UpdateProductPayload)
Result(UpdateProductPayload, func() {
View("default")
})
Error("no_criteria", String, "Missing criteria")
Error("no_match", String, "No product found with specified id")
HTTP(func() {
POST("/{id}")
Response(StatusOK)
Response("no_criteria", StatusBadRequest)
Response("no_match", StatusNotFound)
})
})
})
|
So as I understand your answer, it is not possible to map a path param element name to an attribute name like it is possible for query, header or body elements? |
Yes you are correct, the name of the path param needs to match the name of the attribute. The idea is that the name of the path params should not affect how clients build requests. I am curious to understand the use case for wanting to use a different name for the path param than the name of the attribute? |
I saw the http element mapping of header, body and query elements on https://goa.design/design/http_mapping/ and simply tried to use it with path parameters. My intention was to use a speaking route like |
That's fair, it does set the expectation. I guess the one place where that might matter is in the generated OpenAPI specification. I'm reopening the issue so we can add this feature. |
Hi, I'm new to goa and I want to map a path param e.g. product_id to a payload attribute id.
My design:
Service:
Payload Model:
Generating the code results in:
The text was updated successfully, but these errors were encountered: