openapi

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package openapi is a frontend that turns an OpenAPI 3 spec into Synth schemas, so you can generate valid request payloads for an endpoint without hand-writing a struct. It maps JSON Schema (type/format/enum/min/max) onto schema.Kind, then the normal engine produces records.

Scope: top-level object properties of a request body's application/json schema (including a local $ref into components/schemas). Nested objects and arrays are generated shallowly (as inferred scalars) in this version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PayloadJSON

func PayloadJSON(rec map[string]any) ([]byte, error)

PayloadJSON marshals a generated record map into indented JSON.

Types

type Spec

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

Spec is a parsed OpenAPI document.

func Load

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

Load parses an OpenAPI spec from a file (YAML or JSON).

func Parse

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

Parse parses an OpenAPI spec from bytes (YAML or JSON; YAML is a superset).

func (*Spec) Schema

func (s *Spec) Schema(method, path string) (*schema.Schema, error)

Schema builds a Synth schema for the request body of method+path.

Jump to

Keyboard shortcuts

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