Documentation
¶
Index ¶
- Constants
- type Config
- type Contact
- type ContentUnit
- type ExternalDocs
- type InterceptDefNameFunc
- type InterceptPropFunc
- type InterceptPropParams
- type InterceptSchemaFunc
- type InterceptSchemaParams
- type License
- type Logger
- type OAuthFlows
- type OAuthFlowsAuthorizationCode
- type OAuthFlowsClientCredentials
- type OAuthFlowsImplicit
- type OAuthFlowsPassword
- type ParameterIn
- type PathParser
- type ReflectorConfig
- type SecurityScheme
- type SecuritySchemeAPIKey
- type SecuritySchemeAPIKeyIn
- type SecuritySchemeHTTPBearer
- type SecuritySchemeOAuth2
- type Server
- type ServerVariable
- type Tag
- type TypeMapping
Constants ¶
const ( // SecuritySchemeAPIKeyInQuery specifies the key is passed in the query string. SecuritySchemeAPIKeyInQuery = SecuritySchemeAPIKeyIn("query") // SecuritySchemeAPIKeyInHeader specifies the key is passed in a header. SecuritySchemeAPIKeyInHeader = SecuritySchemeAPIKeyIn("header") // SecuritySchemeAPIKeyInCookie specifies the key is passed in a cookie. SecuritySchemeAPIKeyInCookie = SecuritySchemeAPIKeyIn("cookie") )
const ( ParameterInPath = ParameterIn("path") ParameterInQuery = ParameterIn("query") ParameterInHeader = ParameterIn("header") ParameterInCookie = ParameterIn("cookie") )
ParameterIn 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 // Title of the API.
Version string // Version of the API.
Description *string // Optional description of the API.
Contact *Contact // Contact information for the API.
License *License // License information for the API.
TermsOfService *string // Terms of service URL.
Servers []Server // List of API servers.
SecuritySchemes map[string]*SecurityScheme // Security schemes available for the API.
Tags []Tag // Tags used to organize operations.
ExternalDocs *ExternalDocs // Additional external documentation.
ReflectorConfig *ReflectorConfig // Configuration for schema reflection.
DocsPath string // Path where the documentation will be served.
SpecPath string // Path for the OpenAPI specification JSON or YAML.
CacheAge *int // Cache age for OpenAPI specification responses.
DisableDocs bool // If true, disables serving OpenAPI docs.
Logger Logger // Logger for diagnostic output.
PathParser PathParser // Path parser for framework-specific path conversions.
UIProvider config.Provider // UI provider for the OpenAPI documentation.
SwaggerUIConfig *config.SwaggerUI // Configuration for embedded Swagger UI.
StoplightElementsConfig *config.StoplightElements // Configuration for Stoplight Elements.
ReDocConfig *config.ReDoc // Configuration for Redoc.
ScalarConfig *config.Scalar // Configuration for Scalar.
RapiDocConfig *config.RapiDoc // Configuration for RapiDoc.
}
Config defines the root configuration for OpenAPI documentation generation.
type Contact ¶
type Contact struct {
Name string // Contact name.
URL string // Contact URL. Format: uri.
Email string // Contact email. Format: email.
// MapOfAnything holds vendor extensions. Keys must match `^x-`.
MapOfAnything map[string]any
}
Contact represents contact information for the API. Generated from "#/$defs/contact".
type ContentUnit ¶ added in v0.2.0
type ContentUnit struct {
Structure any
HTTPStatus int
ContentType string // ContentType specifies the MIME type of the content.
IsDefault bool // IsDefault indicates if this content unit is the default response.
Description string // Description provides a description for the content unit.
Encoding map[string]string // Encoding maps property names to content types
}
ContentUnit defines the structure for OpenAPI content configuration.
type ExternalDocs ¶
type ExternalDocs struct {
Description string // Description of the documentation.
URL string // Required. Documentation URL. Format: uri.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
ExternalDocs describes external documentation for a tag or operation. Generated from "#/$defs/external-documentation".
type InterceptDefNameFunc ¶
InterceptDefNameFunc allows customizing schema definition names.
type InterceptPropFunc ¶
type InterceptPropFunc func(params InterceptPropParams) error
InterceptPropFunc allows customizing property schemas during generation.
type InterceptPropParams ¶
type InterceptPropParams struct {
Context *jsonschema.ReflectContext // Reflection context.
Path []string // Path to the property.
Name string // Property name.
Field reflect.StructField // Struct field being processed.
PropertySchema *jsonschema.Schema // Generated property schema.
ParentSchema *jsonschema.Schema // Parent object schema.
Processed bool // True if the property was already processed.
}
InterceptPropParams holds information for intercepting property generation.
type InterceptSchemaFunc ¶
type InterceptSchemaFunc func(params InterceptSchemaParams) (stop bool, err error)
InterceptSchemaFunc allows intercepting schema generation for entire types.
type InterceptSchemaParams ¶
type InterceptSchemaParams struct {
Context *jsonschema.ReflectContext // Reflection context.
Value reflect.Value // Value being reflected.
Schema *jsonschema.Schema // Generated schema.
Processed bool // True if the schema was already processed.
}
InterceptSchemaParams holds information for intercepting full schema generation.
type License ¶
type License struct {
Name string // License name (required).
Identifier string // SPDX identifier.
URL string // License URL. Format: uri.
// MapOfAnything holds vendor extensions. Keys must match `^x-`.
MapOfAnything map[string]any
}
License provides license information for the API. Generated from "#/$defs/license".
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlowsImplicit
Password *OAuthFlowsPassword
ClientCredentials *OAuthFlowsClientCredentials
AuthorizationCode *OAuthFlowsAuthorizationCode
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
OAuthFlows groups supported OAuth2 flows. Generated from "#/$defs/oauth-flows".
type OAuthFlowsAuthorizationCode ¶ added in v0.2.0
type OAuthFlowsAuthorizationCode struct {
AuthorizationURL string // Required. Format: uri.
TokenURL string // Required. Token URL. Format: uri.
RefreshURL *string // Optional refresh URL. Format: uri.
Scopes map[string]string // Required. Available scopes.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
OAuthFlowsAuthorizationCode defines an OAuth2 authorization code flow. Generated from "#/$defs/oauth-flows/$defs/authorization-code".
type OAuthFlowsClientCredentials ¶ added in v0.2.0
type OAuthFlowsClientCredentials struct {
TokenURL string // Required. Token URL. Format: uri.
RefreshURL *string // Optional refresh URL. Format: uri.
Scopes map[string]string // Required. Available scopes.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
OAuthFlowsClientCredentials defines an OAuth2 client credentials flow. Generated from "#/$defs/oauth-flows/$defs/client-credentials".
type OAuthFlowsImplicit ¶ added in v0.2.0
type OAuthFlowsImplicit struct {
AuthorizationURL string // Required. Format: uri.
RefreshURL *string // Optional refresh URL. Format: uri.
Scopes map[string]string // Required. Available scopes.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
OAuthFlowsImplicit defines an OAuth2 implicit flow. Generated from "#/$defs/oauth-flows/$defs/implicit".
type OAuthFlowsPassword ¶ added in v0.2.0
type OAuthFlowsPassword struct {
TokenURL string // Required. Token URL. Format: uri.
RefreshURL *string // Optional refresh URL. Format: uri.
Scopes map[string]string // Required. Available scopes.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
OAuthFlowsPassword defines an OAuth2 password flow. Generated from "#/$defs/oauth-flows/$defs/password".
type PathParser ¶ added in v0.1.4
type PathParser interface {
// Parse converts a framework-style path to OpenAPI path syntax.
Parse(path string) (string, error)
}
PathParser defines an interface for converting router paths to OpenAPI paths.
Example:
Input: "/users/:id"
Output: "/users/{id}"
type ReflectorConfig ¶
type ReflectorConfig struct {
InlineRefs bool // If true, inline schema references instead of using components.
RootRef bool // If true, use a root reference for top-level schemas.
RootNullable bool // If true, allow root schemas to be nullable.
StripDefNamePrefix []string // Prefixes to strip from generated definition names.
InterceptDefNameFunc InterceptDefNameFunc // Function to customize definition names.
InterceptPropFunc InterceptPropFunc // Function to intercept property schema generation.
InterceptSchemaFunc InterceptSchemaFunc // Function to intercept full schema generation.
TypeMappings []TypeMapping // Custom type mappings for schema generation.
ParameterTagMapping map[ParameterIn]string // Custom struct tag mapping for parameters.
}
ReflectorConfig holds advanced options for schema reflection.
type SecurityScheme ¶
type SecurityScheme struct {
Description *string // Optional description.
APIKey *SecuritySchemeAPIKey // API key authentication scheme.
HTTPBearer *SecuritySchemeHTTPBearer // HTTP Bearer authentication scheme.
OAuth2 *SecuritySchemeOAuth2 // OAuth2 authentication scheme.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
SecurityScheme describes a security scheme that can be used by operations. Generated from "#/$defs/security-scheme".
type SecuritySchemeAPIKey ¶
type SecuritySchemeAPIKey struct {
Name string // Required. Name of the header, query, or cookie parameter.
In SecuritySchemeAPIKeyIn // Required. Location of the API key.
}
SecuritySchemeAPIKey defines an API key authentication scheme. Generated from "#/$defs/security-scheme/$defs/type-apikey".
type SecuritySchemeAPIKeyIn ¶
type SecuritySchemeAPIKeyIn string
SecuritySchemeAPIKeyIn specifies where the API key is passed.
type SecuritySchemeHTTPBearer ¶
type SecuritySchemeHTTPBearer struct {
Scheme string // Required. Must match pattern `^[Bb][Ee][Aa][Rr][Ee][Rr]$`.
BearerFormat *string // Optional bearer format hint.
}
SecuritySchemeHTTPBearer defines HTTP Bearer authentication. Generated from "#/$defs/security-scheme/$defs/type-http-bearer".
type SecuritySchemeOAuth2 ¶
type SecuritySchemeOAuth2 struct {
Flows OAuthFlows // Required. Supported OAuth2 flows.
}
SecuritySchemeOAuth2 defines OAuth2 flows. Generated from "#/$defs/security-scheme/$defs/type-oauth2".
type Server ¶
type Server struct {
URL string // Required. Server URL. Format: uri-reference.
Description *string // Optional server description.
Variables map[string]ServerVariable // Server variables for URL templates.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
Server describes an API server. Generated from "#/$defs/server".
type ServerVariable ¶
type ServerVariable struct {
Enum []string // Allowed values.
Default string // Required. Default value.
Description string // Variable description.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
ServerVariable describes a variable for server URL template substitution. Generated from "#/$defs/server-variable".
type Tag ¶
type Tag struct {
Name string // Tag name (required).
Description string // Tag description.
ExternalDocs *ExternalDocs // Additional external documentation.
MapOfAnything map[string]any // Vendor extensions. Keys must match `^x-`.
}
Tag adds metadata to an API operation. Generated from "#/definitions/Tag".
type TypeMapping ¶
TypeMapping maps a source type to a target type in schema generation.