tundraopenapi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 5 Imported by: 0

README

tundra-openapi

The keystone typed model of an OpenAPI 3.0 specification — the single parsed-spec view downstream pleme-io tools import instead of each re-parsing.

What

A thin, stable, codegen-oriented facade over getkin/kin-openapi: load + validate a spec, get a deterministic operation index, the component schema universe, and Raw() for the full document. Spec-agnostic — point it at any OpenAPI 3.0 doc.

Why

SDK companions, client builders, IaC/Terraform generators, and doc emitters all need the same typed view of an API. tundra-openapi is that one shared model, so a fleet of generators stays consistent and no tool re-implements spec parsing.

Install

go get github.com/pleme-io/tundra-openapi

Nix (via substrate):

outputs = { self, nixpkgs, substrate, ... }:
  (import substrate.goLibraryFlakeBuilder { inherit nixpkgs; }) {
    name = "tundra-openapi"; version = "0.1.0"; src = self;
  };

Usage

spec, err := tundraopenapi.Load("openapi.yaml") // or LoadData([]byte)
if err != nil { return errs.Exit(err) }
for tag, ops := range spec.OperationsByTag() {
    // generate one client/file per API group
}
for _, name := range spec.SchemaNames() {
    schema := spec.Schemas()[name] // the codegen type universe
}

Configuration

None — it is a pure library. Consumers that load a spec from a configured location use shikumi-go for that config and pass the path to Load.

Release

Pull-model (Go modules): an annotated vX.Y.Z tag is the release; proxy.golang.org + pkg.go.dev index it. See the GSDS module delivery FSM.

Documentation

Overview

Package tundraopenapi is the keystone typed model of an OpenAPI 3.0 specification — the single parsed-spec view downstream pleme-io tools (SDK companions, client builders, IaC/Terraform generators, doc emitters) import instead of each re-parsing the spec.

It is a thin, stable, codegen-oriented facade over getkin/kin-openapi: it loads + validates a spec, indexes its operations, and exposes the component schema universe, while Spec.Raw gives advanced consumers the full kin-openapi document. The library is spec-agnostic — point it at any OpenAPI 3.0 document the downstream tooling feeds it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

type Operation struct {
	ID      string   // operationId
	Method  string   // GET / POST / PUT / DELETE / ...
	Path    string   // templated path, e.g. /v2/auth
	Tags    []string // OpenAPI tags
	Summary string
}

Operation is one API operation, flattened from a path item for codegen.

type Spec

type Spec struct {
	Title      string
	Version    string
	Operations []Operation // sorted by (path, method) for deterministic codegen
	// contains filtered or unexported fields
}

Spec is a parsed, validated, codegen-oriented view of an OpenAPI 3.0 document.

func Load

func Load(location string) (*Spec, error)

Load parses + validates an OpenAPI 3.0 spec from a file path or URL.

func LoadData

func LoadData(data []byte) (*Spec, error)

LoadData parses + validates an OpenAPI 3.0 spec from raw bytes (JSON or YAML).

func (*Spec) Operation

func (s *Spec) Operation(id string) (Operation, bool)

Operation looks up a single operation by its operationId.

func (*Spec) OperationsByTag

func (s *Spec) OperationsByTag() map[string][]Operation

OperationsByTag groups operations by their first tag ("" if untagged), the natural unit for generating one client/file per API group.

func (*Spec) Raw

func (s *Spec) Raw() *openapi3.T

Raw exposes the underlying kin-openapi document for advanced traversal (request/response bodies, security schemes, extensions, ...).

func (*Spec) SchemaNames

func (s *Spec) SchemaNames() []string

SchemaNames returns the component schema names, sorted, for deterministic codegen.

func (*Spec) Schemas

func (s *Spec) Schemas() openapi3.Schemas

Schemas returns the named component schemas — the codegen type universe.

Jump to

Keyboard shortcuts

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