Skip to content

Commit ba8e102

Browse files
authored
Merge pull request #9801 from swagger-api/html_generator_example_issue
show example on html and html2 generators
2 parents 31e7ea9 + f521a9e commit ba8e102

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@
171171
<div class="param-enum-header">Enum:</div>
172172
{{#_enum}}<div class="param-enum">{{this}}</div>{{/_enum}}
173173
{{/isEnum}}
174+
{{#example}}
175+
<div class="param-desc"><span class="param-type">example: {{example}}</span></div>
176+
{{/example}}
174177
{{/vars}}
175178
</div> <!-- field-items -->
176179
</div>

modules/swagger-codegen/src/main/resources/htmlDocs2/js_jsonschemaview.mustache

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ var JSONSchemaView = (function () {
225225
return this.element;
226226
}
227227
228+
if (this.schema && this.schema.example) {
229+
var exampleDiv = document.createElement('div');
230+
exampleDiv.innerHTML = '<div style="display: block" class="example">\n <span style="color: #808080" class="name">example: ' + this.schema.example + '</span>\n </div>';
231+
this.element.appendChild(exampleDiv.querySelector('.example'));
232+
}
233+
228234
if (!this.isCollapsed) {
229235
this.appendChildren(this.element);
230236
}

0 commit comments

Comments
 (0)