-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
how to return an existing type plus additional cookies ? #3367
Comments
This seems to be a bug in the OpenAPI generation, the |
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 : |
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 |
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. |
Thanks for the repro, this is fixed in #3379, a few things to note though:
|
Thanks for the fix and explanations :) |
Here's an example design :
I define 'Instance' type, which is returned by a 'newInstance' and 'listInstances', but I want 'newInstance' to also define a cookie. So I derived a type InstanceWithCookies from 'Instance', however things don't happen as expected, only 'InstanceWithCookies' is defined and used in the resulted generated code and openapi, which is weird.
Is there another way to return some existing type + cookies without deriving a new type ?
The text was updated successfully, but these errors were encountered: