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

[Validation] Get the schema of matching content type for request body validation #1494

Closed
2 of 4 tasks
jannyHou opened this issue Jul 4, 2018 · 8 comments
Closed
2 of 4 tasks

Comments

@jannyHou
Copy link
Contributor

jannyHou commented Jul 4, 2018

Description / Steps to reproduce / Feature proposal

A request body specification could contain different content-types, each has a schema defined. By validating the request body when a request comes in, the validator should get the schema that matches the request's content type to perform the validation.
see comment in code

Current Behavior

We use the schema of the first content-type by default

Expected Behavior

The content-type should be inferred from the request

Acceptance Cretiria

  • Detect the content type of a request in the rest parser, and pass it into function validateRequestBody - see feat(rest): add support for form request body #1838
  • The validator function above should fetch the schema of the request's content-type to perform the validation. Note: the function to get the schema is called getRequestBodySchema - see feat(rest): add support for form request body #1838
  • Unit/integration test(s): define an operation that has different schemas for JSON and urlencoded bodies and verify that the correct schema was used to validate the incoming request.
  • Extend test helper function aBodySpec to allow multiple contents
@jannyHou jannyHou self-assigned this Jul 4, 2018
@dhmlau
Copy link
Member

dhmlau commented Jul 21, 2018

@jannyHou , PR #1489 has landed. Does it mean this ticket can be closed? Thanks.

@jannyHou
Copy link
Contributor Author

@dhmlau Nope this story is what's missing in PR #1489 :(

@bajtos
Copy link
Member

bajtos commented Oct 30, 2018

A request body specification could contain different content-types, each has a schema defined. By validating the request body when a request comes in, the validator should get the schema that matches the request's content type to perform the validation.

@raymondfeng I think this should be already fixed/implemented by your recently landed pull request #1838. Could you please confirm?

If it's true, then I think we should still keep this issue open but reduce the scope to writing an integration or acceptance tests verifying this aspect of our body parsing. I.e. define an operation that has different schemas for JSON and urlencoded bodies and verify that the correct schema was used to validate the incoming request.

Thoughts?

cc @jannyHou @dhmlau

@jannyHou
Copy link
Contributor Author

@raymondfeng I think this should be already fixed/implemented by your recently landed pull request #1838. Could you please confirm?

I believe so, but better get a confirm from Raymond. IMO this issue is ok to close.

@raymondfeng
Copy link
Contributor

Yes, I think so.

@bajtos
Copy link
Member

bajtos commented Nov 9, 2018

I updated the acceptance criteria, there are still two tasks remaining:

Unit/integration test(s): define an operation that has different schemas for JSON and urlencoded bodies and verify that the correct schema was used to validate the incoming request.
Extend test helper function aBodySpec to allow multiple contents

Let's keep this GH issue open until all acceptance criteria are met.

@raymondfeng
Copy link
Contributor

To be completed by #2079

@raymondfeng
Copy link
Contributor

Completed by #2079

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

4 participants