Repository navigation
fix: support content and OpenAPI keywords - #296
MohitSAGAR11 wants to merge 3 commits into
Conversation
|
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. |
jdesrosiers
left a comment
There was a problem hiding this comment.
Look good so far. Please move openapi.test.js to use the JSON-based test suite.
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.
4292229 to
aedf6c5
Compare
|
Thanks! I moved the OpenAPI tests to the JSON test suite and removed
I also rebased on main. If you'd prefer the OpenAPI tests organized differently, let me know and I'll change it. |
|
@jdesrosiers just a gentle ping on this one. I moved the OpenAPI tests into the JSON test suite like you asked. Let me know if you'd like anything changed. |
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.