Skip to content

Commit

Permalink
fix(oas): change how exclusiveMin & Max are handled (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendarearden authored Mar 23, 2023
1 parent cad26fc commit 4d14e4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/oas/transformers/schema/__tests__/schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ describe('translateSchemaObject', () => {
exclusiveMinimum: false,
exclusiveMaximum: false,
},
{
type: 'integer',
exclusiveMinimum: 2,
exclusiveMaximum: 10,
},
],
}),
).toStrictEqual({
Expand Down Expand Up @@ -89,6 +94,11 @@ describe('translateSchemaObject', () => {
minimum: 2,
maximum: 10,
},
{
type: 'integer',
exclusiveMinimum: 2,
exclusiveMaximum: 10,
},
],
});
});
Expand Down
4 changes: 3 additions & 1 deletion src/oas/transformers/schema/keywords/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ function createRangeConverter(
return schema => {
if (!(keyword in schema)) return;
const { [keyword]: value } = schema;
if (value !== true || typeof schema[valueKeyword] !== 'number') {
if (typeof value === 'number') {
return;
} else if (value !== true || typeof schema[valueKeyword] !== 'number') {
delete schema[keyword];
} else {
schema[keyword] = schema[valueKeyword];
Expand Down

0 comments on commit 4d14e4a

Please sign in to comment.