spec

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package spec brings a specification into the process and decides what it is.

Two questions, in this order: WHERE it comes from (file, URL, stdin) and WHAT it is (OpenAPI 3, Swagger 2, GraphQL schema). No dialect answers the first, and no source answers the second — which is why both live here, away from whoever interprets the content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Source string // where it came from, so errors can point somewhere useful
	Raw    []byte
	Kind   Kind
}

Document is the loaded specification, still raw, already knowing what it is.

func Load

func Load(ctx context.Context, source string, forced Kind) (*Document, error)

Load reads the spec from a file (`file://` or a plain path), an http(s) URL, or `-` (stdin). A non-empty `forced` beats detection — it exists for when the heuristic is wrong, so nobody is stuck with it.

type Kind

type Kind string

Kind is the specification's dialect.

const (
	KindOpenAPI Kind = "openapi" // OpenAPI 3.x or Swagger 2.0 (JSON or YAML)
	KindGraphQL Kind = "graphql" // GraphQL schema, as SDL or introspection
)

Jump to

Keyboard shortcuts

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