Documentation
¶
Overview ¶
Package openapi reads the OpenAPI document meshStack publishes, and picks the operations of a request path, a method and a version out of it. It does not know where the document comes from.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiVersion ¶
type ApiVersion struct {
// contains filtered or unexported fields
}
func MustParseApiVersion ¶
func MustParseApiVersion(s string) ApiVersion
func ParseApiVersion ¶
func ParseApiVersion(s string) (ApiVersion, error)
func (ApiVersion) Compare ¶
func (v ApiVersion) Compare(other ApiVersion) int
func (ApiVersion) IsZero ¶
func (v ApiVersion) IsZero() bool
func (ApiVersion) String ¶
func (v ApiVersion) String() string
String is empty for the zero version.
type ApiVersions ¶
type ApiVersions []ApiVersion
func (ApiVersions) SortedUnique ¶
func (vs ApiVersions) SortedUnique() ApiVersions
SortedUnique sorts in place, oldest first.
func (ApiVersions) String ¶
func (vs ApiVersions) String() string
type Field ¶
Field is a property anywhere in a body. Its Path joins the property names from the top with dots, and writes the items of an array as [], as in spec.parentBuildingBlockRefs[].uuid, and the values of a map as the name *, as the API docs do.
type MediaType ¶
type MediaType struct {
Name string
// Kind is empty for a type of no meshObject.
Kind string
// ApiVersion is zero for a type of no version, such as application/json.
ApiVersion ApiVersion
}
func ParseMediaType ¶
ParseMediaType reads a media type such as an Accept header carries. Its Kind is in lower case, as the media type writes it.
type Operation ¶
type Operation struct {
Method string
PathTemplate PathTemplate
// Kind is the meshObject kind below whose path the operation is, such as meshBuildingBlock, or
// empty outside the path of a kind.
Kind string
// Action names the operation within its kind, as a command of the CLI would: list, show,
// create, update, delete, or the path below the kind's object, such as trigger-run.
Action string
// MediaTypes are those of the request body and of every response, each once.
MediaTypes []MediaType
// contains filtered or unexported fields
}
func (Operation) ApiVersions ¶
func (o Operation) ApiVersions() ApiVersions
ApiVersions are oldest first.
func (Operation) LatestApiVersion ¶
func (o Operation) LatestApiVersion() ApiVersion
LatestApiVersion is zero for an operation of no version.
func (Operation) LatestMediaType ¶
LatestMediaType is the one of the latest version, or for an operation of no version the first, such as application/json. It is the one to accept, and to send a body in.
type OperationDoc ¶
type OperationDoc struct {
Summary string
Description string
Parameters []Parameter
RequestBodies []Body
Responses []Response
}
OperationDoc is what the API docs say about an operation, for a person to read.
type PathTemplate ¶
type PathTemplate string
type Selector ¶
type Selector struct {
// Kind and Action select by Operation.Kind and Operation.Action. Kind is matched in any case.
Kind string
Action string
// Method is empty for every method.
Method string
// Path is a request path such as /api/meshobjects/meshtenants/<uuid>, or empty for every path.
Path string
// ApiVersion is zero for the latest version each operation offers.
ApiVersion ApiVersion
}
type Spec ¶
type Spec struct {
Operations []Operation
// contains filtered or unexported fields
}
Spec is an OpenAPI document. After Select, it marshals to the selected operations and the components they reference.
func Parse ¶
Parse leaves out what the document says about authentication, see withoutAuthentication.
func (Spec) Actions ¶
Actions are those of the operations of one kind, in the order of the document.
func (Spec) Doc ¶
func (s Spec) Doc(operation Operation) (OperationDoc, error)
Doc reads the operation of a Spec, or of a selection of it, which keeps every component.