-
-
Notifications
You must be signed in to change notification settings - Fork 201
Description
Checklist
- I checked the FAQ section of the documentation
- I looked for similar issues in the issue tracker
- I am using the latest version of Schemathesis
Describe the bug
Schemathesis uses static version of the current published version
of the OpenApi 3.1 spec metaschema
(https://spec.openapis.org/oas/3.1/schema/2022-10-07)
to validate openapi 3.1 spec documents. Unfortunately, the published
version has at least one known bug in which the schema for paths
references the definition of a concrete path-item instead of
path-item-or-reference, which might still be technically incorrect
when it comes handling the case of ref and sibling fields, but is
correct according to the documented definition of a pathItemObject.
This oversight has been noticed multiple times
OAI/OpenAPI-Specification#3298
OAI/OpenAPI-Specification#2635 (comment)
OAI/OpenAPI-Specification#2635 (comment)
OAI/OpenAPI-Specification#3513
OAI/OpenAPI-Specification#2657 (comment)
And finally fixed in Feb 2024
OAI/OpenAPI-Specification#3355
with a slightly bigger rework of the pathItem schema.
Sadly, due to confusion about how to release fixes in schemas
OAI/OpenAPI-Specification#151 (comment)
this change has not been published anywhere except schema.yaml in the
git repo, not even in schema.json, which appearantly only gets refreshed
once per release of the metaschema
OAI/OpenAPI-Specification#3355 (comment)
This commit updates the stored schema from the most up-to-date 3.1.0
schema.yaml from 0035208 to close the bug and make spec-valid openapi
spec files that use $ref under path finally validate correctly in
schemathesis
To Reproduce
🚨 Mandatory 🚨: Steps to reproduce the behavior:
- Run this command
st run --validate-schema=true --base-url="http://example.com/" --experimental=openapi-3.1 spec.yaml- See error
Schema Loading Error
The provided API schema does not appear to be a valid OpenAPI schema
Unevaluated properties are not allowed ('$ref' was unexpected)
Failed validating 'unevaluatedProperties' in schema['properties']['paths']['patternProperties']['^/']:
{'$comment': 'https://spec.openapis.org/oas/v3.1.0#path-item-object',
'type': 'object',
'properties': {'summary': {'type': 'string'},
'description': {'type': 'string'},
'servers': {'type': 'array',
'items': {'$ref': '#/$defs/server'}},
'parameters': {'type': 'array',
'items': {'$ref': '#/$defs/parameter-or-reference'}},
'get': {'$ref': '#/$defs/operation'},
'put': {'$ref': '#/$defs/operation'},
'post': {'$ref': '#/$defs/operation'},
'delete': {'$ref': '#/$defs/operation'},
'options': {'$ref': '#/$defs/operation'},
'head': {'$ref': '#/$defs/operation'},
'patch': {'$ref': '#/$defs/operation'},
'trace': {'$ref': '#/$defs/operation'}},
'$ref': '#/$defs/specification-extensions',
'unevaluatedProperties': False}
On instance['paths']['/bar']:
{'$ref': '#/paths/~1bar'}Please include a minimal API schema causing this issue:
openapi: "3.1.0"
info:
title: "Test correct validation of spec using $ref in pathItem"
version: 0.0.1
paths:
/foo:
get:
summary: dummy
operationId: dummy
responses:
'200':
description: Success
/bar:
$ref: '#/paths/~1bar'
Expected behavior
The schema validates and the test run proceeds
Environment
- OS: Linux (Ubuntu 24.04, but the python packages are from nixpks)
- Python version: 3.12.5
- Schemathesis version: 3.36.3
- Spec version: Open API 3.1.0
Additional context
Include any other relevant details, like logs or screenshots.