Proper examples generation: fixes #43

This commit is contained in:
Roman Hotsiy 2016-05-29 20:26:20 +03:00
parent 61d9a42477
commit 4005d8f61b
4 changed files with 13 additions and 4 deletions

View File

@ -2,7 +2,7 @@
import { ElementRef } from '@angular/core';
import SchemaSampler from 'json-schema-instantiator';
import * as OpenAPISampler from 'openapi-sampler';
import { RedocComponent, BaseComponent, SchemaManager } from '../base';
import { JsonFormatter } from '../../utils/JsonFormatterPipe';
@ -36,7 +36,11 @@ export class SchemaSample extends BaseComponent {
sample = base.examples['application/json'];
} else {
this.dereference(this.componentSchema);
sample = SchemaSampler.instantiate(this.componentSchema);
try {
sample = OpenAPISampler.sample(this.componentSchema);
} catch(e) {
console.error('@@@@@@@@@@@@@@@@@@@' + e);
}
}
this.data.sample = sample;

View File

@ -65,6 +65,7 @@ pre {
}
.redoc-json {
overflow-x: auto;
padding: 20px;
border-radius: $border-radius*2;
background-color: darken($black, 2%);

View File

@ -43,9 +43,9 @@
"json": "github:systemjs/plugin-json@^0.1.0",
"json-formatter-js": "npm:json-formatter-js@^0.2.0",
"json-pointer": "npm:json-pointer@^0.3.0",
"json-schema-instantiator": "npm:json-schema-instantiator@^0.3.0",
"json-schema-ref-parser": "npm:json-schema-ref-parser@^3.1.2",
"marked": "npm:marked@^0.3.5",
"openapi-sampler": "npm:openapi-sampler@^0.1.2",
"prismjs": "npm:prismjs@^1.3.0",
"rxjs": "npm:rxjs@5.0.0-beta.6",
"scrollparent": "npm:scrollparent@^0.1.0",
@ -63,6 +63,10 @@
"overrides": {
"github:Robdel12/DropKick@2.1.7": {
"format": "global"
},
"npm:openapi-sampler@0.1.2": {
"main": "src/openapi-sampler",
"format": "esm"
}
}
},

View File

@ -53,9 +53,9 @@ System.config({
"json": "github:systemjs/plugin-json@0.1.2",
"json-formatter-js": "npm:json-formatter-js@0.2.0",
"json-pointer": "npm:json-pointer@0.3.0",
"json-schema-instantiator": "npm:json-schema-instantiator@0.3.0",
"json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2",
"marked": "npm:marked@0.3.5",
"openapi-sampler": "npm:openapi-sampler@0.1.2",
"prismjs": "npm:prismjs@1.3.0",
"rxjs": "npm:rxjs@5.0.0-beta.6",
"scrollparent": "npm:scrollparent@0.1.0",