swagger

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 5 Imported by: 0

README

Welcome to 👋

Version

swagger를 쉽게 배포할 수 있도록 정의한 패키지

Install

go get github.com/realsangil/gopkg/swagger

Usage

Go Standard HTTP package

func main() {
  if err := http.ListenAndServe(":1202", HTTPHandleFunc("https://petstore.swagger.io/v2/swagger.json")); err != nil {
		panic(err)
	}
}

Echo framework

func main() {
  e := echo.New()
	e.GET("/docs", EchoHandleFunc("/v2/swagger.json", WithTitle("Example")))
	if err := e.Server.ListenAndServe(); err != nil {
		panic(err)
	}
}

Run tests

go test ./...

Author

👤 realsangil

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 realsangil.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoHandleFunc

func EchoHandleFunc(specURL string, opts ...ParameterOption) echo.HandlerFunc

EchoHandleFunc returns echo.HandleFunc

Example
e := echo.New()
e.GET("/docs", EchoHandleFunc("/docs/spec", WithTitle("Example")))
if err := e.Server.ListenAndServe(); err != nil {
	panic(err)
}
Output:

func HTTPHandleFunc

func HTTPHandleFunc(specURL string, opts ...ParameterOption) http.HandlerFunc

HTTPHandleFunc returns http.HandlerFunc

Example
if err := http.ListenAndServe(":1202", HTTPHandleFunc("http://localhost:1324/docs/spec")); err != nil {
	panic(err)
}
Output:

Types

type Parameter

type Parameter struct {
	Title   string `json:"title,omitempty"`
	Favicon string `json:"favicon,omitempty"`
	SpecURL string `json:"spec_url,omitempty"`
}

Parameter is golang template parameter

type ParameterOption

type ParameterOption func(*Parameter)

ParameterOption sets Parameter fields

func WithFavicon

func WithFavicon(favicon string) ParameterOption

WithFavicon sets favicon url to Parameter.Favicon

func WithTitle

func WithTitle(title string) ParameterOption

WithTitle sets title to Parameter.Title

Jump to

Keyboard shortcuts

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