Documentation
¶
Index ¶
- Variables
- type DetectedPagination
- func DetectPaginationInParams(params *yaml.Node) []DetectedPagination
- func DetectPaginationInParamsWithDoc(params *yaml.Node, doc *yaml.Node) []DetectedPagination
- func DetectPaginationInResponses(responses *yaml.Node) []DetectedPagination
- func DetectPaginationInResponsesWithDoc(responses *yaml.Node, doc *yaml.Node) []DetectedPagination
- type EndpointPaginationRule
- type Options
- type ProcessResult
- func ProcessEndpoint(operation *yaml.Node, opts Options) (*ProcessResult, error)
- func ProcessEndpointWithDoc(operation *yaml.Node, doc *yaml.Node, opts Options) (*ProcessResult, error)
- func ProcessEndpointWithPathAndMethod(operation *yaml.Node, doc *yaml.Node, endpoint, method string, opts Options) (*ProcessResult, error)
- type Strategy
Constants ¶
This section is empty.
Variables ¶
var PaginationStrategies = map[string]Strategy{ "checkpoint": { Params: []string{"from", "take", "after"}, Fields: []string{"next", "next_checkpoint"}, }, "offset": { Params: []string{"offset", "limit", "include_totals"}, Fields: []string{"total", "offset", "limit", "count"}, }, "page": { Params: []string{"page", "per_page", "include_totals"}, Fields: []string{"start", "limit", "total", "total_count", "page", "per_page"}, }, "cursor": { Params: []string{"cursor", "size"}, Fields: []string{"next_cursor", "has_more"}, }, "none": { Params: []string{}, Fields: []string{}, }, }
PaginationStrategies defines all supported pagination strategies Each strategy has specific parameters that trigger its detection and response fields that indicate its presence in API responses
Functions ¶
This section is empty.
Types ¶
type DetectedPagination ¶
type DetectedPagination struct {
Strategy string
Parameters []string // parameter names found
Fields []string // response field names found
}
DetectedPagination represents detected pagination in an endpoint
func DetectPaginationInParams ¶
func DetectPaginationInParams(params *yaml.Node) []DetectedPagination
DetectPaginationInParams detects pagination strategies in operation parameters
func DetectPaginationInParamsWithDoc ¶ added in v0.2.1
func DetectPaginationInParamsWithDoc(params *yaml.Node, doc *yaml.Node) []DetectedPagination
DetectPaginationInParamsWithDoc detects pagination strategies in operation parameters with document context for $ref resolution
func DetectPaginationInResponses ¶
func DetectPaginationInResponses(responses *yaml.Node) []DetectedPagination
DetectPaginationInResponses detects pagination strategies in operation responses
func DetectPaginationInResponsesWithDoc ¶
func DetectPaginationInResponsesWithDoc(responses *yaml.Node, doc *yaml.Node) []DetectedPagination
DetectPaginationInResponsesWithDoc detects pagination strategies with document context for $ref resolution
type EndpointPaginationRule ¶ added in v0.5.0
type EndpointPaginationRule struct {
Endpoint string // Endpoint pattern (supports wildcards like /api/v1/users/*)
Method string // HTTP method (GET, POST, etc.) - case insensitive
Pagination string // Pagination strategy (cursor, checkpoint, offset, page, none)
}
EndpointPaginationRule defines pagination configuration for specific endpoints Supports exact endpoint matching and wildcard patterns (e.g., /api/v1/users/*)
type Options ¶
type Options struct {
Priority []string // Global ordered list of pagination strategies by priority
EndpointRules []EndpointPaginationRule // Endpoint-specific pagination rules that override global priority
}
Options represents pagination transformation options
func (Options) GetPaginationStrategy ¶ added in v0.5.0
GetPaginationStrategy returns the pagination strategy for a specific endpoint and method It first checks for endpoint-specific rules, then falls back to global priority
Algorithm: 1. Iterate through EndpointRules in order of definition 2. For each rule, check if endpoint matches pattern and method matches (case-insensitive) 3. Return the specific pagination strategy as a single-item priority list if match found 4. If no endpoint rules match, return the global Priority list as fallback
Pattern Matching: - Exact match: "/api/users" matches only "/api/users" - Wildcard: "/api/users/*" matches "/api/users", "/api/users/123", "/api/users/123/posts", etc. - Base path: "/api/users/*" also matches "/api/users" (without trailing slash)
type ProcessResult ¶
type ProcessResult struct {
Changed bool
RemovedParams []string
RemovedResponses []string
ModifiedSchemas []string
}
ProcessResult contains the result of processing a single endpoint
func ProcessEndpoint ¶
func ProcessEndpoint(operation *yaml.Node, opts Options) (*ProcessResult, error)
ProcessEndpoint processes a single endpoint based on pagination priority
func ProcessEndpointWithDoc ¶
func ProcessEndpointWithDoc(operation *yaml.Node, doc *yaml.Node, opts Options) (*ProcessResult, error)
ProcessEndpointWithDoc processes a single endpoint with document context for $ref resolution
func ProcessEndpointWithPathAndMethod ¶ added in v0.5.0
func ProcessEndpointWithPathAndMethod(operation *yaml.Node, doc *yaml.Node, endpoint, method string, opts Options) (*ProcessResult, error)
ProcessEndpointWithPathAndMethod processes a single endpoint with path and method for endpoint-specific rules
This is the main entry point for endpoint-specific pagination processing. It: 1. Detects all pagination strategies present in the endpoint (params + responses) 2. Resolves the correct pagination strategy using endpoint-specific rules or global priority 3. Selects the best available strategy based on the resolved priority 4. Removes parameters and response fields that don't belong to the selected strategy
Parameters: - operation: YAML node containing the OpenAPI operation (parameters, responses, etc.) - doc: Complete OpenAPI document for $ref resolution (can be nil) - endpoint: The endpoint path (e.g., "/api/v1/users") - method: HTTP method (e.g., "GET", "POST") - case insensitive - opts: Options containing global priority and endpoint-specific rules
Returns: - ProcessResult with details of what was changed/removed - Error if processing failed