Skip to content

skip body validation if body parser is not wired in the request chain #74

@stevehu

Description

@stevehu

As we know the openapi-validator and swagger-validator can validate the request body if the body is parsed by the body handler. For put, post and patch request, if the body is missing from the exchange attachment, an error message that indicates the body is missing will be returned. There are two different situations that we cannot use the body parser in the request chain as once the stream is consumed, it won't be available for the downstream handlers anymore.

  • Validation in light-router and light-proxy. We have to keep the body stream to pass to the downstream service so we cannot consume it.

  • In light-spring-boot application. We have to keep the body so that Spring Boot can consume it.

To ensure that the two situations are handled correctly, we have to skip the body validation in the validator if the body cannot be found in the exchange. So the idea is to add another flag in the openapi-validator.yml and swagger-validator.yml to skip the body validation. Other parts of the request are still validated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions