Documentation ¶
Index ¶
- func Must[T any](v T, err error) T
- func NewHandler(opts ...Option) http.HandlerFunc
- type DocExpansion
- type Layout
- type ModelRendering
- type Option
- func WithBasePath(basePath string) Option
- func WithConfigURL(configURL string) Option
- func WithCredentials(withCredentials bool) Option
- func WithDeepLinking(deepLinking bool) Option
- func WithDefaultModelExpandDepth(defaultModelExpandDepth int) Option
- func WithDefaultModelRendering(defaultModelRendering ModelRendering) Option
- func WithDefaultModelsExpandDepth(defaultModelsExpandDepth int) Option
- func WithDisplayOperation(displayOperationID bool) Option
- func WithDisplayRequestDuration(displayRequestDuration bool) Option
- func WithDocExpansion(value DocExpansion) Option
- func WithFilter(enabled bool, expression string) Option
- func WithHTMLTitle(title string) Option
- func WithLayout(layout Layout) Option
- func WithMaxDisplayedTags(maxTags int) Option
- func WithOauth2RedirectUrl(oauth2RedirectUrl string) Option
- func WithPersistAuthorization(persistAuthorization bool) Option
- func WithPresets(preset Preset) Option
- func WithQueryConfigEnabled(queryConfigEnabled bool) Option
- func WithShowCommonExtensions(showCommonExtensions bool) Option
- func WithShowExtensions(showExtensions bool) Option
- func WithShowMutatedRequest(showMutatedRequest bool) Option
- func WithSpec(value []byte) Option
- func WithSpecFilePath(path string) Option
- func WithSpecURL(value string) Option
- func WithSpecURLs(primary string, urls []SpecURL) Option
- func WithSupportedSubmitMethods(supportedSubmitMethods ...string) Option
- func WithTryItOutEnabled(tryItOutEnabled bool) Option
- func WithValidatorURL(enabled bool, validatorUrl string) Option
- type Preset
- type SpecURL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler(opts ...Option) http.HandlerFunc
Types ¶
type DocExpansion ¶
type DocExpansion string
var ( DocExpansionList DocExpansion = "list" DocExpansionFull DocExpansion = "full" DocExpansionNone DocExpansion = "none" )
type ModelRendering ¶
type ModelRendering string
var ( ModelRenderingExample ModelRendering = "example" ModelRenderingModel ModelRendering = "model" )
type Option ¶
type Option func(*uiConfig)
Option is a function that takes a pointer to uiConfig and modifies it.
func WithBasePath ¶
WithBasePath sets the path prefix Swagger UI is provided on the server For example, if Swagger UI is provided under https://example.com/my-service/swagger-ui, the base path would be "/my-service/swagger-ui"). This will allow the handler to receive requests on path "my-service/swagger-ui" without a trailing slash (i.e., "/my-service/swagger-ui/"). Internally, the base path will be used to set a prefix for Swagger UI asset files (CSS, JavaScript, etc.).
func WithConfigURL ¶
WithConfigURL sets the URL to fetch external configuration document from.
func WithCredentials ¶
WithCredentials enables passing credentials, as defined in the Fetch standard, in CORS requests that are sent by the browser. Note that Swagger UI cannot currently set cookies cross-domain (see swagger-js#1163) - as a result, you will have to rely on browser-supplied cookies (which this setting enables sending) that Swagger UI cannot control.
func WithDeepLinking ¶
WithDeepLinking enables deep linking. See documentation at https://swagger.io/docs/open-source-tools/swagger-ui/usage/deep-linking/ for more information.
func WithDefaultModelExpandDepth ¶
WithDefaultModelExpandDepth sets the default expansion depth for the model on the model-example section.
func WithDefaultModelRendering ¶
func WithDefaultModelRendering(defaultModelRendering ModelRendering) Option
WithDefaultModelRendering controls how the model is shown when the API is first rendered. The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.
func WithDefaultModelsExpandDepth ¶
WithDefaultModelsExpandDepth sets the default expansion depth for models (set to -1 completely hide the models).
func WithDisplayOperation ¶
WithDisplayOperation controls the display of operationId in operations list. The default is false.
func WithDisplayRequestDuration ¶
WithDisplayRequestDuration controls the display of the request duration (in milliseconds) for "Try it out" requests.
func WithDocExpansion ¶
func WithDocExpansion(value DocExpansion) Option
WithDocExpansion controls the default expansion setting for the operations and tags.
func WithFilter ¶
WithFilter enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown. If enabled and a non-empty expression string is passed, then filtering will be enabled using that string as the filter expression. Filtering is case-sensitive matching the filter expression anywhere inside the tag. Leave the expression empty, if you only want to enable filtering but do not need a filter expression.
func WithHTMLTitle ¶
WithHTMLTitle sets the index HTML page htmlTitle.
func WithLayout ¶
WithLayout sets the name of a component available via the plugin system to use as the top-level layout for Swagger UI. Possible values are "BaseLayout" and "StandaloneLayout". Default is "BaseLayout".
func WithMaxDisplayedTags ¶
WithMaxDisplayedTags limits the number of tagged operations displayed to at most this many. The default is to show all operations.
func WithOauth2RedirectUrl ¶
WithOauth2RedirectUrl sets the OAuth redirect URL.
func WithPersistAuthorization ¶
WithPersistAuthorization configures Swagger UI to persist authorization data, so that it is not lost on browser close/refresh.
func WithPresets ¶
WithPresets sets the list of presets to use in Swagger UI. Usually, you'll want to include PresetAPIPreset if you use this option.
func WithQueryConfigEnabled ¶
WithQueryConfigEnabled enables overriding configuration parameters via URL search params.
func WithShowCommonExtensions ¶
WithShowCommonExtensions controls the display of extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters.
func WithShowExtensions ¶
WithShowExtensions controls the display of vendor extension (x-) fields and values for Operations, Parameters, Responses, and Schema.
func WithShowMutatedRequest ¶
WithShowMutatedRequest configures Swagger UI to use the mutated request returned from a requestInterceptor to produce the curl command in the UI, otherwise the request before the requestInterceptor was applied is used. Refer to https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ for more information.
func WithSpec ¶
WithSpec sets an OpenAPI specification document content. When used, the URL configuration setting will not be used. This is useful for testing manually-generated definitions without hosting them.
func WithSpecFilePath ¶
WithSpecFilePath sets a file path to read from the OS file system. THIS OPTION IS NOT RECOMMENDED FOR PRODUCTION USE, because it reloads the file on every request. This option only exist to for testing purposes. Once file content is read, it will be used to set the spec field of https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md and is equivalent to the WithSpec function.
func WithSpecURL ¶
WithSpecURL sets the URL pointing to API definition (normally swagger.json or swagger.yaml). Will be ignored if WithSpecURLs or WithSpec is used.
func WithSpecURLs ¶
WithSpecURLs sets the URLs array to multiple API definitions that are used by Topbar plugin. When used and Topbar plugin is enabled, the settings from WithSpecURL will not be used. Names and URLs must be unique among all items in this array, since they're used as identifiers. If the value of the 'primary' parameter matches the name of a spec provided in urls, that spec will be displayed when Swagger UI loads, instead of defaulting to the first spec in urls. Leave parameter 'primary' empty, if you do not want to set a preselected URL.
func WithSupportedSubmitMethods ¶
WithSupportedSubmitMethods sets a list of HTTP methods that have the "Try it out" feature enabled. An empty array disables "Try it out" for all operations. This does not filter the operations from the display. Default is: ["get", "put", "post", "delete", "options", "head", "patch", "trace"].
func WithTryItOutEnabled ¶
WithTryItOutEnabled controls whether the "Try it out" section should be enabled by default.
func WithValidatorURL ¶
WithValidatorURL sets the validator URL to use to validate specification files. By default, Swagger UI attempts to validate specs against swagger.io's online validator. You can use this parameter to set a different validator URL, for example for locally deployed validators (e.g., Validator Badge, see https://github.com/swagger-api/validator-badge). Disabling it or setting the URL to 127.0.0.1 or localhost will disable validation.