-
-
Notifications
You must be signed in to change notification settings - Fork 342
feat!: remove nunjucks support and ag CLI
#1756
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
Open
derberg
wants to merge
35
commits into
asyncapi:master
Choose a base branch
from
derberg:nunjucksfinallygoesaway
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f0fc2bc
feat: remove nunjucks support
derberg d141638
Merge branch 'master' into nunjucksfinallygoesaway
derberg 45dbbd8
refactor
derberg 703d0a6
refresh lock
derberg e75afe6
Merge branch 'master' into nunjucksfinallygoesaway
derberg 02d7166
docs
derberg 1eae283
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg 26cf037
Update package-lock.json
derberg a5d6810
Update jest.config.js
derberg 2e7a403
Update apps/generator/docs/typescript-support.md
derberg 0c4d036
remove cli
derberg 886bc20
Delete migration-cli.md
derberg e5efa5b
changeset
derberg 090eee5
minor
derberg 2c7be47
Update .changeset/remove-deprecated-nunjucks-cli.md
derberg 925a5dd
remove watcher
derberg 112a5ab
isLocalTemplate removal
derberg fc946fa
Merge branch 'master' into nunjucksfinallygoesaway
derberg 9eaad55
make node 24 must have
derberg d20805c
update changeset
derberg 4f86da6
Merge branch 'master' into nunjucksfinallygoesaway
derberg 8bb9fd3
update workflows
derberg eca3b6c
Merge branch 'nunjucksfinallygoesaway' of https://github.com/derberg/…
derberg a6b11d6
silent security alrerts
derberg 8dc94c2
more nunjucks wipe
derberg adb550d
cleanup docker
derberg cd48cc5
update dev guide after local testing
derberg 32a5ce6
bump deps
derberg 57c32e1
Update apps/generator/docs/react-render-engine.md
derberg 9f9068e
Update apps/generator/docs/react-render-engine.md
derberg 1872ddd
Update integration.test.js.snap
derberg f53a520
Update integration.test.js.snap
derberg ae4ea24
Merge branch 'master' into nunjucksfinallygoesaway
derberg aeb9d42
Update remove-deprecated-nunjucks-cli.md
derberg b31c428
Apply suggestions from code review
derberg 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,67 +3,9 @@ title: "File templates" | |
| weight: 140 | ||
| --- | ||
|
|
||
| ## Generating files with the Nunjucks render engine | ||
|
|
||
| > **Note**: This section applies only to the Nunjucks render engine. For information on using the React render engine, refer to the [Generating files with the React render engine](#generating-files-with-the-react-render-engine) section below. | ||
|
|
||
| > **Note**: Nunjucks renderer engine is deprecated and will be removed in the future. Use the React renderer engine instead. For more details read notes from release [@asyncapi/[email protected]](https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0). | ||
|
|
||
| It is possible to generate files for each specific object in your AsyncAPI documentation using the Nunjucks render engine. For example, you can specify a filename like `$$channel$$.js` to generate a file for each channel defined in your AsyncAPI. The following file-template names and extra variables are available: | ||
|
|
||
| - `$$channel$$`, within the template-file you have access to two variables [`channel`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channel) and [`channelName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channels). Where the `channel` contains the current channel being rendered. | ||
| - `$$message$$`, within the template-file you have access to two variables [`message`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message) and [`messageName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message). Where `message` contains the current message being rendered. | ||
| - `$$schema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema). Where `schema` contains the current schema being rendered. Only schemas from [Components object](https://www.asyncapi.com/docs/reference/specification/latest#componentsObject) are used. | ||
| - `$$everySchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. Every [Schema object](https://www.asyncapi.com/docs/specifications/2.0.0/#schemaObject) from the entire AsyncAPI file is used. | ||
| - `$$objectSchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. All the [Schema objects](https://www.asyncapi.com/docs/reference/specification/latest#multiFormatSchemaObject) with type object is used. | ||
| - `$$parameter$$`, within the template-file you have access to two variables [`parameter`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameter) and [`parameterName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameters). Where the `parameter` contains the current parameter being rendered. | ||
| - `$$securityScheme$$`, within the template-file you have access to two variables [`securityScheme`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityscheme) and [`securitySchemeName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityschemes). Where `securityScheme` contains the current security scheme being rendered. | ||
|
|
||
| The file name will be equal to `*Name` variable. | ||
|
|
||
| ### Example | ||
|
|
||
| The file name is `$$schema$$.txt`, the content of this file is: | ||
| ``` | ||
| Schema name is '{{schemaName}}' and properties are: | ||
| {% for propName, prop in schema.properties() %} | ||
| - {{prop.uid()}} | ||
| {% endfor %} | ||
| ``` | ||
|
|
||
| With the following AsyncAPI: | ||
| ``` | ||
| components: | ||
| schemas: | ||
| peoplePayload: | ||
| type: object | ||
| properties: | ||
| event: | ||
| $ref: "#/components/schemas/people" | ||
| people: | ||
| type: object | ||
| properties: | ||
| id: | ||
| type: integer | ||
| ``` | ||
|
|
||
| The generator creates two files `peoplePayload.txt` and `people.txt` with the following content: | ||
| ``` | ||
| Schema name is 'peoplePayload' and properties are: | ||
| - people | ||
| ``` | ||
|
|
||
| and | ||
| ``` | ||
| Schema name is 'people' and properties are: | ||
| - id | ||
| ``` | ||
|
|
||
| > You can see an example of a file template that uses the Nunjucks render engine [here](https://github.com/asyncapi/template-for-generator-templates/tree/nunjucks/template/schemas). | ||
|
|
||
| ## Generating files with the React render engine | ||
|
|
||
| The above method of rendering **file templates** only works for the Nunjucks render engine. To use the React render engine, you need to follow a different approach. The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content. | ||
| The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content. | ||
|
|
||
| ### Example 1: Rendering hardcoded files | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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.
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.
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.
I don't want us to mention Nunjucks anymore, it is removed