OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
I have an object with a two-dimensional array, and the inner array items may be floator integer. If I attempt to generate the go client code it will create a nested map instead.
GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" openapi-generator generate -i ../api/openapi.yaml -g go -o ../vendor/instana/openapi
Steps to reproduce
Create the client. (Bug is already apparent)
Invoke a service.
Note that JSON result cannot be mapped:
panic: json: cannot unmarshal number into Go struct field MetricItem.metrics of type map[string]interface {}
Related issues/PRs
Suggest a fix/enhancement
I would have to dive in, I assume that the problem lies in org.openapitools.codegen.languages. AbstractGoCodegen as it "overmatches" the object type. See typeMapping.put("object", "map[string]interface{}");
Description
I have an object with a two-dimensional array, and the inner array items may be
float
orinteger
. If I attempt to generate the go client code it will create a nested map instead.So instead of this:
I was hoping for this:
openapi-generator version
3.3.4
OpenAPI declaration file content or url
Command line used for generation
GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" openapi-generator generate -i ../api/openapi.yaml -g go -o ../vendor/instana/openapi
Steps to reproduce
Create the client. (Bug is already apparent) Invoke a service. Note that JSON result cannot be mapped:
panic: json: cannot unmarshal number into Go struct field MetricItem.metrics of type map[string]interface {}
Related issues/PRs
Suggest a fix/enhancement
I would have to dive in, I assume that the problem lies in
org.openapitools.codegen.languages. AbstractGoCodegen
as it "overmatches" the object type. SeetypeMapping.put("object", "map[string]interface{}");