Skip to content

Commit 80600b6

Browse files
author
Ludovic Dussart
authored
feat: add version parameter to allow version override (#147)
1 parent d76e99e commit 80600b6

File tree

6 files changed

+30
-11
lines changed

6 files changed

+30
-11
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ npm install -g @asyncapi/generator
1717

1818
## Supported parameters
1919

20-
|Name|Description|Required|Allowed values|Example|
21-
|---|---|---|---|---|
22-
|sidebarOrganization|Defines how the sidebar should be organized. Set its value to `byTagsNoRoot` to categorize operations by operations tags. Set its value to `byTags` when you have tags on a root level. These tags are used to model tags navigation and need to have the same tags in operations.|No|`byTags`, `byTagsNoRoot`|`byTagsNoRoot`|
23-
|baseHref|Sets the base URL for links and forms.|No|*Any*|`/docs`|
24-
|singleFile|Set output into one html-file with styles and scripts inside|No|`true`,`false`|`true`|
25-
|outFilename|The filename of the output file.|No|*Any*|`asyncapi.html`|
26-
|pdf|Generates output HTML as PDF|No|`true,false`|`false`|
20+
|Name|Description|Required|Default|Allowed values|Example|
21+
|---|---|---|---|---|---|
22+
|sidebarOrganization|Defines how the sidebar should be organized. Set its value to `byTagsNoRoot` to categorize operations by operations tags. Set its value to `byTags` when you have tags on a root level. These tags are used to model tags navigation and need to have the same tags in operations.|No|undefined|`byTags`, `byTagsNoRoot`|`byTagsNoRoot`|
23+
|baseHref|Sets the base URL for links and forms.|No|`/`|*Any*|`/docs`|
24+
|version|Override the version of your application provided under `info.version` location in the specification file.|No|Version is taken from the spec file.|*Any* ([See Semver versionning](https://semver.org/))|`1.0.0`|
25+
|singleFile|Set output into one html-file with styles and scripts inside|No|`false`|`true`,`false`|`true`|
26+
|outFilename|The filename of the output file.|No|`index.html`|*Any*|`asyncapi.html`|
27+
|pdf|Generates output HTML as PDF|No|`false`|`true,false`|`false`|
2728

2829
If you only generate an html website, set the environment variable `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` to `true` and the generator will skip downloading chromium.
2930

macros/commons.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{% macro getApiVersion() %}
2+
{% if params.version %}
3+
{% set version = params.version %}
4+
{% else %}
5+
{% set version = asyncapi.info().version() %}
6+
{% endif %}
7+
<span>{{version}}</span>
8+
{% endmacro %}

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"description": "Sets the base URL for links and forms.",
8989
"required": false
9090
},
91+
"version": {
92+
"description": "Override the version of your application provided under `info.version` location in the specification file.",
93+
"required": false
94+
},
9195
"singleFile": {
9296
"description": "If set this parameter to true generate single html file with scripts and styles inside",
9397
"required": false,

partials/introduction.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
{% from "macros/commons.html" import getApiVersion with context %}
2+
13
<div class="center-block p-8">
24
<a name="introduction"></a>
3-
<h1>{{asyncapi.info().title()}} {{asyncapi.info().version()}}</h1>
5+
6+
<h1>{{asyncapi.info().title()}} {{getApiVersion()}}</h1>
47
<div class="leading-normal mb-4">
58
{% if asyncapi.info().termsOfService() %}
69
<a class="border border-solid border-purple-300 hover:bg-purple-300 hover:text-purple-600 font-bold no-underline text-purple-500 text-xs uppercase rounded mr-2 px-3 py-1"

partials/sidebar.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{% from "./sliced-string.html" import slicedString %}
2+
{% from "macros/commons.html" import getApiVersion with context %}
23

34
<input id="burger-menu" type="checkbox" />
45
<label for="burger-menu" class="shadow">
@@ -15,7 +16,7 @@
1516
<img src="{{ asyncapi.info().ext('x-logo') }}" alt="{{ asyncapi.info().title() }} logo">
1617
{% else %}
1718
<h1 class="text-2xl font-thin">
18-
{{ asyncapi.info().title() }} {{ asyncapi.info().version() }}
19+
{{ asyncapi.info().title() }} {{ getApiVersion() }}
1920
</h1>
2021
{% endif %}
2122
<ul class="text-sm mt-10 mt-2">
@@ -92,4 +93,4 @@ <h2 class="text-xs uppercase text-gray-500 mt-10 mb-4 font-thin">Messages</h2>
9293
</ul>
9394
{% endif %}
9495
</div>
95-
</div>
96+
</div>

template/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<!DOCTYPE html>
2+
{% from "macros/commons.html" import getApiVersion with context %}
23
<html lang="en">
34
<head>
45
<meta charset="UTF-8">
56
{% if params.baseHref %}
67
<base href="{{params.baseHref}}">
78
{% endif %}
8-
<title>{{asyncapi.info().title()}} {{asyncapi.info().version()}} documentation</title>
9+
10+
<title>{{asyncapi.info().title()}} {{getApiVersion()}} documentation</title>
911
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1012
{% if params.singleFile %}
1113
<style type="text/css">

0 commit comments

Comments
 (0)