spec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 13 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 spec loads raw API spec bytes from a file or an http(s) URL, with size and time limits (SPEC §5.3, T2). It does not parse the spec; see package openapi.

Index

Constants

View Source
const (
	DefaultMaxBytes = 20 << 20
	DefaultTimeout  = 15 * time.Second
)

Default limits for loading a spec.

Variables

View Source
var (
	ErrTooLarge          = errors.New("spec exceeds size limit")
	ErrEmpty             = errors.New("spec is empty")
	ErrNotRegular        = errors.New("spec path is not a regular file")
	ErrUnsupportedScheme = errors.New("unsupported spec location scheme (use a file path or an http(s) URL)")
	ErrHTTPStatus        = errors.New("unexpected HTTP status fetching spec")
)

Sentinel errors callers can match with errors.Is.

Functions

This section is empty.

Types

type Format

type Format int

Format is the serialization of a spec document.

const (
	JSON Format = iota + 1
	YAML
)

Spec formats.

func (Format) String

func (f Format) String() string

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader loads specs. Create it with New.

func New

func New(opts Options) *Loader

New returns a Loader whose URL fetches go through PlugIt's hardened client.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context, location string) (*Spec, error)

Load reads the spec at location: an http:// or https:// URL, or a local file path. Other URL schemes, including file://, are rejected.

type Options

type Options struct {
	AllowPrivate bool
	MaxBytes     int64
	Timeout      time.Duration
}

Options configures a Loader. The zero value is the secure default.

type Spec

type Spec struct {
	Bytes  []byte
	SHA256 string
	Format Format
	Source string
}

Spec is a loaded spec document.

Jump to

Keyboard shortcuts

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