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] AnyOf causes compilation error for Go #10430

Closed
5 of 6 tasks
deliveroo-andreik opened this issue Sep 20, 2021 · 1 comment
Closed
5 of 6 tasks

[BUG][GO] AnyOf causes compilation error for Go #10430

deliveroo-andreik opened this issue Sep 20, 2021 · 1 comment

Comments

@deliveroo-andreik
Copy link

deliveroo-andreik commented Sep 20, 2021

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The generator produces broken code for anyOf

openapi-generator version

v5.2.1

OpenAPI declaration file content or url
Generation Details

generate
--global-property models
--global-property modelDocs=false
--additional-properties sourceFolder=dto,useOneOfDiscriminatorLookup=true
--model-package dto
--package-name dto
-i /local/docs/openapi.yaml
--generate-alias-as-model
-g go
-o /local/internal/server/rest

func (dst *WebhookEvent) UnmarshalJSON(data []byte) error {
	var err error
	// use discriminator value to speed up the lookup
	var jsonDict map[string]interface{}
	err := json.Unmarshal(data, &jsonDict) // <---- compilation error as err already declared in var
	if err != nil {
		return fmt.Errorf("Failed to unmarshal JSON into map for the discrimintor lookup.")
	}
}
Steps to reproduce
Related issues/PRs
Suggest a fix

fix the template and remove unnecessary colon

@andrewkav
Copy link
Contributor

fixed in #10431

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

No branches or pull requests

2 participants