Skip to content

Commit

Permalink
apiVersion field maps to Parser-API. If not present, old API will be …
Browse files Browse the repository at this point in the history
…used
  • Loading branch information
smoya committed May 4, 2023
1 parent e7656d4 commit cc43d87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/configuration-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `generator` property from `package.json` file must contain a JSON object tha
|Name|Type|Description|
|---|---|---|
|`renderer`| String | Its value can be either `react` or `nunjucks` (default).
|`apiVersion`| String | Determines which version of the [ParserJS](https://github.com/asyncapi/parser-js) API the template uses. Its value can be either `v2` or `v1` (default).
|`apiVersion`| String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v1` for `v1.x.x`. If not specified, the Generator assumes the template is not compatible with the [Parser-API](https://github.com/asyncapi/parser-api) so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). If the template uses a version of the [Parser-API](https://github.com/asyncapi/parser-api) that is not supported by the Generator, the Generator will throw an error.
|`supportedProtocols`| [String] | A list with all the protocols this template supports.
|`parameters`| Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`.
|`parameters[param].description`| String | A user-friendly description about the parameter.
Expand All @@ -28,7 +28,7 @@ The `generator` property from `package.json` file must contain a JSON object tha
"generator":
{
"renderer": "react",
"apiVersion": "v2",
"apiVersion": "v1",
"supportedProtocols": ["amqp", "mqtt"],
"parameters": {
"server": {
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parser.parse = (asyncapi, oldOptions, generator) => {
};

parser.usesNewAPI = (templateConfig = {}) => {
return templateConfig.apiVersion === 'v2';
return templateConfig.apiVersion === 'v1';
};

parser.getProperApiDocument = (asyncapiDocument, templateConfig) => {
Expand Down

0 comments on commit cc43d87

Please sign in to comment.