Documentation
¶
Index ¶
- func Contains(slice []string, item string) bool
- func ExtractReferenceName(ref string) (string, error)
- func ExtractVariantNames(oneOf []*base.SchemaProxy) []string
- func IsEnumSchema(schema *base.Schema) bool
- func PropertyError(schemaName, propertyName, message string) error
- func SanitizeFieldName(name string) (string, error)
- func SchemaError(schemaName, message string) error
- func ToEnumValueName(enumName, value string) string
- func ToPascalCase(s string) string
- func ToSnakeCase(s string) string
- func UnsupportedError(schemaName, propertyName, feature string) error
- func UnsupportedSchemaError(schemaName, feature string) error
- type DependencyGraph
- func (g *DependencyGraph) AddDependency(from, to string)
- func (g *DependencyGraph) AddSchema(name string, proxy *base.SchemaProxy) error
- func (g *DependencyGraph) ComputeTransitiveClosure() (goTypes, protoTypes map[string]bool, reasons map[string]string)
- func (g *DependencyGraph) MarkUnion(schemaName, reason string, variants []string)
- func (g *DependencyGraph) Schemas() map[string]*base.SchemaProxy
- type NameTracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractReferenceName ¶
ExtractReferenceName extracts the schema name from a reference string. Example: "#/components/schemas/Address" → "Address"
func ExtractVariantNames ¶
func ExtractVariantNames(oneOf []*base.SchemaProxy) []string
ExtractVariantNames extracts schema names from oneOf variant references
func IsEnumSchema ¶
IsEnumSchema returns true if schema defines an enum
func PropertyError ¶
PropertyError creates an error with schema and property context. Format: schema '<schema>': property '<prop>' <message>
func SanitizeFieldName ¶
SanitizeFieldName sanitizes an OpenAPI field name for proto3 syntax. Preserves the original name structure when valid, only modifying to meet proto3 requirements:
- Must start with a letter (A-Z, a-z)
- Can contain letters, digits, underscores
- Invalid characters replaced with underscores
Returns error if name cannot be sanitized (e.g., starts with digit).
func SchemaError ¶
SchemaError creates an error with schema context. Format: schema '<name>': <message>
func ToEnumValueName ¶
ToEnumValueName converts a value to ENUM_PREFIX_VALUE_NAME format. Examples: (Status, active) → STATUS_ACTIVE, (Status, in-progress) → STATUS_IN_PROGRESS, (SortBy, createdAt) → SORT_BY_CREATED_AT
func ToPascalCase ¶
ToPascalCase converts snake_case/camelCase/ALLCAPS to PascalCase. Examples: user_id → UserId, shippingAddress → ShippingAddress, USER → User
func ToSnakeCase ¶
ToSnakeCase converts camelCase/PascalCase to snake_case. Algorithm: Each uppercase letter becomes lowercase with underscore prefix (except first char). Examples: userId → user_id, HTTPStatus → h_t_t_p_status, email → email
func UnsupportedError ¶
UnsupportedError creates an error for unsupported features. Format: schema '<schema>': property '<prop>' uses '<feature>' which is not supported
func UnsupportedSchemaError ¶
UnsupportedSchemaError creates an error for unsupported features at the schema level. Format: schema '<name>': uses '<feature>' which is not supported
Types ¶
type DependencyGraph ¶
type DependencyGraph struct {
// contains filtered or unexported fields
}
DependencyGraph tracks schema dependencies and union types for transitive closure computation
func NewDependencyGraph ¶
func NewDependencyGraph() *DependencyGraph
NewDependencyGraph creates a new dependency graph
func (*DependencyGraph) AddDependency ¶
func (g *DependencyGraph) AddDependency(from, to string)
AddDependency records that 'from' schema references 'to' schema
func (*DependencyGraph) AddSchema ¶
func (g *DependencyGraph) AddSchema(name string, proxy *base.SchemaProxy) error
AddSchema registers a schema in the graph
func (*DependencyGraph) ComputeTransitiveClosure ¶
func (g *DependencyGraph) ComputeTransitiveClosure() (goTypes, protoTypes map[string]bool, reasons map[string]string)
ComputeTransitiveClosure performs BFS to find all schemas that should be Go-only Returns goTypes (Go-only schemas), protoTypes (proto schemas), and reasons
func (*DependencyGraph) MarkUnion ¶
func (g *DependencyGraph) MarkUnion(schemaName, reason string, variants []string)
MarkUnion marks a schema as containing a union with the given reason and variant names
func (*DependencyGraph) Schemas ¶
func (g *DependencyGraph) Schemas() map[string]*base.SchemaProxy
Schemas returns the schemas map for external package access
type NameTracker ¶
type NameTracker struct {
// contains filtered or unexported fields
}
NameTracker tracks used names and generates unique names when conflicts occur.
func (*NameTracker) UniqueName ¶
func (nt *NameTracker) UniqueName(name string) string
UniqueName returns a unique name, adding numeric suffix if needed (_2, _3, etc.).