openapi

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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

func ExtractPathFromURL(fullURL string) string

ExtractPathFromURL extracts the API path from a full URL. Example: "https://tenant.auth0.com/api/v2/actions/actions" -> "/actions/actions".

func FindOperation

func FindOperation(doc *openapi3.T, method, path string) (*openapi3.Operation, error)

FindOperation finds an operation by HTTP method and path ("/actions/actions" or "actions/actions").

func GetDoc

func GetDoc() (*openapi3.T, error)

GetDoc returns the OpenAPI document from cache (in-memory then on-disk) or fetches it; returns a stale copy on failure.

func GetQueryParamSchema

func GetQueryParamSchema(operation *openapi3.Operation) *openapi3.Schema

GetQueryParamSchema builds a synthetic object schema from an operation's query parameters.

func GetRequestSchema

func GetRequestSchema(operation *openapi3.Operation) *openapi3.SchemaRef

GetRequestSchema returns the request body schema for an operation.

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

type ValidationResult struct {
	Valid  bool
	Errors []string
}

ValidationResult contains the result of schema validation.

Jump to

Keyboard shortcuts

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