Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
When using an OAS 2.0 spec with a response that is an array of object, the generated code attempts to return a map[string]interface{}
which runs into an error when the array is unmarshaled.
OAS 2.0 results in the following method signature which attempts to return a map[string]interface{}
func (a *LocalesApiService) GetAllLocales(ctx context.Context) (map[string]interface{}, *http.Response, error) {
This results in the following error:
json: cannot unmarshal array into Go value of type map[string]interface {}
Using an OAS 3.0 spec works as expected. It returns a []Locale
as expected:
func (a *LocalesApiService) GetAllLocales(ctx context.Context) ([]Locale, *http.Response, error) {
openapi-generator version
4.1.0-SNAPSHOT, master branch
OpenAPI declaration file content or url
Non-working 2.0 spec: https://github.com/grokify/go-ringcentral-engage/blob/fd5a68df4d1612de69bed7e35c10ceb337a8da32/codegen/partial-specs_v2.0.0/openapi-spec_locales.json
Working 3.0 spec: https://github.com/grokify/go-ringcentral-engage/blob/fd5a68df4d1612de69bed7e35c10ceb337a8da32/codegen/partial-specs_v3.0.0/openapi-spec_locales.json
Command line used for generation
$ java -jar openapi-generator-cli.jar generate -i partial-specs_v3.0.0/openapi-spec_locales.json -g go -o engagedigital --package-name engagedigital
Steps to reproduce
Build a SDK against the linked specs.
Related issues/PRs
grokify/go-ringcentral-engage#2
Suggest a fix
Make it work like the OAS 3.0 spec.