Skip to content

[Bug] Golang generator should use tags as package names #9500

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

Open
5 of 6 tasks
wtrocki opened this issue May 17, 2021 · 2 comments
Open
5 of 6 tasks

[Bug] Golang generator should use tags as package names #9500

wtrocki opened this issue May 17, 2021 · 2 comments

Comments

@wtrocki
Copy link
Contributor

wtrocki commented May 17, 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

Golang generator should generate multiple packages similar to java operator.
Package should be based on the tags:

Currently generating open API for golang will end up with errors related to duplicates.
For example generating this API will create +30 errors in methods and structs duplication:
https://github.com/Apicurio/apicurio-registry/blob/2.0.0.Final/app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json#L2952-L2983

openapi-generator version

master and 5.1.1

OpenAPI declaration file content or url

https://github.com/Apicurio/apicurio-registry/blob/2.0.0.Final/app/src/main/resources-unfiltered/META-INF/resources/api-specifications/registry/v2/openapi.json

Generation Details
openapi-generator-cli generate -i openapi.json -g go --package-name srsdata -p="generateInterfaces=true" -o ./api
Steps to reproduce
  1. Generate API from spec
  2. Generated code will not compile because of many duplicated elements
Suggest a fix

After checking implementation I think there is reasonable way to fix it:

I'm happy contribute this change considering it is something that is valid for golang and openapi gen community.

@wtrocki wtrocki changed the title [Bug] Golang [Bug] Golang generator should use tags as package names May 17, 2021
@wtrocki
Copy link
Contributor Author

wtrocki commented May 17, 2021

See also: #1931

@wtrocki
Copy link
Contributor Author

wtrocki commented Aug 27, 2023

I think api files can easily be moved to the tags but for models that will cause number of issues:
Models reused across the packages will likely need to be redeclared or declared using reusable package

Fix here should enable api files to be saved in the separate folder with subfolders for tag names (property based)

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