Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.
/ swagger-doc Public archive

Provide methods to expose swagger documentation endpoints to your API

Notifications You must be signed in to change notification settings

ricardoarchive/swagger-doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Swagger-doc middleware

Provide methods to expose swagger documentation endpoints to your API

Installing

go get github.com/ricardo-ch/swagger-doc

Getting Started

To add this in your API:

  • Create an environment variable EXPOSE_DOC with boolean value 'true'. Without this, both endpoints will return 404 NotFound result
export EXPOSE_DOC=true
  • Add import statement
import "github.com/ricardo-ch/swagger-doc"
  • Add those 2 endpoints in your API.
// You can specify an URL where your swagger file is hosted, or if you are using the SwaggerHandler, just specify the endpoint(eg. /swagger)
router.Handle("/docs", middleware.DocumentationHandler("http://127.0.0.1:8081", "/docs")) // Add your custom port and endpoint name here
router.HandleFunc("/swagger", middleware.SwaggerHandler)
  • /swagger will display your swagger.json if it exists, otherwise it will return 404
  • /docs will render Redoc documentation for your swagger file

About

Provide methods to expose swagger documentation endpoints to your API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published