Skip to content

Commit 91a2ca4

Browse files
committed
Add support for multiple examples on request bodies and body parameters
1 parent 997ac55 commit 91a2ca4

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{#if example}}
2+
##### Example
3+
4+
{{#if summary}}> {{{summary}}}{{/if}}
5+
6+
{{#if description}}{{{description}}}{{/if}}
7+
8+
```json
9+
{{{stringify example}}}
10+
```
11+
{{else}}
12+
{{#if generatedExample}}
13+
##### Example _(generated)_
14+
15+
```json
16+
{{{stringify generatedExample}}}
17+
```
18+
{{/if}}
19+
{{/if}}

templates/markdown/.partials/operation.md

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,13 @@
1414
###### {{contentTypeName}}
1515
{{> schema schema=schema schemaName='body' hideTitle=true hideExamples=true}}
1616

17-
{{#if schema.example}}
18-
##### Example
19-
20-
```json
21-
{{{stringify schema.example}}}
22-
```
23-
{{else}}
24-
{{#if schema.generatedExample}}
25-
##### Example of payload _(generated)_
26-
```json
27-
{{{stringify schema.generatedExample}}}
28-
```
29-
{{/if}}
17+
{{> example example=schema.example generatedExample=schema.generatedExample }}
18+
{{#if examples}}
19+
{{#each examples as |example exampleName|}}
20+
{{> example example=example.value description=example.description}}
21+
{{/each}}
3022
{{/if}}
23+
3124
{{/each}}
3225
{{/if}}
3326

@@ -36,20 +29,13 @@
3629
#### Request body
3730
{{> schema schema=../schema schemaName='body' hideTitle=true hideExamples=true}}
3831

39-
{{#if ../example}}
40-
##### Example
41-
42-
```json
43-
{{{stringify ../example}}}
44-
```
45-
{{else}}
46-
{{#if ../generatedExample}}
47-
##### Example of payload _(generated)_
48-
```json
49-
{{{stringify ../generatedExample}}}
50-
```
51-
{{/if}}
32+
{{> example example=schema.example generatedExample=schema.generatedExample }}
33+
{{#if ../examples}}
34+
{{#each ../examples as |example exampleName|}}
35+
{{> example example=example.value description=example.description}}
36+
{{/each}}
5237
{{/if}}
38+
5339
{{/equal}}
5440
{{/each}}
5541

0 commit comments

Comments
 (0)