diff --git a/.gitignore b/.gitignore
index e4d93b73..b371351d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,3 +37,4 @@ compiled
/coverage
.ghpages-tmp
stats.json
+/nbproject
\ No newline at end of file
diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html
index c60b7a28..d0efd5e7 100644
--- a/lib/components/JsonSchema/json-schema.html
+++ b/lib/components/JsonSchema/json-schema.html
@@ -41,6 +41,19 @@
+
+
+
+
+ [{{idx}}]:
+
+
+
+
+
+
diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss
index f0d98758..78faa604 100644
--- a/lib/components/JsonSchema/json-schema.scss
+++ b/lib/components/JsonSchema/json-schema.scss
@@ -127,6 +127,12 @@ table {
font-family: monospace;
}
+.params-wrap.params-oneOf:before {
+ content: "oneOf [";
+ padding-top: 1em;
+ font-family: monospace;
+}
+
.params-wrap.params-array:before {
content: "Array [";
padding-top: 1em;
diff --git a/lib/components/SchemaSample/schema-sample.ts b/lib/components/SchemaSample/schema-sample.ts
index 79a533d2..6ba508b2 100644
--- a/lib/components/SchemaSample/schema-sample.ts
+++ b/lib/components/SchemaSample/schema-sample.ts
@@ -65,7 +65,12 @@ export class SchemaSample extends BaseComponent implements OnInit {
return;
}
try {
- sample = OpenAPISampler.sample(this.componentSchema, {
+ let schemaForSampler = this.componentSchema;
+ if (this.componentSchema.oneOf) {
+ schemaForSampler = this.componentSchema.oneOf[0];
+ }
+
+ sample = OpenAPISampler.sample(schemaForSampler, {
skipReadOnly: this.skipReadOnly
});
} catch(e) {
diff --git a/lib/services/schema-helper.service.ts b/lib/services/schema-helper.service.ts
index 4e1192d2..b6f73834 100644
--- a/lib/services/schema-helper.service.ts
+++ b/lib/services/schema-helper.service.ts
@@ -94,6 +94,20 @@ const injectors = {
injectTo._widgetType = 'object';
}
},
+ oneOf: {
+ check: (propertySchema) => propertySchema.oneOf,
+ inject: (injectTo, propertySchema = injectTo, propPointer) => {
+
+ injectTo._isTuple = true;
+ injectTo._displayType = '';
+ let itemsPtr = JsonPointer.join(propertySchema._pointer || propPointer, ['oneOf']);
+ for (let i=0; i < propertySchema.oneOf.length; i++) {
+ let itemSchema = propertySchema.oneOf[i];
+ itemSchema._pointer = itemSchema._pointer || JsonPointer.join(itemsPtr, [i.toString()]);
+ }
+ injectTo._widgetType = 'oneOf';
+ }
+ },
noType: {
check: (propertySchema) => !propertySchema.type,
inject: (injectTo) => {
@@ -110,7 +124,7 @@ const injectors = {
return (!propertySchema.properties || !Object.keys(propertySchema.properties).length)
&& (typeof propertySchema.additionalProperties !== 'object');
}
- return (propertySchema.type !== 'array') && propertySchema.type;
+ return (propertySchema.type !== 'array') && (propertySchema.type !== 'oneOf') && propertySchema.type;
},
inject: (injectTo, propertySchema = injectTo) => {
injectTo.isTrivial = true;
diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts
index 433d03a8..485d8a4b 100644
--- a/lib/services/schema-normalizer.service.ts
+++ b/lib/services/schema-normalizer.service.ts
@@ -13,6 +13,7 @@ interface Reference {
interface Schema {
properties: any;
allOf: any;
+ oneOf: any;
items: any;
additionalProperties: any;
}
@@ -36,6 +37,9 @@ export class SchemaNormalizer {
resolved = Object.assign({}, resolved);
AllOfMerger.merge(resolved, resolved.allOf);
}
+ if (resolved.oneOf) {
+ resolved.type = 'oneOf';
+ }
return resolved;
});
if (opts.resolved && !hasPtr) this._dereferencer.exit(ptr);
@@ -74,6 +78,11 @@ class SchemaWalker {
SchemaWalker.walkEach(obj.allOf, ptr, visitor);
}
+ if (obj.oneOf) {
+ let ptr = JsonPointer.join(pointer, ['oneOf']);
+ SchemaWalker.walkEach(obj.oneOf, ptr, visitor);
+ }
+
if (obj.items) {
let ptr = JsonPointer.join(pointer, ['items']);
if (Array.isArray(obj.items)) {