loader

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenAPIPatternToChi

func OpenAPIPatternToChi(pattern string) string

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

type SchemaInfo struct {
	Spec   *openapi3.T
	Prefix string
}

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.

Jump to

Keyboard shortcuts

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