Documentation
¶
Index ¶
- Constants
- func ExtractPathFromURL(fullURL string) string
- func FindOperation(doc *openapi3.T, method, path string) (*openapi3.Operation, error)
- func GetDoc() (*openapi3.T, error)
- func GetQueryParamSchema(operation *openapi3.Operation) *openapi3.Schema
- func GetRequestSchema(operation *openapi3.Operation) *openapi3.SchemaRef
- type OperationSchema
- type SchemaManager
- type ValidationResult
Constants ¶
const ( // SchemaURL is the URL to the Auth0 Management API OpenAPI schema. SchemaURL = "https://auth0.com/docs/oas/management/v2/management-api-oas.json" // CacheTTL is how long to cache the schema before re-fetching. CacheTTL = 3 * 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func ExtractPathFromURL ¶
ExtractPathFromURL extracts the API path from a full URL. Example: "https://tenant.auth0.com/api/v2/actions/actions" -> "/actions/actions".
func FindOperation ¶
FindOperation finds an operation by HTTP method and path ("/actions/actions" or "actions/actions").
func GetDoc ¶
GetDoc returns the OpenAPI document from cache (in-memory then on-disk) or fetches it; returns a stale copy on failure.
func GetQueryParamSchema ¶
GetQueryParamSchema builds a synthetic object schema from an operation's query parameters.
Types ¶
type OperationSchema ¶
type OperationSchema struct {
OperationID string
Summary string
Description string
Method string
Path string
RequestSchema *openapi3.Schema
IsQueryParamSchema bool
}
OperationSchema contains schema information for an API operation.
func (*OperationSchema) FormatAsJSON ¶
func (op *OperationSchema) FormatAsJSON() (string, error)
FormatAsJSON formats the schema as JSON for display.
func (*OperationSchema) FormatAsText ¶
func (op *OperationSchema) FormatAsText() string
FormatAsText formats the schema as human-readable text.
type SchemaManager ¶
type SchemaManager struct {
// contains filtered or unexported fields
}
SchemaManager provides access to OpenAPI operation schemas and request validation.
func NewSchemaManager ¶
func NewSchemaManager() (*SchemaManager, error)
NewSchemaManager creates a new schema manager backed by the cached OpenAPI document.
func (*SchemaManager) EnhanceError ¶
func (sm *SchemaManager) EnhanceError(err error, method, path string) error
EnhanceError appends the expected request schema to a 400 Bad Request error. Non-400 errors are returned unchanged.
func (*SchemaManager) GetOperationSchema ¶
func (sm *SchemaManager) GetOperationSchema(method, path string) (*OperationSchema, error)
GetOperationSchema returns the schema information for an operation.
func (*SchemaManager) ValidateRequest ¶
func (sm *SchemaManager) ValidateRequest(method, path string, body []byte) (*ValidationResult, error)
ValidateRequest validates a request using openapi3filter.
type ValidationResult ¶
ValidationResult contains the result of schema validation.