Repository navigation
Fix SchemaParameter.schema type in openapi-3-1 (OasSchema32 -> OasSchema31) - #137
Open
tarunagnihotri534 wants to merge 1 commit into
Open
tarunagnihotri534 wants to merge 1 commit into
tarunagnihotri534 wants to merge 1 commit into
Conversation
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.
Summary
Fixes a typing error in
openapi-3-1/index.d.tswhereSchemaParameter.schemawas typed asOasSchema32instead ofOasSchema31.Root Cause
SchemaParameterwas copied over fromopenapi-3-2/index.d.tsin commit a52c3d0 ("OpenApi type improvements") and the schema type was never switched back to the 3.1 one.OasSchema32isn't declared or imported inopenapi-3-1/index.d.ts, so anyone type-checking declaration files withskipLibCheck: falsehits this error when importing from@hyperjump/json-schema/openapi-3-1:It went unnoticed because the repo's
tsconfig.jsonhasskipLibCheck: trueand no.tsfile importsSchemaParameter, sonpm run check-typesnever looked at it.Changes
SchemaParameter.schemafromOasSchema32toOasSchema31, matchingMediaType.schemaandHeader.schemain the same file.openapi-3-1/index.spec.ts, a small type-level regression test that importsParameterandSchemaParameter, sonpm run check-typesnow exercises these types.Testing
Added
openapi-3-1/index.spec.ts(VitestexpectTypeOf), with two tests:SchemaParameter["schema"]is notanyand is exactlyOasSchema31.Parameterunion exposes the sameOasSchema31type for its schema variants.Because the bug lives in a
.d.tsfile, the test is checked at compile time bynpm run check-types, not at runtime. Before the fix, the unresolvedOasSchema32is treated asany, so the type check fails:To run it locally:
npm run check-types
npm test
Verification
npm run check-typesfails on the unfixed code and passes with the fix.npm testpasses (29 test files, 15,003 tests) and eslint reports no errors.openapi-3-1/index.d.tswith--skipLibCheck falseno longer reports theOasSchema32error. The remaining errors from@hyperjump/browserare unrelated and out of scope here.Fixes #135