Documentation
¶
Index ¶
- Constants
- type Config
- type Generator
- type Logger
- type NoopLogger
- type OAuthFlows
- type OAuthFlowsDefsAuthorizationCode
- type OAuthFlowsDefsClientCredentials
- type OAuthFlowsDefsImplicit
- type OAuthFlowsDefsPassword
- type OperationContext
- type Reflector
- type SecurityScheme
- type SecuritySchemeAPIKey
- type SecuritySchemeAPIKeyIn
- type SecuritySchemeHTTPBearer
- type SecuritySchemeOAuth2
- type Server
- type ServerVariable
- type Spec
- type SwaggerConfig
Constants ¶
const ( SecuritySchemeAPIKeyInQuery = SecuritySchemeAPIKeyIn("query") SecuritySchemeAPIKeyInHeader = SecuritySchemeAPIKeyIn("header") SecuritySchemeAPIKeyInCookie = SecuritySchemeAPIKeyIn("cookie") )
SecuritySchemeAPIKeyIn values enumeration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
OpenAPIVersion string // OpenAPI version, e.g., "3.1.0"
Title string
Version string
Description *string
Servers []Server
SecuritySchemes map[string]*SecurityScheme
DisableOpenAPI bool
BaseURL string
DocsPath string
SwaggerConfig *SwaggerConfig
Logger Logger
}
Config holds the configuration for OpenAPI documentation generation.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is responsible for generating OpenAPI documentation.
func NewGenerator ¶
NewGenerator creates a new Generator instance with the provided configuration.
func (*Generator) AddOperation ¶
func (g *Generator) AddOperation(ctx OperationContext) error
AddOperation adds an operation to the OpenAPI documentation.
func (*Generator) GenerateSchema ¶
GenerateSchema generates the OpenAPI schema in the specified format (JSON or YAML).
func (*Generator) NewOperationContext ¶
func (g *Generator) NewOperationContext(method, path string) (OperationContext, error)
NewOperationContext creates a new operation context for the specified method and path.
func (*Generator) WriteSchemaTo ¶
WriteSchemaTo writes the OpenAPI schema to the specified file path.
type NoopLogger ¶
type NoopLogger struct{}
func (NoopLogger) Printf ¶
func (l NoopLogger) Printf(format string, v ...any)
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlowsDefsImplicit
Password *OAuthFlowsDefsPassword
ClientCredentials *OAuthFlowsDefsClientCredentials
AuthorizationCode *OAuthFlowsDefsAuthorizationCode
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
OAuthFlows structure is generated from "#/$defs/oauth-flows".
type OAuthFlowsDefsAuthorizationCode ¶
type OAuthFlowsDefsAuthorizationCode struct {
// Format: uri.
// Required.
AuthorizationURL string
// Format: uri.
// Required.
TokenURL string
RefreshURL *string // Format: uri.
Scopes map[string]string // Required.
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
OAuthFlowsDefsAuthorizationCode structure is generated from "#/$defs/oauth-flows/$defs/authorization-code".
type OAuthFlowsDefsClientCredentials ¶
type OAuthFlowsDefsClientCredentials struct {
// Format: uri.
// Required.
TokenURL string
RefreshURL *string // Format: uri.
Scopes map[string]string // Required.
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
OAuthFlowsDefsClientCredentials structure is generated from "#/$defs/oauth-flows/$defs/client-credentials".
type OAuthFlowsDefsImplicit ¶
type OAuthFlowsDefsImplicit struct {
// Format: uri.
// Required.
AuthorizationURL string
RefreshURL *string // Format: uri.
Scopes map[string]string // Required.
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
OAuthFlowsDefsImplicit structure is generated from "#/$defs/oauth-flows/$defs/implicit".
type OAuthFlowsDefsPassword ¶
type OAuthFlowsDefsPassword struct {
// Format: uri.
// Required.
TokenURL string
RefreshURL *string // Format: uri.
Scopes map[string]string // Required.
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
OAuthFlowsDefsPassword structure is generated from "#/$defs/oauth-flows/$defs/password".
type OperationContext ¶
type OperationContext interface {
openapi.OperationContext
OpenAPIOperationContext() openapi.OperationContext
}
type Reflector ¶
type Reflector interface {
AddOperation(oc OperationContext) error
NewOperationContext(method, path string) (OperationContext, error)
Spec() Spec
}
type SecurityScheme ¶
type SecurityScheme struct {
Description *string
APIKey *SecuritySchemeAPIKey
HTTPBearer *SecuritySchemeHTTPBearer
OAuth2 *SecuritySchemeOAuth2
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
SecurityScheme structure is generated from "#/$defs/security-scheme".
type SecuritySchemeAPIKey ¶
type SecuritySchemeAPIKey struct {
Name string // Required.
In SecuritySchemeAPIKeyIn // Required.
}
SecuritySchemeAPIKey structure is generated from "#/$defs/security-scheme/$defs/type-apikey".
type SecuritySchemeAPIKeyIn ¶
type SecuritySchemeAPIKeyIn string
SecuritySchemeAPIKeyIn is an enum type.
type SecuritySchemeHTTPBearer ¶
type SecuritySchemeHTTPBearer struct {
// Value must match pattern: `^[Bb][Ee][Aa][Rr][Ee][Rr]$`.
// Required.
Scheme string `json:"scheme"`
BearerFormat *string `json:"bearerFormat,omitempty"`
}
SecuritySchemeHTTPBearer structure is generated from "#/$defs/security-scheme/$defs/type-http-bearer".
type SecuritySchemeOAuth2 ¶
type SecuritySchemeOAuth2 struct {
Flows OAuthFlows // Required.
}
SecuritySchemeOAuth2 structure is generated from "#/$defs/security-scheme/$defs/type-oauth2".
type Server ¶
type Server struct {
// Format: uri-reference.
// Required.
URL string
Description *string
Variables map[string]ServerVariable
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
Server structure is generated from "#/$defs/server".
type ServerVariable ¶
type ServerVariable struct {
Enum []string
Default string // Required.
Description *string
MapOfAnything map[string]any // Key must match pattern: `^x-`.
}
ServerVariable structure is generated from "#/$defs/server-variable".
type SwaggerConfig ¶
type SwaggerConfig struct {
ShowTopBar bool
HideCurl bool
JsonEditor bool
PreAuthorizeApiKey map[string]string
// SettingsUI contains keys and plain javascript values of SwaggerUIBundle configuration.
// Overrides default values.
// See https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ for available options.
SettingsUI map[string]string
// Proxy enables proxying requests through swgui handler.
// Can be useful if API is not directly available due to CORS policy.
Proxy bool
}
SwaggerConfig holds the configuration for Swagger UI.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
chiopenapi
module
|
|
|
echoopenapi
module
|
|
|
fiberopenapi
module
|
|
|
ginopenapi
module
|
|
|
httpopenapi
module
|
|
|
httprouteropenapi
module
|
|
|
muxopenapi
module
|
|
|
adapters
|
|
|
chiopenapi
module
|
|
|
echoopenapi
module
|
|
|
fiberopenapi
module
|
|
|
ginopenapi
module
|
|
|
httpopenapi
module
|
|
|
module
|
|
|
specui
module
|
|
|
pkg
|
|