Comments (5)
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.
from goa.
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)
})
})
})
Param
defines query string parameters so in the original DSL the id
field gets mapped twice - once in the HTTP route and once as a query string parameter. So Param
should be removed and instead the mapping done within the route definition (POST("/{id}")
).
from goa.
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?
from goa.
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?
from goa.
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 /users/{user_id}/products/{product_id}
instead of using /users/{id}/products/{product_id}
while having a consistent schema for my structs by having them all have an id
parameter regardless of whether it is a user, product or is something else.
from goa.
Related Issues (20)
- Goa generating invalid code when OneOf types is a user defined type
- Example generation failed in the latest version HOT 3
- Generated server code parses query parameters repeatedly HOT 1
- Getting the Raw Query? HOT 1
- Allow implementing `io.WriterTo` for `SkipResponseBodyEncodeDecode` responses. HOT 3
- generated cli: expected type, found newline HOT 4
- `CollectionOf()` + `View()` leading to unknown attribute errors. HOT 4
- `Return(ResultType)` + `Meta("struct:pkg:path", "path")` leads to some broken return types in gen/**/service.go. HOT 1
- go.mod shouldn't specify Go patch version HOT 1
- OpenAPI schema for `Any` DSL type assumes nested serialization into a string HOT 7
- Unexpected OpenAPI specification when using CollectionOf() + View() in Attribute HOT 1
- Incorrect code generation for GoaErrorName() function for custom error types HOT 6
- goa gen example issue HOT 1
- SIGSEGV when generating design HOT 2
- ConvertTo or CreateForm with constructor, factory or builder? HOT 2
- goa CLI panics when run without any args
- Dependency issue v3.19.0 / google.golang.org/grpc 1.66.1 HOT 1
- version 3.19.0 break openapi generation HOT 3
- OpenAPI generating incorrect requestBody example
- Using Meta to Specify time.Time Type Causes Code Generation Error HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goa.