internal

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, item string) bool

Contains checks if a slice contains a string (case-insensitive)

func ExtractReferenceName

func ExtractReferenceName(ref string) (string, error)

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

func IsEnumSchema(schema *base.Schema) bool

IsEnumSchema returns true if schema defines an enum

func PropertyError

func PropertyError(schemaName, propertyName, message string) error

PropertyError creates an error with schema and property context. Format: schema '<schema>': property '<prop>' <message>

func SanitizeFieldName

func SanitizeFieldName(name string) (string, error)

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

func SchemaError(schemaName, message string) error

SchemaError creates an error with schema context. Format: schema '<name>': <message>

func ToEnumValueName

func ToEnumValueName(enumName, value string) string

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

func ToPascalCase(s string) string

ToPascalCase converts snake_case/camelCase/ALLCAPS to PascalCase. Examples: user_id → UserId, shippingAddress → ShippingAddress, USER → User

func ToSnakeCase

func ToSnakeCase(s string) string

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

func UnsupportedError(schemaName, propertyName, feature string) error

UnsupportedError creates an error for unsupported features. Format: schema '<schema>': property '<prop>' uses '<feature>' which is not supported

func UnsupportedSchemaError

func UnsupportedSchemaError(schemaName, feature string) error

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 NewNameTracker

func NewNameTracker() *NameTracker

NewNameTracker creates a new NameTracker.

func (*NameTracker) UniqueName

func (nt *NameTracker) UniqueName(name string) string

UniqueName returns a unique name, adding numeric suffix if needed (_2, _3, etc.).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL