-
-
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
Templating Engine API and handlebars support #690
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
652358b
openapi-generator-api
119b662
templating engine adapters
f2e9184
-e templating engine CLI option
4699c64
adapt Generator to process Template with the passed TemplatingEngineA…
30cb6c4
add a MustacheEngineAdapter to the codegen in the unit tests
1d0a1af
force default MustacheEngineAdapter
30fbd73
copy api module in the root Dockerfile
585ec3b
rename the interfaces module to openapi-generator-core
148f043
rename getFullTemplate to getFullTemplateContents
7da8cc8
reinstate the processCompiler step in case of a MustacheEngineAdapter
3c1f18c
add processTemplatingEngine to CodegenConfig, to be overriden by Code…
387ba9d
multiple file extensions per templating engine adapter
8093822
docs touchup
1732281
Rename template engine method to compileTemplate
jimschubert 96dbb43
Initialize config-customized mustache compiler only once
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>openapi-generator-project</artifactId> | ||
<groupId>org.openapitools</groupId> | ||
<version>4.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>openapi-generator-core</artifactId> | ||
<name>openapi-generator-core</name> | ||
<url>https://github.com/openapitools/openapi-generator</url> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
...pi-generator-core/src/main/java/org/openapitools/codegen/api/TemplatingEngineAdapter.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,30 @@ | ||
package org.openapitools.codegen.api; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
/** | ||
* Each templating engine is called by an Adapter, selected at runtime | ||
*/ | ||
public interface TemplatingEngineAdapter{ | ||
|
||
/** | ||
* Compiles a template into a string | ||
* | ||
* @param generator From where we can fetch the templates content (e.g. an instance of DefaultGenerator) | ||
* @param bundle The map of values to pass to the template | ||
* @param templateFile The name of the template (e.g. model.mustache ) | ||
* @return the processed template result | ||
* @throws IOException an error ocurred in the template processing | ||
*/ | ||
String compileTemplate(TemplatingGenerator generator, Map<String, Object> bundle, | ||
String templateFile) throws IOException; | ||
|
||
/** | ||
* During generation, if a supporting file has a file extension that is | ||
* inside that array, then it is considered a templated supporting file | ||
* and we use the templating engine adapter to generate it | ||
* @return string array of the valid file extensions for this templating engine | ||
*/ | ||
String[] getFileExtensions(); | ||
} |
17 changes: 17 additions & 0 deletions
17
...penapi-generator-core/src/main/java/org/openapitools/codegen/api/TemplatingGenerator.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,17 @@ | ||
package org.openapitools.codegen.api; | ||
|
||
/** | ||
* interface to the full template content | ||
* implementers might take into account the -t cli option, | ||
* look in the resources for a language specific template, etc | ||
*/ | ||
public interface TemplatingGenerator { | ||
|
||
/** | ||
* 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); | ||
|
||
} |
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
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.
Again, also missing extension of the templating engine: