« Back to Search  |  Reader Mode  |  Switch to Full Retro Site View Links: Stay in Reader  |  Retro Mode: ON  |  Original »
GitHub · Extracted in 854 ms

GitHub - oapi-codegen/gin-middleware

Source: https://github.com/oapi-codegen/gin-middleware

Repository navigation

gin-middleware
Public

About

No description, website, or topics provided.

Resources

Readme Apache-2.0 license

Security policy

Security policy Activity Custom properties

Stars

8 stars

Watchers

2 watching

Forks

8 forks Report repository
Branches

Tags
Go to Branches page Go to Tags page

Latest commit

 

History


51 Commits
View commit history for this file.

Folders and files

Name Name Last commit message Last commit date
.github .github    
.gitignore .gitignore    
LICENSE LICENSE    
Makefile Makefile    
README.md README.md    
go.mod go.mod    
go.sum go.sum    
oapi_validate.go oapi_validate.go    
oapi_validate_test.go oapi_validate_test.go    
renovate.json renovate.json    
test_spec.yaml test_spec.yaml    

Repository files navigation

Gin Middleware

⚠️ This README may be for the latest development version, which may contain unreleased changes. Please ensure you're looking at the README for the latest release version.

Middleware for the Gin web server for use with oapi-codegen/oapi-codegen .

Validated request body

The middleware enables kin-openapi's openapi3filter.Options.KeepValidatedValue by default. After a request body passes validation, c.Request.Body stays readable (with the original bytes, unless kin-openapi rewrote it to apply schema defaults) and additionally implements interface{ ValidatedValue() any }, returning the decoded value that was validated. oapi-codegen strict servers that support it can bind that value instead of decoding the body a second time, so the handler sees exactly what was validated (for example, encoding/json's case-insensitive member matching can no longer make a request validate as one value but bind as another).

To opt out, for instance to limit memory retention for very large request bodies, set Options.DiscardValidatedValue = true. This setting overrides Options.Options.KeepValidatedValue.

Any middleware placed after the validator that replaces c.Request.Body (decompression, size limiting, logging wrappers and the like) hides the validated value from handlers. Register such middleware before the validator.

Licensed under the Apache-2.0.

About

No description, website, or topics provided.

Resources

Readme Apache-2.0 license

Security policy

Security policy Activity Custom properties

Stars

8 stars

Watchers

2 watching

Forks

8 forks Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages