openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[Go] Go Client Code generation: customise location of the generated model files

Open gcatanese opened this issue 3 years ago • 7 comments

@antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04)

The changes allow specifying in which folder the model files should be placed during the code generation. The default location can be overridden by passing the sub-directory in the additional properties ie --additional-properties=modelFileFolder=model

How to validate the changes?

Generate models passing --additional-properties=modelFileFolder=model

Fix #12307

PR checklist

  • [x] Read the contribution guidelines.

  • [x] Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.

  • [x] Run the following to build the project and update samples:

    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    

    Commit all changed files.

  • [x] File the PR against the correct branch: master (6.0.1) (patch release), 6.1.x (breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)

  • [x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

gcatanese avatar Jun 04 '22 18:06 gcatanese

@wing328 circle-ci build is broken but I am not sure about the cause (my changes or maybe networking issue)

gcatanese avatar Jun 06 '22 09:06 gcatanese

@wing328 circle-ci build is broken but I am not sure about the cause (my changes or maybe networking issue)

@wing328 Please let me know (when you have time) if you have any idea/hint why the pipeline fails, and if this PR can be merged (or if further changes are necessary maybe?). Thank you.

gcatanese avatar Jun 14 '22 09:06 gcatanese

@gcatanese thanks for the PR. Instead of adding an option, what about using commands to move the model files to the new location after the code generation process completes?

wing328 avatar Jun 20 '22 02:06 wing328

@gcatanese thanks for the PR. Instead of adding an option, what about using commands to move the model files to the new location after the code generation process completes?

@wing328 thanks for the feedback. Sorry, I am not sure I understand the option you propose. Is there a different way to do this in openapi-generator? Or do you mean do that after the codegen? Can you please elaborate? Thanks

gcatanese avatar Jun 20 '22 07:06 gcatanese

I mean after the codegen. (not part of the openapi-generator process)

wing328 avatar Jun 20 '22 08:06 wing328

I think it is a useful customisation (flexibility), and to be honest I would see this very useful in other languages (lots of model files place in one sub-folder). Not only my idea, someone else created #12307

Indeed it can be done outside the openapi-generator responsibility, but since it generates the files it would be convenient to indicate the location

gcatanese avatar Jun 20 '22 09:06 gcatanese

@wing328 any further thoughts on this? I considered moving the models after the codegen, but next time I am re-generating from the specs (ie API upgrade with new/updated models) I would see the models again in the main folder (thus dropping the previous model folder and move the newly created ones). I still find it not great but if this is the expected behaviour please let me know and I can close the PR. Thanks for your time.

gcatanese avatar Sep 16 '22 10:09 gcatanese

@wing328 any further thought on this? The `python-nextgen' also creates a folder for the generated models, I find this useful and elegant. Let me know if this is PR is to be considered (I can rebase/resolve conflicts) or if I should instead close it. Thanks.

gcatanese avatar Jan 03 '23 11:01 gcatanese

please resolve the conflicts when you've time and i'll try to merge before the v6.3.0 release.

wing328 avatar Jan 30 '23 08:01 wing328

@wing328 Done

gcatanese avatar Jan 30 '23 15:01 gcatanese

FYI. submitted https://github.com/OpenAPITools/openapi-generator/pull/14580/commits/4f4c4d5d3b13b8c5013c31619f431214bbe6b7b3 with minor fix for Windows.

wing328 avatar Feb 01 '23 12:02 wing328