echoSwagger

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 10 Imported by: 1

README

echo-swagger

This is a forked version of echo-swagger to be sure not get updated with breaking changes.

echo middleware to automatically generate RESTful API documentation with Swagger 2.0.

go get github.com/worldline-go/echo-swagger

Usage

Set client-id for swagger-ui for oauth2 authentication. Use our auth library to get client-id external.

// echoSwagger "github.com/worldline-go/echo-swagger"

// set default external client-id in swagger-ui
v1.GET("/swagger/*", echoSwagger.EchoWrapHandler(func(c *echoSwagger.Config) {
	c.OAuth = &echoSwagger.OAuthConfig{
		ClientId: authProvider.GetClientIDExternal(),
	}
}))

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WrapHandler = EchoWrapHandler()

WrapHandler wraps swaggerFiles.Handler and returns echo.HandlerFunc

Functions

func DeepLinking

func DeepLinking(deepLinking bool) func(*Config)

DeepLinking true, false.

func DocExpansion

func DocExpansion(docExpansion string) func(*Config)

DocExpansion list, full, none.

func DomID

func DomID(domID string) func(*Config)

DomID #swagger-ui.

func EchoWrapHandler

func EchoWrapHandler(options ...func(*Config)) echo.HandlerFunc

EchoWrapHandler wraps `http.Handler` into `echo.HandlerFunc`.

func InstanceName

func InstanceName(instanceName string) func(*Config)

InstanceName specified swag instance name.

func OAuth

func OAuth(config *OAuthConfig) func(*Config)

func PersistAuthorization

func PersistAuthorization(persistAuthorization bool) func(*Config)

PersistAuthorization Persist authorization information over browser close/refresh. Defaults to false.

func SyntaxHighlight

func SyntaxHighlight(syntaxHighlight bool) func(*Config)

SyntaxHighlight true, false.

func URL

func URL(url string) func(*Config)

URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).

Types

type Config

type Config struct {
	// The url pointing to API definition (normally swagger.json or swagger.yaml). Default is `mockedSwag.json`.
	URLs                 []string
	DocExpansion         string
	DomID                string
	InstanceName         string
	DeepLinking          bool
	PersistAuthorization bool
	SyntaxHighlight      bool

	// The information for OAuth2 integration, if any.
	OAuth *OAuthConfig
}

Config stores echoSwagger configuration variables.

type OAuthConfig

type OAuthConfig struct {
	// The ID of the client sent to the OAuth2 IAM provider.
	ClientId string

	// The OAuth2 realm that the client should operate in. If not applicable, use empty string.
	Realm string

	// The name to display for the application in the authentication popup.
	AppName string
}

OAuthConfig stores configuration for Swagger UI OAuth2 integration. See https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/ for further details.

Directories

Path Synopsis
docs
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

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