echoswagger/README.md

48 lines
1.3 KiB
Markdown
Raw Normal View History

2018-08-30 15:41:51 +02:00
# echoswagger
Swagger UI generator for Echo framework
2018-09-02 03:14:14 +02:00
[![Go Report Card](https://goreportcard.com/badge/github.com/elvinchan/echoswagger)](https://goreportcard.com/report/github.com/elvinchan/echoswagger)
[![Build Status](https://travis-ci.org/elvinchan/echoswagger.svg?branch=master)](https://travis-ci.org/elvinchan/echoswagger)
2018-09-02 04:22:18 +02:00
[![codecov](https://codecov.io/gh/elvinchan/echoswagger/branch/master/graph/badge.svg)](https://codecov.io/gh/elvinchan/echoswagger)
## Feature
- No SwaggerUI html/css dependency
- Highly integrated with echo, low intrusive design
- Take advantage of the strong typing language to make it easy to use
- Recycle garbage in time, low memory usage
## Example
```go
package main
import (
"net/http"
"github.com/elvinchan/echoswagger"
"github.com/labstack/echo"
)
func main() {
// ApiRoot with Echo instance
e := echoswagger.New(echo.New(), "/v2", "doc/", nil)
// Routes with parameters & responses
e.POST("/", createUser).
AddParamBody(User{}, "body", "User input struct", true).
AddResponse(http.StatusCreated, "successful", nil, nil)
// Start server
e.Echo().Logger.Fatal(e.Echo().Start(":1323"))
}
type User struct {
Name string
}
// Handler
func createUser(c echo.Context) error {
return c.JSON(http.StatusCreated, nil)
}
```