gin-openapi

module
v0.1.1-0...-d769665 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2020 License: MIT

README

gin-openapi

Automatically validates API requests against an OpenAPI 3 spec.

Usage

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL