Skip to content

Commit

Permalink
(fix): openapi parser gets boolean values safely (#3937)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Jun 26, 2024
1 parent 2606813 commit a7b2f1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cli/openapi-parser/src/schema/convertSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { OpenAPIExtension } from "../openapi/v3/extensions/extensions";
import { FernOpenAPIExtension } from "../openapi/v3/extensions/fernExtensions";
import { getFernEnum } from "../openapi/v3/extensions/getFernEnum";
import { getFernTypeExtension } from "../openapi/v3/extensions/getFernTypeExtension";
import { getValueIfBoolean } from "../utils/getValue";
import { convertAdditionalProperties, wrapMap } from "./convertAdditionalProperties";
import { convertArray } from "./convertArray";
import { convertDiscriminatedOneOf, convertDiscriminatedOneOfWithVariants } from "./convertDiscriminatedOneOf";
Expand Down Expand Up @@ -296,8 +297,8 @@ export function convertSchemaObject(
_default: schema.default,
minimum: schema.minimum,
maximum: schema.maximum,
exclusiveMinimum: schema.exclusiveMinimum,
exclusiveMaximum: schema.exclusiveMaximum,
exclusiveMinimum: getValueIfBoolean(schema.exclusiveMinimum),
exclusiveMaximum: getValueIfBoolean(schema.exclusiveMaximum),
multipleOf: schema.multipleOf,
description,
wrapAsNullable,
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/openapi-parser/src/utils/getValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function getValueIfBoolean(value: unknown): boolean | undefined {
if (value != null && typeof value === "boolean") {
return value;
}
return undefined;
}

0 comments on commit a7b2f1d

Please sign in to comment.