Skip to content

Conversation

@luke-hagar-sp
Copy link
Contributor

@luke-hagar-sp luke-hagar-sp commented Oct 24, 2025

Problem

Currently, …

Solution

With this PR …

Checklist

I've gone through the following:

  • I've added an explanation why this change is needed.
  • I've added a changeset (pnpm changeset).
  • I've added tests for the regression or new feature.
  • I've updated the documentation.

Note

Upgrades AJV and schemas to improve OpenAPI validation (incl. refs in paths) and delivers clearer, deduplicated errors with expanded tests.

  • Validator (src/lib/Validator/Validator.ts):
    • Add draft-07 support via Ajv; enable discriminator and allErrors options.
    • Pass full specification to transformErrors; refine error handling.
  • Schemas:
    • v2.0 (schemas/v2.0): allow paths entries to be oneOf pathItem or jsonReference.
    • v3.0 (schemas/v3.0): introduce PathItemOrReference and use it in Paths; add discriminator to SecurityScheme oneOf; clean up PathItem fields.
    • v3.1 (schemas/v3.1): use path-item-or-reference for paths.
    • v3.2 (schemas/v3.2): use path-item-or-reference across paths, webhooks, and component pathItems; add conditional path-item-or-reference and related structural updates.
  • Error handling:
    • types: extend ErrorObject with optional path.
    • betterAjvErrors: add oneOf/if/additionalProperties/unevaluatedProperties handling; smarter redundancy filtering.
    • transform-errors: guard invalid specs, try/catch fallback to raw AJV errors, format additionalProperties messages, deduplicate by message+path.
  • Tests (tests/openapi3-examples/3.0/fail/*):
    • Update expectations for new error messages, paths, and counts; skip overly noisy suite (openapi-vue).

Written by Cursor Bugbot for commit bb56d7e. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

⚠️ No Changeset found

Latest commit: bb56d7e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@luke-hagar-sp
Copy link
Contributor Author

Hello Scalar!

Big fan of the tooling you all are building here.

I'm looking to use some of the tools here on our API Specifications at SailPoint and I want to refine the error handling a bit and hopefully get some better output in certain situations, so I took a look at the underlying validation logic and I think I was able to make some good changes here.

Would anyone mind reviewing this PR?

If you are happy with these changes I have some additional changes/improvements in mind.

@hanspagel @marclave @geoffgscott

Copy link
Member

@marclave marclave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

passing to @geoffgscott @amritk @DemonHa to review :) but looks cool!

@amritk
Copy link
Member

amritk commented Oct 30, 2025

@marclave I believe @hanspagel is back! This is parser stuff

@hanspagel hanspagel changed the title feat: huge validator overhaul feat(openapi-parser): validator overhaul Nov 3, 2025
Copy link
Member

@hanspagel hanspagel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE

Actually, I‘d love to see a version that doesn’t use ajv somehow, and a functional approach. This was more or less copied from somewhere and has a bunch of flaws.

That said, your PR is a huge improvement over the status quo. 🙏

"requestBody1": {
"content": {
"application/json": {
"description": "Pet object that needs to be added to the store",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we remove those comments? 🤔

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions are invalid at these places in the document

Comment on lines -97 to +98
errors: transformErrors(entrypoint, validateSchema.errors),
errors: transformErrors(specification, validateSchema.errors),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we call it document?

I know, people refer to it as the "specification", but the specification is the actual standard, not the document (or definition).

@LukeHagar
Copy link

Great feedback!

I'll make some changes when I log on for the day

…idSchemaName.test.ts

Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
luke-hagar-sp and others added 2 commits November 3, 2025 09:21
…idPattern.test.ts

Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
…owNotFlows.test.ts

Co-authored-by: Hans Pagel <hanspagel@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

5 participants