Documentation
¶
Overview ¶
Package openapi turns an OpenAPI 3.0/3.1 document into Flowi 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 ¶
var ErrSwagger2 = errors.New("a Swagger 2.0 document cannot take overlays from Flowi; 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 ¶
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
// Files is where references to other files ("$ref: ./schemas/pet.yaml")
// are read from, rooted at the folder of the document. Nil: they are
// reported and left out.
Files fs.FS
}
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/
// Files are the files the document's references were followed into: path
// (relative to the folder of the document, slash-separated) → content. They
// are what a later import of a kept copy needs beside it.
Files map[string][]byte
}
Result is what an OpenAPI document becomes.