Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurse references in validation #125

Merged
merged 1 commit into from May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions openapi_spec_validator/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def dereference(self, item):
ref = item['$ref']
with self.resolver_manager.in_scope(item) as resolver:
with resolver.resolving(ref) as target:
if is_ref(target):
target = self.dereference(target)
return target


Expand Down
1 change: 1 addition & 0 deletions tests/integration/data/v3.0/parent-reference/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ paths:
tags:
- pets
parameters:
- $ref: "recursive.yaml#/parameters/RecursiveReference"
- name: limit
in: query
description: How many items to return at one time (max 100)
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/data/v3.0/parent-reference/recursive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
RecursiveReference:
$ref : "recursive2.yaml#/parameters/RecursiveReference"
8 changes: 8 additions & 0 deletions tests/integration/data/v3.0/parent-reference/recursive2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
RecursiveReference:
name: sampleParameter
in: query
description: Tests recursion
required: false
schema:
type: boolean
2 changes: 1 addition & 1 deletion tests/integration/test_shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def spec_url(self):
)


class TestApiWithExampe(BaseTestValidValidateV3SpecUrl):
class TestApiWithExample(BaseTestValidValidateV3SpecUrl):

@pytest.fixture
def spec_url(self):
Expand Down