Skip to content

Commit

Permalink
feat: handle booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
maxholman committed Dec 6, 2022
1 parent a969726 commit 0ba48ab
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/process-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,17 @@ export function registerTypesFromSchema(
typesAndInterfaces.set(`#/components/schemas/${schemaName}`, typeAlias);
}

// deal with boolean things
else if (schemaObject.type === 'boolean') {
const typeAlias = typesFile.addTypeAlias({
name: pascalCase(schemaName),
isExported: true,
type: withNullUnion('boolean', schemaObject.nullable),
});

typesAndInterfaces.set(`#/components/schemas/${schemaName}`, typeAlias);
}

// deal with arrays of refs
else if (schemaObject.type === 'array' && '$ref' in schemaObject.items) {
const iface = typesAndInterfaces.get(schemaObject.items.$ref);
Expand Down

0 comments on commit 0ba48ab

Please sign in to comment.