-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[go] map type object *interface{} convert problem #51
Comments
@ilk thanks for creating the issue. May I know if you can also share a spec to more easily reproduce the issue? When using |
For example: ...
"Provider" : {
"type" : "object",
"properties" : {
"Foobar" : {
"type" : "object",
"description" : "Foobar-specific configuration object"
},
... Results to: type Provider struct {
Foobar *interface{}
...
} Better would be: type Provider struct {
Foobar map[string]interface{}
...
} |
@ilk @wing328 I agree with ilk's assessment and would appreciate this change too. It'll make the go client more Go-like:
|
Not sure the reason for the string key? Wouldn't the object be a model (one
of many possible structs).
…On Tue, May 15, 2018, 11:23 William Cheng ***@***.***> wrote:
@louis77 <https://github.com/louis77> thanks for the feedback.
cc @antihax <https://github.com/antihax> @bvwells
<https://github.com/bvwells>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#51 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGqJ24U0kSX0NXn_M1F_Q4P85P6lP4FYks5tyvMHgaJpZM4T_s36>
.
|
@antihax Which works properly if definitions are used in the OpenAPI Spec. However, arbitrary inline objects are currently represented as *interface{}'s. To use @ilk 's example, |
This looks OK in this instance. However it would end up as map[string]string as we cannot determine types on an arbitrary structure? |
The This is now changed to: So it'll always end up as a map[string]interface{}, there is no further logic involved. In a next release we could think about generating an |
Is it correct to say that the proposed change will also work with XML payload (since Go client supports the "withXML" option) ?
|
…r-2.x chore(deps): update dependency prettier to v2.1.2
Description
Definition property "type": "object" gets converted to *interface{} which returns an error when set to a struct or pointer pointer.
openapi-generator version
3.0.0
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Instead of an *interface{} map the object to map[string]interface{}
The text was updated successfully, but these errors were encountered: