openapi-mock icon indicating copy to clipboard operation
openapi-mock copied to clipboard

Validate that input adheres to openapi spec

Open Hollerweger opened this issue 2 years ago • 2 comments

It seems that the post data is not validated against the openapi specification. Is there a possibility to enable data validation against the specification? A 400 BadRequest should be returned in case the data does not adhere to the specification.

Hollerweger avatar Sep 30 '22 12:09 Hollerweger

Okay just saw that request validation is currently not supported. Is this something that is planned? Which openapi generator is used here? The ones I know are usually generation input validation for server stubs.

Hollerweger avatar Sep 30 '22 12:09 Hollerweger

It seems a simple action to do by modifying the code at openapi validator

https://github.com/muonsoft/openapi-mock/blob/master/internal/openapi/handler/ResponseGeneratorHandler.go#L54

It'd be nice to give user an option to choose being strict or not. If yes, then validate request body, if not, ignore request body

ctnguyen avatar Apr 22 '23 08:04 ctnguyen