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] Unused imports "fmt" and "bytes" when generateMarshalJSON=false and generateUnmarshalJSON=false #20599

Open
raphoester opened this issue Feb 5, 2025 · 1 comment

Comments

@raphoester
Copy link

Description

The bug happens when running the Go generation with both generateUnmarshalJSON and generateMarshalJSON flags set to false.

Some of the resulting model files contain unused imports to bytes and fmt.
Unused imports are disallowed by the Go language, which results in the client being unable to compile

openapi-generator version

Version : openapi-generator-cli 7.12.0-SNAPSHOT
Commit : 9a9c108
Built: -999999999-01-01T00:00:00+18:00

OpenAPI declaration file content or url

https://api.reepay.com/openapi.json

Generation Details
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate \
		-i <ref> \
		-g go \
		-o /local/out \
		--additional-properties=generateMarshalJSON=false,generateUnmarshalJSON=false
Steps to reproduce

command above on any valid input

Related issues/PRs
Suggest a fix

I guess checking for unused imports after the generation, and then deleting them should do it

@raphoester
Copy link
Author

I have found a temporary fix : run goimports -w . to fix the broken imports.
But ideally the broken imports should not be in the generated files in the first place

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

1 participant