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

added useFqn parameter to generate fully qualified model class names (Java) #1002

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

frode-carlsen
Copy link

@frode-carlsen frode-carlsen commented Dec 28, 2021

This resolves #1001 by adding an additional property useFqn that will take the assigned schema name as the basis for the generated package namespace of the model files. Any modelPackage already set (or default io.swagger.model) will be prepended to the package namespace.

@frode-carlsen
Copy link
Author

frode-carlsen commented Dec 28, 2021

This currently only supports the generated Java code, but could relatively easily be extended to the other language templates.

As an asside, a couple of refactorings ought be done to swagger-codegen to improve this. If this seems a viable PR then I'd be happy to submit a PR for that too:

  • DefaultGenerator#processModels only processes one model at a time atm. The templates are complicated to support multiple models when only one is present at a time. Propose simplifying this method signature to only take one definition at a time if possible
  • I've reused CodegenModel#xmlNamespace field for this case to better support generated import statement. This should be generalized in swagger-codegen to a namespace field or similar

@frode-carlsen frode-carlsen changed the title added useFqn parameter to generate fully qualified model class names (Java) (#1001) Resolves #1001: added useFqn parameter to generate fully qualified model class names (Java) Dec 28, 2021
@frode-carlsen frode-carlsen changed the title Resolves #1001: added useFqn parameter to generate fully qualified model class names (Java) added useFqn parameter to generate fully qualified model class names (Java) (resolves #1001) Dec 28, 2021
@frode-carlsen frode-carlsen changed the title added useFqn parameter to generate fully qualified model class names (Java) (resolves #1001) added useFqn parameter to generate fully qualified model class names (Java) Jan 4, 2022
@frode-carlsen
Copy link
Author

@frantuma @HugoMario would it be possible to get feedback on this PR? This would be very helpful for generating code from larger OpenAPI specs.

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

Successfully merging this pull request may close these issues.

Support for generating qualified model package/namespace
1 participant