Documentation
¶
Index ¶
- Variables
- func DisablingHandler(h *webdav.Handler, envName string, configurators ...Configurator) iris.Handler
- func Handler(h *webdav.Handler, configurators ...Configurator) iris.Handler
- type Config
- type Configurator
- type ConfiguratorFunc
- func DeepLinking(deepLinking bool) ConfiguratorFunc
- func DefaultModelsExpandDepth(depth int) ConfiguratorFunc
- func DocExpansion(docExpansion string) ConfiguratorFunc
- func DomID(domID string) ConfiguratorFunc
- func FontCDN(cdn string) ConfiguratorFunc
- func OAuth(config *OAuthConfig) ConfiguratorFunc
- func Oauth2DefaultClientID(oauth2DefaultClientID string) ConfiguratorFunc
- func Oauth2UsePkce(usePkce bool) ConfiguratorFunc
- func PersistAuthorization(persistAuthorization bool) ConfiguratorFunc
- func Prefix(prefix string) ConfiguratorFunc
- func SetTheme(theme Theme) ConfiguratorFunc
- func SyntaxHighlight(syntaxHighlight bool) ConfiguratorFunc
- func URL(url string) ConfiguratorFunc
- func URLs(urls ...string) ConfiguratorFunc
- type OAuthConfig
- type Theme
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultConfig 默认的Swagger配置 DefaultConfig = &Config{ URL: "swagger/swagger.json", DeepLinking: true, DocExpansion: "list", DomID: "#swagger-ui", Prefix: "/swagger", FontCDN: "https://fonts.googleapis.com", Theme: Unknow, Filter: true, } )
Functions ¶
func DisablingHandler ¶
func DisablingHandler(h *webdav.Handler, envName string, configurators ...Configurator) iris.Handler
DisablingHandler turns handler off if specified environment variable passed.
func Handler ¶
func Handler(h *webdav.Handler, configurators ...Configurator) iris.Handler
Handler wraps the webdav http handler into an Iris Handler one.
Usage:
swaggerUI := swagger.Handler(swaggerFiles.Handler,
swagger.URL("http://localhost:8080/swagger/swagger.json"), // The url pointing to API definition))
swagger.DeepLinking(true),
swagger.Prefix("/swagger"),
)
app.Get("/swagger", swaggerUI)
app.Get("/swagger/{any:path}", swaggerUI)
OR
swaggerUI := swagger.Handler(swaggerFiles.Handler, swagger.Config{
URL: ...,
Prefix: ...,
DeepLinking: ...,
DocExpansion: ...,
DomID: ...,
}
Types ¶
type Config ¶
type Config struct {
// The URL pointing to API definition (normally swagger.json or swagger.yaml).
// Default is `swagger/swagger.json`. DEPRECATED: Use URLs instead.
URL string
// The URLs pointing to API definitions (normally swagger.json or swagger.yaml).
// Default is `["swagger/swagger.json"]`.
URLs []string
// The prefix url which this swagger ui is registered on.
// Defaults to "/swagger". It can be a "." too.
Prefix string
FontCDN string
Theme Theme
DeepLinking bool
DocExpansion string
DomID string
// Enabling tag Filtering
Filter bool
// Persist authorization information over browser close/refresh
PersistAuthorization bool
// Syntax highlighting for the swagger UI
SyntaxHighlight bool
// Information for OAuth2 integration
OAuth *OAuthConfig
// Enable OAuth2 PKCE
Oauth2UsePkce bool
// Default OAuth2 client ID
Oauth2DefaultClientID string
// Default expansion depth for models
DefaultModelsExpandDepth int
}
Config stores swagger configuration variables.
type Configurator ¶
type Configurator interface {
Configure(*Config)
}
Configurator represents a configuration setter.
type ConfiguratorFunc ¶
type ConfiguratorFunc func(*Config)
ConfiguratorFunc implements the Configuration as a function type.
func DeepLinking ¶
func DeepLinking(deepLinking bool) ConfiguratorFunc
DeepLinking set the swagger deeplinking configuration.
func DefaultModelsExpandDepth ¶
func DefaultModelsExpandDepth(depth int) ConfiguratorFunc
DefaultModelsExpandDepth set the default expansion depth for models (set to -1 completely hide the models).
func DocExpansion ¶
func DocExpansion(docExpansion string) ConfiguratorFunc
DocExpansion list, full, none.
func Oauth2DefaultClientID ¶
func Oauth2DefaultClientID(oauth2DefaultClientID string) ConfiguratorFunc
Oauth2DefaultClientID set the default client ID used for OAuth2.
func Oauth2UsePkce ¶
func Oauth2UsePkce(usePkce bool) ConfiguratorFunc
Oauth2UsePkce enables Proof Key for Code Exchange. Corresponds to the usePkceWithAuthorizationCodeGrant property of the Swagger UI and applies only to accessCode (Authorization Code) flows.
func PersistAuthorization ¶
func PersistAuthorization(persistAuthorization bool) ConfiguratorFunc
PersistAuthorization Persist authorization information over browser close/refresh. Defaults to false.
func Prefix ¶
func Prefix(prefix string) ConfiguratorFunc
Prefix presents the URL prefix of this swagger UI (normally "/swagger" or ".").
func SetTheme ¶
func SetTheme(theme Theme) ConfiguratorFunc
func SyntaxHighlight ¶
func SyntaxHighlight(syntaxHighlight bool) ConfiguratorFunc
SyntaxHighlight enable syntax highlighting for the swagger UI. Defaults to false for backward compatibility.
func URL ¶
func URL(url string) ConfiguratorFunc
URL presents the URL pointing to API definition (normally swagger.json or swagger.yaml). For backward compatibility - adds single URL to URLs slice.
func URLs ¶
func URLs(urls ...string) ConfiguratorFunc
URLs presents the URLs pointing to API definitions (normally swagger.json or swagger.yaml).
func (ConfiguratorFunc) Configure ¶
func (fn ConfiguratorFunc) Configure(config *Config)
Configure calls itself and modifies the default config.
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
basic
command
|
|
|
basic/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 |