Comments (6)
This seems to be a bug in the OpenAPI generation, the newInstance
operation should use the type Instance
and not InstanceWithCookies
.
from goa.
Thanks for the fix and explanations :)
from goa.
I also notice that returned (set) cookies are not documented in the openapi.
Maybe what we would need in this case, instead of defining (extend) a new type with cookies, which is a bit weird (and define a new type name), would be to be able to define Result as the combination of several things, in this case it would be 'Instance' + the cookie. It would kind of merge all these in an anonymous type.
But right now if I try to do this :
Method("newInstance2", func() {
Result(Instance, func() {
Attribute("cookie", String)
})
HTTP(func() {
POST("/instance2")
Response(StatusOK, func() {
Cookie("cookie")
CookieMaxAge(3600 * 24 * 365)
CookieSecure()
CookieHTTPOnly()
CookiePath("/")
})
})
})
I get this error : [design/test.go:45] can't define child attribute "cookie" on attribute of type Instance *expr.UserTypeExpr in attribute
from goa.
Yeah the above isn't valid DSL. Extend should work and would be the proper way to do what you want. For now though you could use your own function that defines the same attributes in two different types and add an additional cookie
attribute to the InstanceWithCookies
type.
from goa.
The example I provided also has in comment the method you suggest where I use a function instead of Extend, but this leads to the same bug, where only InstanceWithCookies is defined in the openapi.
from goa.
Thanks for the repro, this is fixed in #3379, a few things to note though:
- The fact that only one type is being generated is correct and by design. That is because the shape of the response bodies for both API endpoints are actually the exact same and Goa ensures that it won't create arbitrary schemas for types that are structurally identical.
Meta("openapi:typename")
can be used to override the name generated in the OpenAPI specification (Goa will use the name of the first type from which the body is derived by default). - The OpenAPI specification does not define a discrete attribute for cookies in responses (it does for cookies in requests). Instead official examples add the "Set-Coookie" header so this is what the PR linked above does.
from goa.
Related Issues (20)
- can't set cookie 'SameSite' attribute HOT 2
- How to get the native *http.Request from the payload? HOT 2
- Missing schemas in OpenAPI spec when using union types HOT 3
- Declare POST request contain an array of object HOT 2
- Bumping goa.design/plugins/v3 from 3.14.0 to 3.14.1 is causing my client generation to fail HOT 3
- Generated code for nested inline attributes doesn't compile HOT 2
- Deprecated Code in Generated http.go using goa example
- meta for externalDocs and deprecated? HOT 4
- Map as Query Param not working? HOT 2
- Using Param() to map path parameters to attributes results in a runtime error HOT 5
- Panic in main HOT 2
- Goa panics when query params have unclosed square brackets HOT 2
- Goa panics when a user provides an explicit `null` where a `Map` is expected, if it's a nested structure HOT 2
- Middleware in design? HOT 6
- Goa generating uncompilable code while using views on types that contain OneOf union type
- 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 1
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.