https://github.com/cdimascio/gin-openapi
Automatically validates API requests against an OpenAPI 3 spec.
https://github.com/cdimascio/gin-openapi
gin gin-gonic middleware openapi request-validation validation
Last synced: 6 months ago
JSON representation
Automatically validates API requests against an OpenAPI 3 spec.
- Host: GitHub
- URL: https://github.com/cdimascio/gin-openapi
- Owner: cdimascio
- License: mit
- Created: 2020-10-31T19:25:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-31T22:05:35.000Z (about 5 years ago)
- Last Synced: 2025-04-24T06:36:21.865Z (9 months ago)
- Topics: gin, gin-gonic, middleware, openapi, request-validation, validation
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## gin-openapi
Automatically validates API requests against an OpenAPI 3 spec.
## Usage
```go
package main
import (
openapi "github.com/cdimascio/gin-openapi/pkg"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
// Add gin-openapi middleware
router.Use(openapi.ValidateRequests("spec.yml"))
// Add routes
router.POST("/v1/ping", func(c *gin.Context) {
c.JSON(200, gin.H{ "id": "pong" })
})
router.Run(":8080")
}
```
## License MIT