Documentation
¶
Index ¶
- type ContentConfig
- type ContentOption
- type OpenAPIOption
- func WithBaseURL(baseURL string) OpenAPIOption
- func WithDebug(debug ...bool) OpenAPIOption
- func WithDescription(description string) OpenAPIOption
- func WithDisableOpenAPI(disable ...bool) OpenAPIOption
- func WithDocsPath(path string) OpenAPIOption
- func WithOpenAPIVersion(version string) OpenAPIOption
- func WithSecurity(name string, opts ...SecurityOption) OpenAPIOption
- func WithServer(url string, opts ...ServerOption) OpenAPIOption
- func WithSwaggerConfig(cfg ...*spec.SwaggerConfig) OpenAPIOption
- func WithTitle(title string) OpenAPIOption
- func WithVersion(version string) OpenAPIOption
- type OperationConfig
- type OperationOption
- func Deprecated(deprecated ...bool) OperationOption
- func Description(description string) OperationOption
- func Hide(hide ...bool) OperationOption
- func ID(id string) OperationOption
- func Request(structure any, options ...ContentOption) OperationOption
- func Response(httpStatus int, structure any, options ...ContentOption) OperationOption
- func Security(securityName string, scopes ...string) OperationOption
- func Summary(summary string) OperationOption
- func Tags(tags ...string) OperationOption
- type RouteConfig
- type RouteOption
- type RouteSecurityConfig
- type SecurityOption
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentConfig ¶
type ContentConfig struct {
Structure any
ContentType string
// HTTPStatus can have values 100-599 for single status, or 1-5 for status families (e.g. 2XX)
HTTPStatus int
}
ContentConfig defines the structure for OpenAPI content configuration.
type ContentOption ¶
type ContentOption func(cu *ContentConfig)
ContentOption is a function that modifies the ContentConfig.
func WithContentType ¶
func WithContentType(contentType string) ContentOption
WithContentType sets the content type for the OpenAPI content.
type OpenAPIOption ¶
func WithBaseURL ¶
func WithBaseURL(baseURL string) OpenAPIOption
WithBaseURL sets the base URL for the OpenAPI documentation.
func WithDebug ¶
func WithDebug(debug ...bool) OpenAPIOption
WithDebug enables or disables debug logging for OpenAPI operations.
func WithDescription ¶
func WithDescription(description string) OpenAPIOption
WithDescription sets the description for the OpenAPI documentation.
func WithDisableOpenAPI ¶
func WithDisableOpenAPI(disable ...bool) OpenAPIOption
WithDisableOpenAPI disables the OpenAPI documentation generation. By default, OpenAPI documentation generation is enabled. If set to true, the OpenAPI documentation will not be generated.
This can be useful in production environments where you want to disable the documentation.
func WithDocsPath ¶
func WithDocsPath(path string) OpenAPIOption
WithDocsPath sets the path for the OpenAPI documentation.
func WithOpenAPIVersion ¶
func WithOpenAPIVersion(version string) OpenAPIOption
WithOpenAPIVersion sets the OpenAPI version for the documentation. The default version is "3.1.0". Supported versions are "3.0.0" and "3.1.0".
func WithSecurity ¶
func WithSecurity(name string, opts ...SecurityOption) OpenAPIOption
WithSecurity adds a security scheme to the OpenAPI documentation.
It can be used to define API key or HTTP Bearer authentication schemes.
func WithServer ¶
func WithServer(url string, opts ...ServerOption) OpenAPIOption
WithServer adds a server to the OpenAPI documentation.
func WithSwaggerConfig ¶
func WithSwaggerConfig(cfg ...*spec.SwaggerConfig) OpenAPIOption
WithSwagger sets the configuration for Swagger UI.
func WithTitle ¶
func WithTitle(title string) OpenAPIOption
WithTitle sets the title for the OpenAPI documentation.
func WithVersion ¶
func WithVersion(version string) OpenAPIOption
WithVersion sets the version for the OpenAPI documentation.
type OperationConfig ¶
type OperationConfig struct {
Hide bool
OperationID string
Description string
Summary string
Deprecated bool
Tags []string
Security []RouteSecurityConfig
Requests []*ContentConfig
Responses []*ContentConfig
}
OperationConfig holds the configuration for an OpenAPI operation.
type OperationOption ¶
type OperationOption func(*OperationConfig)
Operation is a function that configures an OpenAPI operation.
func Deprecated ¶
func Deprecated(deprecated ...bool) OperationOption
Deprecated marks the operation as deprecated in the OpenAPI documentation.
func Description ¶
func Description(description string) OperationOption
Description sets the description for the OpenAPI operation.
func Hide ¶
func Hide(hide ...bool) OperationOption
Hide marks the operation as hidden in the OpenAPI documentation. This is useful for operations that should not be exposed to the public API.
func Request ¶
func Request(structure any, options ...ContentOption) OperationOption
Request adds a request structure to the OpenAPI operation.
func Response ¶
func Response(httpStatus int, structure any, options ...ContentOption) OperationOption
Response adds a response structure to the OpenAPI operation.
func Security ¶
func Security(securityName string, scopes ...string) OperationOption
Security adds security requirements to the OpenAPI operation.
func Summary ¶
func Summary(summary string) OperationOption
Summary sets the summary for the OpenAPI operation.
type RouteConfig ¶
type RouteConfig struct {
Tags []string
Security []RouteSecurityConfig
Hide bool
}
Operation is a function that configures an OpenAPI operation.
type RouteOption ¶
type RouteOption func(*RouteConfig)
RouteOption is a function that applies configuration to a RouteConfig.
func RouteHide ¶
func RouteHide(hide ...bool) RouteOption
RouteHide marks the route as hidden in the OpenAPI documentation. This is useful for routes that should not be exposed to the public API.
It will hide all routes in the sub-router. If you want to hide only specific routes, use the `With` method on the route
func RouteSecurity ¶
func RouteSecurity(securityName string, scopes ...string) RouteOption
RouteSecurity adds security schemes to the route.
It will add security schemes to all routes in the sub-router.
func RouteTags ¶
func RouteTags(tags ...string) RouteOption
RouteTags adds tags to the route.
It will add tags to all routes in the sub-router.
type RouteSecurityConfig ¶
RouteSecurityConfig holds the security configuration for a route.
type SecurityOption ¶
type SecurityOption func(*securityConfig)
SecurityOption is a function that applies configuration to a securityConfig.
func SecurityAPIKey ¶
func SecurityAPIKey(name string, in spec.SecuritySchemeAPIKeyIn) SecurityOption
SecurityAPIKey creates a security scheme for API key authentication.
func SecurityDescription ¶
func SecurityDescription(description string) SecurityOption
SecurityDescription sets the description for the security scheme.
func SecurityHTTPBearer ¶
func SecurityHTTPBearer(scheme ...string) SecurityOption
SecurityHTTPBearer creates a security scheme for HTTP Bearer authentication.
func SecurityOAuth2 ¶
func SecurityOAuth2(flows spec.OAuthFlows) SecurityOption
SecurityOAuth2 creates a security scheme for OAuth 2.0 authentication.
type ServerOption ¶
func ServerDescription ¶
func ServerDescription(description string) ServerOption
func ServerVariables ¶
func ServerVariables(variables map[string]spec.ServerVariable) ServerOption