Skip to content

Integrate openapi-schema-test-suite as canonical validator test suite#278

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-openapi-test-suite-again
Draft

Integrate openapi-schema-test-suite as canonical validator test suite#278
Copilot wants to merge 3 commits intomasterfrom
copilot/add-openapi-test-suite-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

Integrates the openapi-schema-test-suite — the canonical JSON test corpus for OAS 3.1/3.2 schema dialect validators — into the project's test suite.

Changes

Git submodule

  • Added vendor/openapi-schema-test-suite pointing to the upstream repo

Test runner (tests/test_suite.py)

  • Parametrizes all oas31/ and oas32/ JSON test files into 740 pytest cases with readable IDs (dialect/file/case/test)
  • Enables format checkers for optional/format/ tests (format-as-assertion mode)
  • 4 known failures marked xfail(strict=True):
    • format uri relative/invalid URI tests — uri format checker does not enforce RFC 3986 absolute-URI requirement

Bug fix: OAS 3.1/3.2 discriminator is annotation-only (validators.py)

The OAS 3.1 validator was inheriting custom oneOf/anyOf/allOf handlers that replace standard JSON Schema composition with discriminator-based $ref resolution (OAS 3.0 semantics). In OAS 3.1/3.2, discriminator is a pure annotation; composition validation is governed entirely by oneOf/anyOf/allOf. Removed those overrides so OAS 3.1/3.2 uses Draft 2020-12 semantics directly.

# Before: OAS31Validator with discriminator would silently attempt ref resolution
schema = {
    "$schema": "https://spec.openapis.org/oas/3.1/dialect/2024-11-10",
    "oneOf": [
        {"type": "object", "properties": {"petType": {"const": "cat"}, "meow": {"type": "string"}}, "required": ["petType", "meow"]},
    ],
    "discriminator": {"propertyName": "petType"},
}
v = OAS31Validator(schema)
list(v.iter_errors({"petType": "cat", "meow": "purr"}))
# Was: [ValidationError: "... reference '#/components/schemas/cat' could not be resolved"]
# Now: []  — discriminator ignored, oneOf validates normally

pyproject.toml

  • Added vendor/openapi-schema-test-suite/tests to sdist includes

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: p1c2u <1679024+p1c2u@users.noreply.github.com>
Copilot AI changed the title [WIP] Add OpenAPI test suite to project Integrate openapi-schema-test-suite as canonical validator test suite Mar 6, 2026
Copilot finished work on behalf of p1c2u March 6, 2026 14:52
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.

2 participants