Skip to content

Commit

Permalink
Merge pull request #27 from asyncapi/feature/add-events-support
Browse files Browse the repository at this point in the history
Add support for events in Markdown template
  • Loading branch information
fmvilas authored Jan 13, 2019
2 parents 90bbccd + 91c05ff commit 20c2954
Show file tree
Hide file tree
Showing 8 changed files with 920 additions and 10 deletions.
8 changes: 5 additions & 3 deletions lib/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ module.exports = (asyncapi) => {
beautifySchema(schema);
});

const commonPrefix = sharedStart(Object.keys(asyncapi.topics));
const levels = commonPrefix.split('.').length - 1;
asyncapi.__commonPrefix = commonPrefix.split('.').slice(0, levels).join('.');
if (asyncapi.topics) {
const commonPrefix = sharedStart(Object.keys(asyncapi.topics));
const levels = commonPrefix.split('.').length - 1;
asyncapi.__commonPrefix = commonPrefix.split('.').slice(0, levels).join('.');
}

return asyncapi;
};
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
},
"homepage": "https://github.com/asyncapi/generator",
"dependencies": {
"asyncapi": "^2.0.2",
"asyncapi": "^2.1.0",
"commander": "^2.12.2",
"fs.extra": "^1.3.2",
"handlebars": "^4.0.6",
"js-yaml": "^3.8.3",
"json-schema-ref-parser": "^5.1.0",
"lodash": "^4.17.4",
"markdown-it": "^8.4.1",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"openapi-sampler": "^1.0.0-beta.9",
"project-name-generator": "^2.1.5",
"z-schema": "^3.18.2",
"minimatch": "^3.0.4"
"z-schema": "^3.18.2"
},
"devDependencies": {}
}
6 changes: 6 additions & 0 deletions templates/markdown/.partials/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

{{> security}}

{{#if asyncapi.topics}}
{{> topics }}
{{/if}}

{{#if asyncapi.events}}
{{> events }}
{{/if}}

{{> messages}}

Expand Down
21 changes: 21 additions & 0 deletions templates/markdown/.partials/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## <a id="events"/>Events

### <a id="events-receive"/>Events a client can receive:
{{#each asyncapi.events.receive as |event index|}}
{{#if event.x-title}}
#### {{event.x-title}} {{#if event.deprecated}} (**deprecated**){{/if}}
{{else}}
#### Event #{{index}} {{#if event.deprecated}} (**deprecated**){{/if}}
{{/if}}
{{> message message=event hideTitle=true}}
{{/each}}

### <a id="events-send"/>Events a client can send:
{{#each asyncapi.events.send as |event index|}}
{{#if event.x-title}}
#### {{event.x-title}} {{#if event.deprecated}} (**deprecated**){{/if}}
{{else}}
#### Event #{{index}} {{#if event.deprecated}} (**deprecated**){{/if}}
{{/if}}
{{> message message=event hideTitle=true}}
{{/each}}
4 changes: 3 additions & 1 deletion templates/markdown/.partials/message.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### {{messageName}} {{#if message.deprecated}} (**deprecated**){{/if}}
{{#unless hideTitle}}
### {{messageName}} {{#if message.deprecated}} (**deprecated**){{/if}}
{{/unless}}
{{#if message.summary}}
{{{message.summary}}}

Expand Down
2 changes: 2 additions & 0 deletions templates/markdown/asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
{{/if}}
{{#if asyncapi.events}}
* [Events](#events)
- [Events a client can receive](#events-receive)
- [Events a client can send](#events-send)
{{/if}}
{{#if asyncapi.stream}}
* [Stream](#stream)
Expand Down
Loading

0 comments on commit 20c2954

Please sign in to comment.