Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenAPIPatternToChi ¶
OpenAPIPatternToChi converts an OpenAPI path pattern (with {param}) to a Chi pattern. Chi supports both {param} and :param syntax. We keep the OpenAPI braces.
Types ¶
type RouteMapping ¶
type RouteMapping struct {
Method string
Path string // The full path pattern with prefix (e.g., "/v1/users/{id}")
Pattern string // The path pattern without prefix (e.g., "/users/{id}")
Prefix string // The prefix for this route (e.g., "/v1")
ChiPattern string // Path converted to Chi pattern (e.g., "/v1/users/:id")
Operation *openapi3.Operation
Parameters openapi3.Parameters
Responses *openapi3.Responses
}
RouteMapping holds a mapping from HTTP method and path pattern to an OpenAPI operation.
func BuildRouteMappings ¶
func BuildRouteMappings(infos []SchemaInfo) ([]RouteMapping, error)
BuildRouteMappings creates route mappings from loaded schemas. For each schema, each path in the schema is combined with the schema's prefix to produce the full path pattern used for routing.
func FindOperation ¶
func FindOperation(mappings []RouteMapping, method, path string) (*RouteMapping, map[string]string, bool)
FindOperation finds the operation that matches the given method and path. It returns the route mapping and extracted path parameters.
type SchemaInfo ¶
SchemaInfo holds a loaded OpenAPI spec and its path prefix.
func LoadSchemas ¶
func LoadSchemas(sources []string, prefixes []string) ([]SchemaInfo, error)
LoadSchemas loads multiple OpenAPI schemas from file paths. Each source path is paired with a prefix (empty string for no prefix). Returns a slice of SchemaInfo in the same order as sources.