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

Validator does not follow Reference in patterned fields in Responses Object in OpenAPI v2 & v3 #269

Open
AnotherOneAckap opened this issue Jul 11, 2023 · 0 comments

Comments

@AnotherOneAckap
Copy link

  • JSON::Validator version: 5.14
  • Perl version: 5.30.0
  • Operating system: Ubuntu 20.04.3 LTS

First things first: thank you for your great job!

Steps to reproduce the behavior

I have an openapi v3 spec and I would like to test responses got from server against it.

Here is the test sample https://github.com/AnotherOneAckap/json-validator-issue-example

Expected behavior

In the given example output with both specifications should be identical.

Actual behavior

Validator ignores futher schema if it meets Reference in patterned filed in Responses Object

How to fix it

According to openapi spec v3.0 2019-04-02
Responses Object contains patterned fields which could be either a Response Object or a Reference
see https://spec.openapis.org/oas/v3.0.3#patterned-fields-0 also https://github.com/OAI/OpenAPI-Specification/blob/3.0.3/schemas/v3.0/schema.json#L211

But if I use Reference instead of Response Object, validator ignores it.

This happens because here validator first make get (which resolves any refs) to reach responses node and then it just go down by hash with status code.
But node after status code also could be a Reference.
So I suppose to use another get there.
Same problem exists in JSON::Validator::Schema::OpenAPIv2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants