How to enable strict validation of the request body? #744
-
Howdy, For example, here is an example swagger spec, notice how i have put
Here is the generated code for reference too- https://github.com/BuilderHarrison/animal-generated-oapi-codgen Here is 2 images of what happens of when i dont provide a request body with any of the required properties - https://imgur.com/a/hZL9b7N That image is of the method when i'm implementing one of the handlers. Which is where I assume would be the best place to implement my own validation of the request body if there isnt a flag or something provided by oapi-codegen! Happy for suggestions if this is something, someone has tackled already :). Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Follow up, i haven't tested middlewears just yet, so i'll try that too! |
Beta Was this translation helpful? Give feedback.
-
I was able to accomplish request body validation by using the chi-middlewear module and editing the swagger spec to something like this:
and added the following code to my serverHandler
|
Beta Was this translation helpful? Give feedback.
I was able to accomplish request body validation by using the chi-middlewear module and editing the swagger spec to something like this: