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

[BUG] Strict schema validation not honoring required fields #742

Open
3 tasks
kheraankit opened this issue Apr 15, 2024 · 0 comments
Open
3 tasks

[BUG] Strict schema validation not honoring required fields #742

kheraankit opened this issue Apr 15, 2024 · 0 comments

Comments

@kheraankit
Copy link

Describe the bug

I have the following response schema, in which available is a required field and the user_name name may or may not be present. All tests pass until in enable strict schema validation config.openapi_strict_schema_validation = true. Now the test fails with the following message Expected response body to match schema: The property '#/' did not contain a required property of 'user_name' in schema. It appears the schema validation is not taking into account the required fields or maybe I am not interpreting the documentation correctly. Can someone help here?

          schema type: :object,
                 properties: {
                   available: { type: :boolean },
                   user_name: { type: :string, nullable: true },
                 },
                 required: ['available']

Steps to Test or Reproduce

  • Define the schema as above, and return following response from the endpoint { 'available': true }
  • Write an rswag test with the above response schema
  • Run the tests and they would succeed
  • Enable strict schema mode
  • Re-Run the tests and they would fail

Expected behavior

I am expecting the tests to still succeed as the user_name field is not required

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Dependency versions

The version of are you using for:

  • Rswag:
  • RSpec:
  • Rails:
  • Ruby:

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1
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

No branches or pull requests

1 participant