-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
[core][feature] User custom added templates #7366
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This allows encapsulation of SupportingFile properties rather than direct field access. TemplateDefinition will be used as the base to allow for different types of supporting file extensions.
Users would previously be forced to extend their target generator and go through more complicated customization steps just to add new files to generated output. This adds support for user-defined templates. Users can now: * add supporting files that aren't referenced in the target generator * include additional templates for api/model and their docs and templates * modify file extensions/suffixes for api/model (docs+tests) Notes on the new feature: * This is currently a "merge" operation. Existing definitions will be overwritten, but other template definitions will be untouched. This allows users to add files by default. * To modify generated suffixes/extensions for others (not supporting files), may require inspection of source to exactly match the map key used in the target generator. e.g. "model_doc.mustache", "Doc.md" would output DogDoc.md. If the target generator includes "model_doc.mustache" and user passes "model-doc.mustache", this will result in duplicate docs being generated. We don't currently have a mechanism in place to inspect these.
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
This removes TemplateFile and roles the type enum property into TemplateDefinition.
FYI. DroneCI reports the following errors:
|
@wing328 I've fixed those if you want to review. |
This is a fantastic feature! |
This is definitely cool feature, which will save lot of time and flexibility for users, without having to add custom generators. |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Users would previously be forced to extend their target generator and go
through more complicated customization steps just to add new files to
generated output.
This adds support for user-defined templates.
Users can now:
templates
Notes on the new feature:
overwritten, but other template definitions will be untouched. This
allows users to add files by default.
files), may require inspection of source to exactly match the map key
used in the target generator. e.g. "model_doc.mustache", "Doc.md"
would output DogDoc.md. If the target generator includes
"model_doc.mustache" and user passes "model-doc.mustache", this will
result in duplicate docs being generated. We don't currently have a
mechanism in place to inspect these.
See customization.md changes in this PR for full details. A quick example:
Modifying
bin/configs/kotlin.yaml
with the above, we can define the following files:.bak/kotlin-templates/AUTHORS.md
(not included in the Kotlin generator).bak/kotlin-templates/libraries/jvm-okhttp/api_interfaces.mustache
(not included in the Kotlin generator)The above will generate an
AUTHORS.md
, a user customized interface output for each API type generated, and will change the file suffix for the built-in api.mustache from.kt
toImpl.kt
.Full output tree of the above config would look like this:
Note the
AUTHORS.md
and types/files under packageorg.openapitools.client.apis
.cc @OpenAPITools/generator-core-team
Potential breaking change:
This encapsulates properties of SupportingFiles. For users consuming programmatically via Java, this will require updating direct field accessors to getter/setters; Kotlin users consuming programmatically will be unaffected.
PR checklist
./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master