diff --git a/lib/components/ResponsesSamples/responses-samples.ts b/lib/components/ResponsesSamples/responses-samples.ts index e977b275..a7585d7d 100644 --- a/lib/components/ResponsesSamples/responses-samples.ts +++ b/lib/components/ResponsesSamples/responses-samples.ts @@ -3,7 +3,7 @@ import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core'; import { BaseComponent, SpecManager } from '../base'; import JsonPointer from '../../utils/JsonPointer'; -import { statusCodeType, getJsonLikeSample } from '../../utils/helpers'; +import { statusCodeType, getJsonLikeSample, getXmlLikeSample } from '../../utils/helpers'; function isNumeric(n) { @@ -11,8 +11,7 @@ function isNumeric(n) { } function hasExample(response) { - return ((response.examples && getJsonLikeSample(response.examples)) || - response.schema); + return response.schema || getXmlLikeSample(response.examples) || getJsonLikeSample(response.examples) } @Component({ diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html index b7791525..a13dbc78 100644 --- a/lib/components/SchemaSample/schema-sample.html +++ b/lib/components/SchemaSample/schema-sample.html @@ -12,7 +12,7 @@ - + diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts index 9ba5da9c..dc0fa3d3 100644 --- a/lib/utils/helpers.ts +++ b/lib/utils/helpers.ts @@ -142,7 +142,7 @@ export function isXmlLike(contentType: string): boolean { return contentType.search(/xml/i) !== -1; } -export function getJsonLikeSample(samples: Object) { +export function getJsonLikeSample(samples: Object = {}) { const jsonLikeKeys = Object.keys(samples).filter(isJsonLike); if (!jsonLikeKeys.length) { @@ -152,7 +152,7 @@ export function getJsonLikeSample(samples: Object) { return samples[jsonLikeKeys[0]]; } -export function getXmlLikeSample(samples: Object) { +export function getXmlLikeSample(samples: Object = {}) { const xmlLikeKeys = Object.keys(samples).filter(isXmlLike); if (!xmlLikeKeys.length) {