Help us shape the future of Go! Take the 2026 Go Developer Survey

openapi

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package openapi turns an OpenAPI 3.0/3.1 document into Flow-I requests: one request per operation (path versions /v1/, /v2/ grouped as request versions), bodies generated from schemas, response schemas kept as the request's contract, and flows suggested from links. It is a pure transform: it returns model values and writes nothing.

libopenapi checks that the input is an OpenAPI 3 document; the mapping works on the decoded document with local $ref resolution (external references are reported, not followed).

Index

Constants

This section is empty.

Variables

View Source
var ErrSwagger2 = errors.New("a Swagger 2.0 document cannot take overlays from Flow-I; convert it to OpenAPI 3 first")

ErrSwagger2 is returned by OperationsOf for a Swagger 2.0 document: Import converts it first, so an overlay could not point into it.

Functions

func ParamKey

func ParamKey(name string) string

ParamKey is the template name a parameter is filled through ({{X_Trace}} for header X-Trace): request nodes pass it in with. Arazzo import and export use the same rule.

Types

type OperationRef

type OperationRef struct {
	RequestPath string // the request Import makes of it
	Label       string // the version label
	Method      string // lower case, as in the document
	Path        string // the path template, as in the document
	OperationID string
	Op          map[string]any // the operation object, references not followed
	PathParams  []any          // the path item's parameters, shared by its operations
}

OperationRef is the operation an imported request version came from, as the document writes it: what a spec overlay needs to point at it.

func OperationsOf

func OperationsOf(data []byte) ([]OperationRef, error)

OperationsOf lists the operations of an OpenAPI 3 document with the request path and version label Import gives each.

type Options

type Options struct {
	NewID func() model.ID // ids for new requests and flows
}

Options configure Import.

type Result

type Result struct {
	Requests []model.Request // Path is set (relative to requests/); File is not
	// Schemas holds response schemas: request path → version label →
	// status code → JSON schema with references inlined.
	Schemas map[string]map[string]map[string]any
	Flows   []model.Flow // suggested from links; Path is relative to flows/
}

Result is what an OpenAPI document becomes.

func Import

func Import(data []byte, o Options) (Result, diag.List)

Import maps an OpenAPI 3.0/3.1 or Swagger 2.0 document (YAML or JSON; Swagger is converted to 3.0 first) to requests, response schemas and suggested flows.

Jump to

Keyboard shortcuts

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