fix wrong resolving of responses component using $ref #277
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
Fix wrong resolving of responses component using
$ref
.OpenAPI supports the reusable responses with
$ref
keyword but it not work as expected.Motivation
When I tested it, as described in issue #276, it didn't behave as expected.
So I tried to print some log messages in
JSON::Validator::Schema::OpenAPIv3::parameters_for_response()
method.and here's what I got
Here we can see that the subpath was not parsed because we only specified up to
responses
as the path parameter to theget()
method.Therefore, I think we should explicitly include the HTTP return code(
$status
) in the path parameter to support defining reusable responses and using them with the$ref
keyword.References
https://swagger.io/docs/specification/v3_0/describing-responses/#reusing-responses
Test Result