apispec

package
v0.2.711 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 9 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

Overview

Package apispec embeds Cloudflare's official OpenAPI spec and a compact, generated table of every API operation in it (ops_gen.go).

Regenerate the table with `go generate ./...`; refresh the vendored spec with `make spec` (scripts/update-spec.sh).

Index

Constants

View Source
const (
	SpecRepo    = "https://github.com/cloudflare/api-schemas"
	SpecCommit  = "37e7a4ae9c5123a2c58929a100c42cb4584edc57"
	SpecDate    = "2026-10-02T19:35:42+00:00"
	SpecOpenAPI = "3.0.3"
	SpecVersion = "4.0.0"
)

Spec source, recorded by `go run ./gen -import`.

Variables

This section is empty.

Functions

func Describe

func Describe(o *Op, command string) (string, error)

Describe renders a human-readable description of an operation: method, path, params, and request body schema with an example skeleton.

func Spec

func Spec() (map[string]any, error)

Spec returns the parsed embedded OpenAPI document (parsed once, lazily; ~13 MB of JSON, so only describe-style commands should need it).

func SpecJSON

func SpecJSON(w io.Writer) error

SpecJSON writes the decompressed embedded spec to w.

func SpecSize

func SpecSize() int

SpecSize returns the compressed size of the embedded spec.

Types

type Op

type Op struct {
	// ID is the OpenAPI operationId (unique).
	ID     string
	Method string
	// Path is the templated path under /client/v4, e.g. /zones/{zone_id}/dns_records.
	Path string
	// Tag is the operation's first OpenAPI tag; TagSlug its CLI name.
	Tag, TagSlug string
	// Slug is the operation's CLI name, unique within TagSlug.
	Slug    string
	Summary string
	// Desc is the first line of the description.
	Desc       string
	Deprecated bool
	// Confirm is set when the spec marks the operation as needing confirmation
	// (x-forge-require-confirmation).
	Confirm bool
	// Params: path params in path order, then query, header, cookie.
	Params []Param
	// BodyTypes lists request body content types, most CLI-friendly first.
	BodyTypes    []string
	BodyRequired bool
}

Op is one Cloudflare API operation (an OpenAPI path + method).

func ByID

func ByID(id string) (*Op, bool)

ByID returns the operation with the given operationId.

func Find

func Find(tagSlug, slug string) (*Op, bool)

Find returns the operation with the given tag slug and op slug.

func Ops

func Ops() []Op

Ops returns every operation, in path then method order.

func Search(words []string) []Op

Search returns operations matching every word (case-insensitive) in operationId, summary, path, tag, or slugs.

func (*Op) HasBody

func (o *Op) HasBody() bool

HasBody reports whether the operation takes a request body.

func (*Op) HeaderParams

func (o *Op) HeaderParams() []Param

HeaderParams returns the header parameters.

func (*Op) PathParams

func (o *Op) PathParams() []Param

PathParams returns the path parameters in path order.

func (*Op) QueryParams

func (o *Op) QueryParams() []Param

QueryParams returns the query parameters.

type Param

type Param struct {
	Name string
	// In is "path", "query", "header", or "cookie".
	In string
	// Type is the JSON schema type: string, integer, number, boolean,
	// object, or array<T>.
	Type     string
	Required bool
	Enum     []string
	Default  string
	// Desc is the first line of the parameter's description.
	Desc string
}

Param is one operation parameter.

func (Param) IsArray

func (p Param) IsArray() bool

IsArray reports whether the parameter takes repeated values.

type Tag

type Tag struct {
	Name, Slug string
	Ops        int
}

Tag is a tag with its operation count.

func Tags

func Tags() []Tag

Tags returns every tag, sorted by slug.

Directories

Path Synopsis
Command gen builds internal/apispec/ops_gen.go from the vendored Cloudflare OpenAPI spec (internal/apispec/openapi.json.gz).
Command gen builds internal/apispec/ops_gen.go from the vendored Cloudflare OpenAPI spec (internal/apispec/openapi.json.gz).

Jump to

Keyboard shortcuts

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