Code Monkey home page Code Monkey logo

go-redoc's Introduction

go-redoc

GoDoc Go Report Card

go-redoc is an embedded OpenAPI documentation ui for Go using ReDoc and Go's 1.16+'s embed package, with middleware implementations for: net/http, gin, fiber, and echo.

The template is based on the ReDoc's bundle template with the script already placed in the html instead of depending on a CDN.

This package does not generate openapi spec file. Check this example for using code generation with swag.

Usage

import "github.com/hohmannr/go-redoc"

...

doc := redoc.Redoc{
    Title:       "Example API",
    Description: "Example API Description",
    SpecFile:    "./openapi.json", // "./openapi.yaml"
    SpecPath:    "/openapi.json",  // "/openapi.yaml"
    DocsPath:    "/docs",
}
  • net/http
import (
	"net/http"
	"github.com/hohmannr/go-redoc"
)

...

http.ListenAndServe(address, doc.Handler())
  • gin
import (
	"github.com/gin-gonic/gin"
	"github.com/hohmannr/go-redoc"
	ginredoc "github.com/hohmannr/go-redoc/gin"
)

...

r := gin.New()
r.Use(ginredoc.New(doc))
  • echo
import (
	"github.com/labstack/echo/v4"
	"github.com/hohmannr/go-redoc"
	echoredoc "github.com/hohmannr/go-redoc/echo"
)

...

r := echo.New()
r.Use(echoredoc.New(doc))
  • fiber
import (
	"github.com/gofiber/fiber/v2"
	"github.com/hohmannr/go-redoc"
	fiberredoc "github.com/hohmannr/go-redoc/fiber"
)

...

r := fiber.New()
r.Use(fiberredoc.New(doc))

See examples

go-redoc's People

Contributors

mvrilo avatar hohmannr avatar grindlemire avatar thiskevinwang avatar ttys3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.