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

Fix parameters with schema reference #564

Merged
merged 1 commit into from
Oct 24, 2022
Merged

Fix parameters with schema reference #564

merged 1 commit into from
Oct 24, 2022

Conversation

sergiopatricio
Copy link
Contributor

Problem

Reading https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject it says that schema can be a "Schema Object" or a "Reference Object".

I think the code on rswag/specs/request_factory.rb is not prepared for the "Reference Object" option. When schema has a $ref and not a type it raises an exception:

NoMethodError:
   undefined method `to_sym' for nil:NilClass

             case param[:schema][:type].to_sym
                                       ^^^^^^^

Solution

Don't raise an exception, and instead add a fallback as we had before version 2.6.0.

This concerns this parts of the Open API Specification:

The changes I made are compatible with:

  • OAS2
  • OAS3
  • OAS3.1

Related Issues

#563

Checklist

  • Added tests
  • Changelog updated
  • Added documentation to README.md

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

@oblakeerickson oblakeerickson merged commit a46424d into rswag:master Oct 24, 2022
@sergiopatricio sergiopatricio deleted the parameters-schema-ref branch October 25, 2022 08:23
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.

None yet

2 participants