Skip to content

Commit

Permalink
Show x-enumNames where available
Browse files Browse the repository at this point in the history
Fixes mrin9#59
  • Loading branch information
andyrooger committed Jun 6, 2020
1 parent 6a8055c commit a0285cc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/object-tree-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export function getTypeInfo(schema) {

// Set the Type
if (schema.enum) {
let opt = '';
schema.enum.map((v) => {
opt += `${v}, `;
});
const opt = (schema['x-enumNames']
? schema.enum.map((val, idx) => `${val} (${schema['x-enumNames'][idx]})`)
: schema.enum
).join(', ');
info.type = 'enum';
info.allowedValues = opt.slice(0, -2);
info.allowedValues = opt;
} else if (schema.type) {
info.type = schema.type;
}
Expand All @@ -47,11 +47,11 @@ export function getTypeInfo(schema) {
info.arrayType = `${schema.type} of ${arraySchema.type}`;
info.default = arraySchema.default === 0 ? '0 ' : (arraySchema.default ? arraySchema.default : '');
if (arraySchema.enum) {
let opt = '';
arraySchema.enum.map((v) => {
opt += `${v}, `;
});
info.allowedValues = opt.slice(0, -2);
const opt = (arraySchema['x-enumNames']
? arraySchema.enum.map((val, idx) => `${val} (${arraySchema['x-enumNames'][idx]})`)
: arraySchema.enum
).join(', ');
info.allowedValues = opt;
}
} else if (schema.type === 'integer' || schema.type === 'number') {
if (schema.minimum !== undefined && schema.maximum !== undefined) {
Expand Down

0 comments on commit a0285cc

Please sign in to comment.