fix(validator): reject type "null" in OAS 3.0 documents#365
Conversation
In OAS 3.0.x, the only valid schema types are array, boolean, integer, number, object, and string. The "null" type was introduced in OAS 3.1+ (JSON Schema 2020-12). Previously, validateSchemaTypeConstraints silently accepted type: "null" on 3.0 documents because its switch had no "null" case and no version check. This change plumbs the parsed OAS version onto the Validator via a new oasVersion field (set in ValidateParsed) and adds a "null" case to the schema type switch that emits an error when the document is OAS 3.0.x. OAS 3.1+ continues to accept both scalar type: "null" and the type-array form (e.g. ["string", "null"]). Fixes #362
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 29 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #365 +/- ##
=======================================
Coverage 84.75% 84.76%
=======================================
Files 194 194
Lines 27458 27469 +11
=======================================
+ Hits 23272 23283 +11
Misses 2842 2842
Partials 1344 1344
🚀 New features to boost your workflow:
|
Summary
typeto be one ofarray,boolean,integer,number,object,string. The"null"type was introduced in OAS 3.1+ (JSON Schema 2020-12). Previously the validator silently acceptedtype: "null"on 3.0 documents.Validatorvia a newoasVersionfield (set inValidateParsed) and add a"null"case tovalidateSchemaTypeConstraintsthat emits an error when the document is OAS 3.0.x.type: "null"and the type-array form (e.g.["string", "null"]) — this PR only tightens the 3.0 path.Fixes #362.
Error message
Scope note
The issue mentions a related pattern — specs that carry both
nullable: true(3.0 idiom) andanyOf: [{type: "null"}](3.1 idiom). That cross-idiom check is intentionally deferred to keep this PR tight and focused on the primary reported bug.Test plan
TestValidate_NullType_OAS30_Rejectedcovers all 3.0.x minor versions (3.0.0 through 3.0.4)TestValidate_NullType_OAS31_Allowedregression guard — 3.1.0 still acceptstype: "null"TestValidate_StringType_OAS30_Allowedregression guard — valid 3.0 types still passmake checkpasses locally (lint 0 issues, 8568 tests, validator coverage 89.4%)🤖 Generated with Claude Code