diff --git a/lib/components/ResponsesSamples/responses-samples.html b/lib/components/ResponsesSamples/responses-samples.html
index 4c540c7b..c143b6e0 100644
--- a/lib/components/ResponsesSamples/responses-samples.html
+++ b/lib/components/ResponsesSamples/responses-samples.html
@@ -1,6 +1,6 @@
-
+
diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js
index dec82e39..41420127 100644
--- a/lib/components/ResponsesSamples/responses-samples.js
+++ b/lib/components/ResponsesSamples/responses-samples.js
@@ -10,6 +10,11 @@ function isNumeric(n) {
return (!isNaN(parseFloat(n)) && isFinite(n));
}
+function hasExample(response) {
+ return ((response.examples && response.examples['application/json']) ||
+ response.schema);
+}
+
@RedocComponent({
selector: 'responses-samples',
templateUrl: './lib/components/ResponsesSamples/responses-samples.html',
@@ -38,7 +43,8 @@ export class ResponsesSamples extends BaseComponent {
resp.code = respCode;
return resp;
- });
+ })
+ .filter(response => hasExample(response));
this.data.responses = responses;
}
}
diff --git a/lib/components/SchemaSample/schema-sample.html b/lib/components/SchemaSample/schema-sample.html
index 932df1bf..71a7b47c 100644
--- a/lib/components/SchemaSample/schema-sample.html
+++ b/lib/components/SchemaSample/schema-sample.html
@@ -1,4 +1,5 @@
-
Not supported yet (any-of)
+
+
Sample unavailable
{{data.sample | json}}
diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js
index 4f02294a..e10bd446 100644
--- a/lib/components/SchemaSample/schema-sample.js
+++ b/lib/components/SchemaSample/schema-sample.js
@@ -15,12 +15,20 @@ export class SchemaSample extends BaseComponent {
init() {
this.data = {};
+
+ // sometimes for some reason this method is called without resolved pointer
+ // TODO: fix it and remove the following workaround
if (!this.componentSchema || !this.pointer) {
- console.log(this.pointer);
return;
}
- this.dereference();
- let sample = SchemaSampler.instantiate(this.componentSchema);
+ let sample;
+ if (this.componentSchema.examples && this.componentSchema.examples['application/json']) {
+ sample = this.componentSchema.examples['application/json'];
+ } else {
+ this.dereference(this.componentSchema.schema);
+ sample = SchemaSampler.instantiate(this.componentSchema.schema);
+ }
+
this.data.sample = sample;
}
}