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

Any way to pass the payload directly in ValidateRequestBody #846

Open
pratik-sharma-1 opened this issue Oct 16, 2023 · 0 comments
Open

Any way to pass the payload directly in ValidateRequestBody #846

pratik-sharma-1 opened this issue Oct 16, 2023 · 0 comments

Comments

@pratik-sharma-1
Copy link

pratik-sharma-1 commented Oct 16, 2023

Hi Team,

To validate the request body against openapi spec , we currently use method ValidateRequestBody defined at https://github.com/getkin/kin-openapi/blob/master/openapi3filter/validate_request.go#L196.

However, we also need to fulfil below 2 usecases:

  1. To protect our system from large request payloads, we want to limit the read of the payload from the request to a configurable limit (example: 10 MB)
  2. During the course of processing , we have other steps which also need to read the request payload. We want to avoid reading the same payload (and then putting it back to the request) from the request more than once.

Currently , ValidateRequestBody does a io.ReadAll (https://github.com/getkin/kin-openapi/blob/master/openapi3filter/validate_request.go#L210)

To fulfil above usecases, do we have any way to achieve it currently or can we provide the payload directly via any other API?

Regards,
Pratik Sharma

@pratik-sharma-1 pratik-sharma-1 changed the title Any way to pass the payload directly in validate Any way to pass the payload directly in ValidateRequestBody Oct 17, 2023
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