Skip to content

Commit

Permalink
fix: int64 overflow issue to due precision issues (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanashapiro authored Oct 9, 2023
1 parent 9762cd2 commit 69d38ec
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"lodash.pickby": "^4.6.0",
"openapi3-ts": "^2.0.2",
"postman-collection": "^4.1.2",
"tslib": "^2.3.1",
"tslib": "^2.6.2",
"type-is": "^1.6.18"
},
"devDependencies": {
Expand Down
36 changes: 18 additions & 18 deletions src/oas/__tests__/__snapshots__/operation.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -90,8 +90,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -349,8 +349,8 @@ Array [
"schema": Object {
"$schema": "http://json-schema.org/draft-07/schema#",
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "number",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -450,8 +450,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -511,8 +511,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -771,8 +771,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -833,8 +833,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -1069,8 +1069,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down Expand Up @@ -1131,8 +1131,8 @@ Array [
},
"id": Object {
"format": "int64",
"maximum": 9223372036854776000,
"minimum": -9223372036854776000,
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer",
"x-stoplight": Object {
"explicitProperties": Array [
Expand Down
6 changes: 3 additions & 3 deletions src/oas/transformers/schema/__tests__/schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('translateSchemaObject', () => {
{
type: 'integer',
format: 'int64',
maximum: 2 ** 40,
maximum: Number.MAX_SAFE_INTEGER,
'x-stoplight': {
explicitProperties: ['type', 'format', 'maximum'],
},
Expand Down Expand Up @@ -139,8 +139,8 @@ describe('translateSchemaObject', () => {
{
type: 'integer',
format: 'int64',
minimum: 0 - 2 ** 63,
maximum: 2 ** 40,
minimum: Number.MIN_SAFE_INTEGER,
maximum: Number.MAX_SAFE_INTEGER,
'x-stoplight': {
explicitProperties: ['type', 'format', 'maximum'],
},
Expand Down
4 changes: 2 additions & 2 deletions src/oas/transformers/schema/keywords/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { Converter } from '../types';
const ranges = {
MIN_INT_32: 0 - 2 ** 31,
MAX_INT_32: 2 ** 31 - 1,
MIN_INT_64: 0 - 2 ** 63,
MAX_INT_64: 2 ** 63 - 1,
MIN_INT_64: Number.MIN_SAFE_INTEGER,
MAX_INT_64: Number.MAX_SAFE_INTEGER,
MIN_FLOAT: 0 - 2 ** 128,
MAX_FLOAT: 2 ** 128 - 1,
MIN_DOUBLE: 0 - Number.MAX_VALUE,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10373,6 +10373,11 @@ tslib@^2.0.0, tslib@^2.2.0, tslib@^2.3.1:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==

tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down

0 comments on commit 69d38ec

Please sign in to comment.