Repository navigation
fix: support content and OpenAPI keywords - #296
Open
MohitSAGAR11 wants to merge 2 commits into
Open
MohitSAGAR11 wants to merge 2 commits into
MohitSAGAR11 wants to merge 2 commits into
Conversation
The contentMediaType, contentEncoding, and contentSchema keywords are annotation-only, but they weren't registered, so any schema using them threw 'Encountered unsupported keyword'. Register them as annotations like the other annotation keywords. Closes hyperjump-io#294
The OpenAPI dialects use their own keyword URIs, so any schema using them threw 'Encountered unsupported keyword'. Register the annotation-only keywords (discriminator, example, externalDocs, nullable, xml) and teach the type/const/enum error handler about the OpenAPI 3.0 type keyword so it produces the same messages as the standard type keyword.
MohitSAGAR11
marked this pull request as ready for review
October 19, 2026 01:35
Author
|
Hi @jdesrosiers, thanks again for the quick reply on #294. While this PR is up, I wanted to check in: is there anything you'd like help with, or a direction you'd prefer I work toward? I'm happy to keep doing what I've been doing — finding and reporting issues, then opening a PR for the ones you approve — but I didn't want to assume. Let me know what would be most useful. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #294
Summary
A schema that uses a keyword the package doesn't know about makes
jsonSchemaErrorsthrowEncountered unsupported keyword .... This adds support for the keywords the standard dialects and the OpenAPI dialects can put in the AST.Content keywords (draft-07 and up)
contentMediaType,contentEncoding, andcontentSchemaare annotation-only, but they weren't registered. They're now registered as annotations, alongsidecomment,default,description, andexamples.OpenAPI keywords
The OpenAPI dialects define their own keyword URIs:
discriminator,example,externalDocs,xml, andnullable(OpenAPI 3.0) don't affect validation and are registered as annotations.typekeyword asserts types like the standardtypekeyword, so the type/const/enum error handler now recognizes it and produces the same messages (including thenulltype added bynullable).OpenAPI 3.1 and 3.2 reuse the same keyword URIs, so they're covered too.
Tests
src/test-suite/tests/content.json— the content keywords are annotations across draft-07, 2019-09, and 2020-12.src/openapi.test.js— OpenAPI 3.0/3.1/3.2typeassertions,nullable, annotation keywords, and annotation-only schemas.npm test(1338 passing),npm run lint, andnpm run type-checkall pass.