Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error generating schema #16

Open
hermanbanken opened this issue Aug 16, 2022 · 2 comments
Open

Error generating schema #16

hermanbanken opened this issue Aug 16, 2022 · 2 comments

Comments

@hermanbanken
Copy link
Member

One of the dependencies (json-stringify-safe) throws an error when generating our schema. The error is:

Start generating files for custom schema: /project/json-schemas/schemas/schema.ts
/project/json-schemas/node_modules/json-stringify-safe/stringify.js:5
  return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces)
              ^
RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at stringify (/project/json-schemas/node_modules/json-stringify-safe/stringify.js:5:15)
    at /project/json-schemas/node_modules/json-schema-to-typescript/dist/src/optimizer.js:34:204
    at baseUniq (/project/json-schemas/node_modules/lodash/lodash.js:4338:35)
    at Function.uniqBy (/project/json-schemas/node_modules/lodash/lodash.js:8482:40)
    at optimize (/project/json-schemas/node_modules/json-schema-to-typescript/dist/src/optimizer.js:34:35)
    at /project/json-schemas/node_modules/json-schema-to-typescript/dist/src/optimizer.js:18:86
    at Array.map (<anonymous>)
    at Object.optimize (/project/json-schemas/node_modules/json-schema-to-typescript/dist/src/optimizer.js:18:36)
    at Object.<anonymous> (/project/json-schemas/node_modules/json-schema-to-typescript/dist/src/index.js:159:45)

Just reporting this here, before I dive deeper into the issue.

@hermanbanken
Copy link
Member Author

hermanbanken commented Aug 16, 2022

Removing node_modules/json-schema-to-typescript/dist/src/optimizer.js from running (direct return via return ast at the top), both makes the generation nearly instant, as fixes the issue... but no idea what isn't done then...

@hermanbanken
Copy link
Member Author

Updating json-schema-to-typescript to v11 seems to fix the issue, and seems to have no further downsides/impact on our code generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant