Skip to content

fix: support content and OpenAPI keywords - #296

Open
MohitSAGAR11 wants to merge 2 commits into
hyperjump-io:mainfrom
MohitSAGAR11:fix/content-keywords
Open

MohitSAGAR11 wants to merge 2 commits into
hyperjump-io:mainfrom
MohitSAGAR11:fix/content-keywords

Conversation

@MohitSAGAR11

@MohitSAGAR11 MohitSAGAR11 commented Oct 19, 2026 •

Copy link
Copy Markdown

Closes #294

Summary

A schema that uses a keyword the package doesn't know about makes jsonSchemaErrors throw Encountered 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, and contentSchema are annotation-only, but they weren't registered. They're now registered as annotations, alongside comment, default, description, and examples.

OpenAPI keywords

The OpenAPI dialects define their own keyword URIs:

  • The annotation-only keywords discriminator, example, externalDocs, xml, and nullable (OpenAPI 3.0) don't affect validation and are registered as annotations.
  • The OpenAPI 3.0 type keyword asserts types like the standard type keyword, so the type/const/enum error handler now recognizes it and produces the same messages (including the null type added by nullable).

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.2 type assertions, nullable, annotation keywords, and annotation-only schemas.

npm test (1338 passing), npm run lint, and npm run type-check all pass.

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 MohitSAGAR11 changed the title fix: register content keywords as annotations fix: support content and OpenAPI keywords Oct 19, 2026
@MohitSAGAR11
MohitSAGAR11 marked this pull request as ready for review October 19, 2026 01:35
@MohitSAGAR11

Copy link
Copy Markdown
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

No deployments
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.

contentMediaType, contentEncoding and contentSchema throw "unsupported keyword"

1 participant