Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3395
Closed
Open
Issue created Jul 19, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][Golang][Client] Response JSON array of object not handled in spec 2.0 but works in spec 3.0

Created by: grokify

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

https://github.com/grokify/go-ringcentral-engage/issues/2

Suggest a fix

Make it work like the OAS 3.0 spec.

Assignee
Assign to
Time tracking