-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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] Refactor templating management #6357
Merged
jimschubert
merged 33 commits into
OpenAPITools:master
from
jimschubert:cleanup-template-management
May 30, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
636c4dd
[core] Refactor templating management
jimschubert d67d3d4
Fix javadoc errs
jimschubert 66f49b6
Tests for dry run file outputs
jimschubert 6a745de
Update API usage in Meta, test TemplateManager
jimschubert a1b23d9
Fix temp file in overwrite test.
jimschubert f3ccf3c
Wait on lastModified, lookup by filename in SpringCodegenTest
jimschubert 4c3c28e
Remove minimal update test from DefaultGenerator (dupe with TemplateM…
jimschubert bb804a4
Test DefaultGenerator + ignore file
jimschubert ecb985e
Move config.processOpenAPI in DefaultGenerator
jimschubert f970e7c
Clarify comment in GeneratorTemplateContentLocator
jimschubert 8062b77
Do not overwrite existing test files
jimschubert 048cc6e
Fix wrong use of libraries templateDirector (java)
jimschubert d5307f3
[samples] Regenerate
jimschubert e267159
Merge branch 'master' into cleanup-template-management
jimschubert edaa592
Fix handlebars extension usage, clean up Meta tasks
jimschubert ccbcf6f
Merge branch 'master' into cleanup-template-management
jimschubert ef4e835
Merge branch 'master' into cleanup-template-management
jimschubert 00ebf20
Merge branch 'master' into cleanup-template-management
jimschubert 5f6368c
Move FILES/VERSION metadata gen to private methods
jimschubert 9b046c2
Update kotlin-multiplatform gradle wrapper
jimschubert 8943146
Rename GraphQL .gitignore template
jimschubert d256cec
Log entire stacktrace in go sdk built by gradle in AppVeyor
jimschubert 33f89fd
Rename PHP .gitignore to gitignore
jimschubert 3ea7469
[samples] Regenerate
jimschubert bc86eea
[php] Rename .gitignore templates to gitignore
jimschubert e934bec
Use same classpath lookup in common locator
jimschubert 062b4d2
Merge branch 'master' into cleanup-template-management
jimschubert 8faa776
[samples] Regenerate
jimschubert e3dcb2f
Merge branch 'master' into cleanup-template-management
jimschubert ff91eec
Regenerate rust samples
jimschubert 9a982d4
[rust] Properly escape empty triple-braces
jimschubert 5166440
Merge branch 'master' into cleanup-template-management
jimschubert 2033a90
[samples] Regenerate
jimschubert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
...penapi-generator-core/src/main/java/org/openapitools/codegen/api/TemplatePathLocator.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.openapitools.codegen.api; | ||
|
||
/** | ||
* Provides means for searching for "actual" template location based on relative template file. | ||
*/ | ||
public interface TemplatePathLocator { | ||
/** | ||
* Get the full path to a relative template file. | ||
* | ||
* @param relativeTemplateFile Template file | ||
* @return String Full template file path | ||
*/ | ||
String getFullTemplatePath(String relativeTemplateFile); | ||
} |
56 changes: 56 additions & 0 deletions
56
.../openapi-generator-core/src/main/java/org/openapitools/codegen/api/TemplateProcessor.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.openapitools.codegen.api; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
|
||
/** | ||
* Interface for abstractions around writing templated data to a file. | ||
*/ | ||
public interface TemplateProcessor { | ||
/** | ||
* Writes data to a compiled template | ||
* | ||
* @param data Input data | ||
* @param template Input template location | ||
* @param target The targeted file output location | ||
* | ||
* @return The actual file | ||
*/ | ||
File write(Map<String, Object> data, String template, File target) throws IOException; | ||
|
||
/** | ||
* Write bytes to a file | ||
* | ||
* @param filename The name of file to write | ||
* @param contents The contents bytes. Typically this is a UTF-8 formatted string. | ||
* @return File representing the written file. | ||
* @throws IOException If file cannot be written. | ||
*/ | ||
File writeToFile(String filename, byte[] contents) throws IOException; | ||
|
||
/** | ||
* Allow a caller to mark a path as ignored with accompanying reason | ||
* | ||
* @param path The ignored path | ||
* @param context The reason for ignoring this path | ||
*/ | ||
void ignore(Path path, String context); | ||
|
||
/** | ||
* Allow a caller to mark a path as skipped with accompanying reason | ||
* | ||
* @param path The skipped path | ||
* @param context The reason for skipping this path | ||
*/ | ||
void skip(Path path, String context); | ||
|
||
/** | ||
* Allow a caller to mark a path having errored during processing with accompanying reason | ||
* | ||
* @param path The path which has caused an error | ||
* @param context The reason for the error | ||
*/ | ||
default void error(Path path, String context) { }; | ||
} |
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
26 changes: 26 additions & 0 deletions
26
...openapi-generator-core/src/main/java/org/openapitools/codegen/api/TemplatingExecutor.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.openapitools.codegen.api; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* interface to the full template content | ||
* implementers might take into account the -t cli option, | ||
* look in the resources for a generator specific template, etc | ||
*/ | ||
public interface TemplatingExecutor { | ||
/** | ||
* returns the template content by name | ||
* | ||
* @param name the template name (e.g. model.mustache) | ||
* @return the contents of that template | ||
*/ | ||
String getFullTemplateContents(String name); | ||
|
||
/** | ||
* Returns the path of a template, allowing access to the template where consuming literal contents aren't desirable or possible. | ||
* | ||
* @param name the template name (e.g. model.mustache) | ||
* @return The {@link Path} to the template | ||
*/ | ||
Path getFullTemplatePath(String name); | ||
} |
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 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 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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is now handled by template loading functionality, as that is not the responsibility of DefaultCodegen.