Skip to content
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

[BUG][GO] Invalid property type for free form object #3277

Closed
5 tasks done
shaxbee opened this issue Jul 3, 2019 · 3 comments · Fixed by #11802
Closed
5 tasks done

[BUG][GO] Invalid property type for free form object #3277

shaxbee opened this issue Jul 3, 2019 · 3 comments · Fixed by #11802

Comments

@shaxbee
Copy link
Contributor

shaxbee commented Jul 3, 2019

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?map[string]interface{}
Description

Free form object property yields map[string]map[string]interface{} where it should be map[string]interface{}

openapi-generator version

4.0.1

OpenAPI declaration file content or url
components:
  schemas:
    Response:
      type: object
      properties:
        payload:
          type: object
          additionalProperties: {}
Command line used for generation
openapi-generator-cli generate -i ../api.yaml -g go -o . -DpackageName=api -DwithGoCodegenComment
Steps to reproduce

Generate go client using given schema.

Suggest a fix

Tried changing getTypeDeclaration in AbstractGoCodegen.java to use ModelUtils.isFreeFormObject to no avail.
Also attempted changing template with no success.

@auto-labeler
Copy link

auto-labeler bot commented Jul 3, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@shaxbee shaxbee changed the title [BUG][GO] Description [BUG][GO] Invalid property type for free form object Jul 4, 2019
@grokify
Copy link
Member

grokify commented Aug 2, 2019

I've run into a similar issue where:

type: object results in a map[string]string when it should be a map[string]interface{}

@docwhat
Copy link

docwhat commented Feb 11, 2021

I was able to work around OP's issue by passing this flag to openapi-generator-cli:

--type-mappings=object=interface{}

(I would have thought I would have to pass type[string]interface{} but I guess not?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants