Skip to content

Commit

Permalink
Type checking if schema property is not string (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmelian authored and magicmatatjahu committed Sep 17, 2019
1 parent 098a500 commit b73d44c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
41 changes: 30 additions & 11 deletions library/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions library/src/helpers/beautifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Beautifier {
const transformed: Record<string, Schema> = {};

for (const [key, property] of Object.entries(schema.properties)) {
if (typeof property !== 'object' || !property) {
continue;
}
if (property.allOf) {
transformed[key] = this.resolveAllOf(property) || property;
continue;
Expand Down Expand Up @@ -140,8 +143,10 @@ class Beautifier {

const newSchemas: Record<string, Schema> = {};
for (const [key, schema] of Object.entries(schemas)) {
newSchemas[key] = this.resolveAllOf(schema) || schema;
newSchemas[key] = this.beautifySchema(newSchemas[key]) || newSchemas[key];
if (typeof schema === 'object') {
newSchemas[key] = this.resolveAllOf(schema) || schema;
newSchemas[key] = this.beautifySchema(newSchemas[key]) || newSchemas[key];
}
}
return newSchemas;
}
Expand Down

0 comments on commit b73d44c

Please sign in to comment.