openapi

package
v0.0.0-...-7f2e576 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package openapi lowers OpenAPI 3.0/3.1/3.2 documents into the Morphic IR. It implements compilers.Compiler. Parsing is delegated to github.com/speakeasy-api/openapi; this package owns identity (pointer-derived IDs), hoisting, normalization (nullable spellings, allOf classification), and lossless preservation of constructs the IR does not model structurally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct{}

Compiler lowers OpenAPI 3.x documents into the IR.

func New

func New() *Compiler

New returns the OpenAPI compiler.

func (*Compiler) Compile

func (c *Compiler) Compile(ctx context.Context, sources []compilers.Source, opts compilers.Options) (*ir.Document, []ir.Diagnostic, error)

Compile implements compilers.Compiler. Milestone 1 accepts exactly one root source; multi-document stitching belongs to the link pass.

func (*Compiler) Formats

func (*Compiler) Formats() []compilers.SourceFormat

Formats reports the OpenAPI dialects this compiler accepts.

type GroupingStrategy

type GroupingStrategy string

GroupingStrategy selects how operations are grouped into OperationGroups. It is the injectable-policy seam (architecture principle 6): grouping is inferred policy, not source semantics, and can be switched or disabled.

const (
	// GroupByTags groups operations by their first OpenAPI tag (default).
	GroupByTags GroupingStrategy = "tags"
	// GroupByPathPrefix groups operations by the first path segment.
	GroupByPathPrefix GroupingStrategy = "path-prefix"
)

Grouping strategies.

type Options

type Options struct {
	// Grouping selects the operation-grouping strategy.
	Grouping GroupingStrategy `json:"grouping,omitempty"`
	// DisableExternalRefs prevents resolution of $refs into other documents.
	DisableExternalRefs bool `json:"disableExternalRefs"`
}

Options configures the OpenAPI compiler. It is the concrete type this compiler expects in compilers.Options.FormatOptions; the zero value is valid and normalized by withDefaults.

Jump to

Keyboard shortcuts

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