Skip to content

Commit 4b330b4

Browse files
committed
fixes #211 and passes proper selected response code to api-response component in view mode
1 parent ba95238 commit 4b330b4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/templates/endpoint-template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function endpointBodyTemplate(path) {
9191
schema-style="${this.schemaStyle}"
9292
schema-expand-level = "${this.schemaExpandLevel}"
9393
schema-description-expanded = "${this.schemaDescriptionExpanded}"
94-
selected-status = "${Object.keys(path.responses)[0]}"
94+
selected-status = "${Object.keys(path.responses || {})[0] || ''}"
9595
> </api-response>
9696
</div>
9797
</div>`;

src/utils/schema-utils.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ export function getTypeInfo(schema) {
8181
}
8282

8383
export function getSampleValueByType(schemaObj) {
84-
if (schemaObj.example) {
85-
return schemaObj.example;
86-
}
84+
if (schemaObj.example === '') { return ''; }
85+
if (schemaObj.example === null) { return null; }
86+
if (schemaObj.example === 0) { return 0; }
87+
if (schemaObj.example) { return schemaObj.example; }
88+
8789
if (Object.keys(schemaObj).length === 0) {
8890
return null;
8991
}
@@ -476,7 +478,6 @@ export function generateExample(examples, example, schema, mimeType, includeRead
476478
deprecated: true,
477479
},
478480
);
479-
480481
finalExamples.push({
481482
exampleId: 'Example',
482483
exampleSummary: '',

0 commit comments

Comments
 (0)