schema

package
v1.261201.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndpointCount added in v1.260519.0

func EndpointCount() (int, error)

EndpointCount returns the number of endpoints in the embedded schema index.

func IsQueryParameterName

func IsQueryParameterName(name string) (bool, error)

IsQueryParameterName reports whether any operation in the embedded schema index defines a query parameter named name.

func NewSchemaCommand

func NewSchemaCommand(d *shared.Deps) *ffcli.Command

NewSchemaCommand returns the schema command built on d.

func PathTemplate

func PathTemplate(path string) (string, bool, error)

PathTemplate returns the path template of the embedded schema index that a concrete request path matches, whatever the method, and whether one did. Template segments such as {id} match any single non-empty segment; a query string on path is ignored. The returned template is always a string from the index, never part of path.

Types

type Endpoint

type Endpoint struct {
	Method               string                         `json:"method"`
	Path                 string                         `json:"path"`
	Parameters           []Parameter                    `json:"parameters,omitempty"`
	RequestSchema        string                         `json:"requestSchema,omitempty"`
	RequestAttributes    map[string]any                 `json:"requestAttributes,omitempty"`
	RequestRelationships map[string]RequestRelationship `json:"requestRelationships,omitempty"`
	ResponseSchema       string                         `json:"responseSchema,omitempty"`
	// contains filtered or unexported fields
}

Endpoint is a compact representation of an API endpoint.

func MatchOperation

func MatchOperation(method, path string) (Endpoint, bool, error)

MatchOperation reports the indexed endpoint whose method and templated path match a concrete request path. Template segments such as {id} match any single non-empty path segment. The path may carry a query string, which is ignored, and a trailing slash.

type NearOperation

type NearOperation struct {
	Endpoint
	Correction bool
}

NearOperation is an indexed operation that resembles a request. Correction reports that it has the request's method and the request's shape but names the API version or one literal segment differently: a misspelling, a plural, reordered or missing words, or an expanded abbreviation.

func NearestOperations

func NearestOperations(method, path string, limit int) ([]NearOperation, error)

NearestOperations ranks indexed endpoints by how closely they resemble the requested method and path and returns up to limit of them. Endpoints whose template matches the whole path under a different method rank first, then corrections (see NearOperation), then endpoints sharing the longest leading segment run. The API version segment is compared loosely, so /v1 and /v2 templates compete on their resource segments. An endpoint must share at least the resource segment or be a correction, so a request naming a resource the index does not know returns nothing. Ties prefer the requested method, then the requested API version, then the smallest edit distance between the first differing segments, then the smallest length difference.

type Parameter

type Parameter struct {
	Name     string   `json:"name"`
	In       string   `json:"in"`
	Enum     []string `json:"enum,omitempty"`
	Required bool     `json:"required,omitempty"`
}

Parameter describes a query/path parameter.

type RequestRelationship added in v1.260722.0

type RequestRelationship struct {
	ResourceType string `json:"resourceType"`
	Cardinality  string `json:"cardinality"`
	Required     bool   `json:"required"`
}

RequestRelationship describes a JSON:API relationship accepted by a request.

Jump to

Keyboard shortcuts

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