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

fix(openapi-typescript): include location in error messages #1999

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

patzick
Copy link

@patzick patzick commented Nov 12, 2024

Changes

  • improved error messages - added locations to help find the problem in schema
  • do not throw error on first problem - display all the problems with the schema before throwing an error - helps to find out how many things are broken in schema
  • repeated code moved to internal method, reused in both Validation and Bundling

Examples:

  • from ✘ Can't resolve $ref to ✘ Can't resolve $ref at #/components/schemas/Pet/properties/type
  • from Expected SchemaObject, received Array to Expected SchemaObject, received Array at #/components/schemas/someSchema

How to Review

Apart of more explicit error messages the only change is in not throwing the first problem, but rather display all the problems to help quickly fix them before the next run. This is not affecting the application flow, as the Error is still thrown right after problems are processed.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@patzick patzick requested a review from a team as a code owner November 12, 2024 17:55
Copy link

changeset-bot bot commented Nov 12, 2024

🦋 Changeset detected

Latest commit: a2f5dff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openapi-typescript Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kerwanp kerwanp added the openapi-ts Relevant to the openapi-typescript library label Nov 13, 2024
@patzick
Copy link
Author

patzick commented Nov 15, 2024

hey @kerwanp, can you review it or point me to the person who should review it? Would be nice to have this in the next patch version as debugging broken schemas is very hard without it :)

@kerwanp
Copy link
Contributor

kerwanp commented Nov 15, 2024

Hi @patzick, thanks for the contribution! I would take a look at it this weekend.

@patzick
Copy link
Author

patzick commented Nov 28, 2024

hey @kerwanp any chance to push this forward?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants