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

feat: adding support for request validation #1

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

maticardenas
Copy link
Owner

issue: snok#291

Adding requestBody validation support.

Currently, the package offers the possibility of validating only the response, however, it is useful to also at the same time,e to have validated that the passed resquestBody in our functional tests are also properly documented and match the implementation.

Additions/Changes

  • Methods for validating request (validate_request) and extract the corresponding requestBody schema section from the OpenAPI schema (get_request_body_schema_section)
  • Updating test_project to also expose Pets API, as it is the OpenAPI schema we have in tests.
  • Adding tests for schema tester, clients and validators.
  • Updating affected variables and functions.

Notes

  • Adding support only for openapi schemas (no swagger, previous versions), which involves StaticSchemaLoader and UrlStaticSchemaLoader instantiated with an openapi 3.x.x. This because it's the current requirement I have for my project.
  • Decided to make request validation only when the scenarios has a successful response. Why? In the case you provide for example an incomplete payload, it will always fail naturally when comparing when your schema - in this situations we should let the functional case validate that the test we chose doesn't fit our design.

Follow Ups

  • Add support for request bodies for swagger, DrfSpectacularSchemaLoader and DrfYasgSchemaLoader.
  • Add support maybe for checking more aspects of the request? query params, headers, authentication, etc.

@maticardenas maticardenas self-assigned this Nov 15, 2023
@maticardenas maticardenas merged commit 25b6ac6 into master Nov 15, 2023
@maticardenas maticardenas deleted the 291-validate-requests-func branch October 17, 2024 15:13
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.

1 participant