Documentation
¶
Index ¶
- type Capabilities
- type Config
- type Contact
- type Discriminator
- type Encoding
- type Endpoint
- type ErrorSeverity
- type ExcludeConfig
- type Feature
- type GenerateConfig
- type GeneratedFile
- type GenerationError
- type GenerationResult
- type Generator
- type GeneratorMetadata
- type Header
- type License
- type Location
- type MediaType
- type Model
- type OAuthFlow
- type OAuthFlows
- type Parameter
- type Property
- type RefResolver
- type RequestBody
- type Response
- type SecurityRequirement
- type SecurityScheme
- type Spec
- type SpecInfo
- type Tag
- type TemplateConfig
- type TypeOverride
- type TypesConfig
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities struct {
SupportsClient bool // Can generate client code
SupportsServer bool // Can generate server code
SupportsValidation bool // Can generate validators
SupportsAsync bool // Supports async/await patterns
SupportsStreaming bool // Supports streaming (SSE, Websockets)
ClientFrameworks []string // Supported client frameworks
ServerFrameworks []string // Supported server frameworks
}
Capabilities describes what a generator can produce
type Config ¶
type Config struct {
// Source
SpecPath string
// Output
OutputDir string
// Generator selection
Generator string
// What to generate
Generate GenerateConfig
// Generator-specific options
Options map[string]interface{}
// Template customization
Templates TemplateConfig
// Exclusions
Exclude ExcludeConfig
// Custom type mappings
Types TypesConfig
}
type Discriminator ¶
type Encoding ¶
type Encoding struct {
ContentType string // e.g., "application/json" or "image/png"
}
type Endpoint ¶
type Endpoint struct {
Path string
Method string // GET, POST, PUT, DELETE, etc.
OperationID string
Summary string
Description string
Tags []string
Parameters []Parameter
RequestBody *RequestBody
Responses []Response
Security []SecurityRequirement
IsPublic bool // true when security: [] is set explicitly (no auth required)
IsDeprecated bool
}
type ErrorSeverity ¶
type ErrorSeverity int
const ( ErrorSeverityWarning ErrorSeverity = iota ErrorSeverityError ErrorSeverityFatal )
type ExcludeConfig ¶
type ExcludeConfig struct {
Models []string // model names to skip (exact match)
Tags []string // operation tags to skip
}
ExcludeConfig specifies models and tags to skip during generation.
type Feature ¶
type Feature string
Feature represents an OpeAPI feature
const ( FeatureNullable Feature = "nullable" FeatureDiscriminator Feature = "discriminator" FeatureOneOf Feature = "oneOf" FeatureAllOf Feature = "allOf" FeatureCallbacks Feature = "callbacks" FeatureWebhooks Feature = "webhooks" FeatureDeprecated Feature = "deprecated" FeatureExamples Feature = "examples" FeatureReadOnly Feature = "readOnly" FeatureWriteOnly Feature = "writeOnly" )
type GenerateConfig ¶
type GenerateConfig struct {
Models, Client, Server, Validation bool
}
type GeneratedFile ¶
type GenerationError ¶
type GenerationError struct {
Severity ErrorSeverity
Phase string // "parsing", "validation", "generation"
Location *Location
Message string
Hint string // Suggestion to fix
Code string // Error code (e.g., "E1001")
}
func (GenerationError) Error ¶
func (e GenerationError) Error() string
type GenerationResult ¶
type GenerationResult struct {
Files []GeneratedFile
Warnings []GenerationError
}
type Generator ¶
type Generator interface {
// Metadata returs informatio about this generator
Metadata() GeneratorMetadata
// Validate checks if the spec and config are valid for this generator
// Returns validation errors (does not stop on first error)
Validate(spec *Spec, config *Config) []ValidationError
// Generate produces code from the spec
Generate(spec *Spec, config *Config) (*GenerationResult, error)
// SupportedFeatures returns OpenAPI features this generator supports
SupportedFeatures() []Feature
}
Generator is the interface that all language generators must implement
type GeneratorMetadata ¶
type GeneratorMetadata struct {
Name string // Unique identifier (e.g., "go-generator")
Language string // Target language (e.g., "go", "typescript")
Version string // Semantic version
Description string // Human-readable description
Author string // Author/maintainer
Capabilities Capabilities // What this generator can produce
}
GeneratorMetadata describes the generator's capabilities
type Model ¶
type Model struct {
Name string
Description string
Type string // "object", "array", "string", etc.
Properties []Property
Required []string
Enum []interface{}
// For array type schemas
IsArray bool // true if this is an array schema
Items *Property // full items definition
// For map type schemas (additionalProperties)
IsMap bool // true if this is a map schema
AdditionalProps *Property // the type of map values
// Complex type handling
AllOf []Model
OneOf []Model
AnyOf []Model
// Metadata
Discriminator *Discriminator
IsDeprecated bool
Example interface{}
// Union type flags
IsOneOf bool
IsAnyOf bool
// Source location
SourcePath string // JSON Path in spec
}
type OAuthFlow ¶
type OAuthFlow struct {
AuthorizationURL string
TokenURL string
RefreshURL string
Scopes map[string]string
}
OAuthFlow represetns a single OAuth 2.0 flow
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlow
Password *OAuthFlow
ClientCredentials *OAuthFlow
AuthorizationCode *OAuthFlow
}
OAuthFlows represents OAuth 2.0 flow configurations
type Property ¶
type Property struct {
Name string
Type string
Format string
Description string
Required bool
Nullable bool
Enum []interface{} // Enum values if this is an enum
// Field metadata
Default interface{} // Default value
ReadOnly bool // Read-only field
WriteOnly bool // Write-only field
Deprecated bool // Deprecated field
// Constraints
Pattern string
MinLength *int
MaxLength *int
Minimum *float64
Maximum *float64
MinItems *int
MaxItems *int
UniqueItems bool
MultipleOf *float64
// For nested types
RefType string // Referenced type name (for $ref or nested objects)
Items *Property
// For objects
Properties []Property
// Additional properties for maps
AdditionalProperties *Property
Example interface{}
}
func (Property) HasConstraints ¶
HasConstraints returns true if the property has any spec-defined validation constraints.
type RequestBody ¶
type SecurityRequirement ¶
type SecurityScheme ¶
type SecurityScheme struct {
Type string // "apiKey", "http", "oauth2", "openIdConnect"
Description string
Name string // Scheme identifier (map key from spec, e.g. "bearerAuth")
ParameterName string // For apiKey: header/query/cookie parameter name (e.g. "X-API-Key")
In string // For apiKey: "header", "query", "cookie"
Scheme string // For http: "bearer", "basic", etc.
BearerFormat string // For http bearer
Flows *OAuthFlows
OpenIDConnectURL string
}
SecuritySchema represents an authentication/authorization schema
func (SecurityScheme) IsAPIKey ¶
func (s SecurityScheme) IsAPIKey() bool
IsAPIKey returns true if the scheme is an API key scheme.
func (SecurityScheme) IsBasicAuth ¶
func (s SecurityScheme) IsBasicAuth() bool
IsBasicAuth returns true if the scheme is HTTP Basic authentication.
func (SecurityScheme) IsBearer ¶
func (s SecurityScheme) IsBearer() bool
IsBearer returns true if the scheme is HTTP Bearer token.
func (SecurityScheme) IsOAuth2 ¶
func (s SecurityScheme) IsOAuth2() bool
IsOAuth2 returns true if the scheme is OAuth2.
type Spec ¶
type Spec struct {
Raw *openapi3.T
Info SpecInfo
Models []Model
Endpoints []Endpoint
Tags []Tag
SecurityDef []SecurityScheme
Version string // OpenAPI Version (e.g., "3.0.0")
// contains filtered or unexported fields
}
Spec represents a processed OpenAPI specification
type TemplateConfig ¶
type TypeOverride ¶
type TypeOverride struct {
Format string // OpenAPI format (e.g. "email", "uuid", "date-time")
Type string // OpenAPI type (e.g. "integer") — matched when Format is ""
Go string // Target Go type (e.g. "uuid.UUID", "EmailAddress")
}
TypeOverride maps an OpenAPI format or type to a custom Go type. Format takes precedence over Type when both are set.
type TypesConfig ¶
type TypesConfig struct {
Overrides []TypeOverride
}
TypesConfig holds custom OpenAPI → Go type mappings.
type ValidationError ¶
type ValidationError struct {
GenerationError
}