Documentation
¶
Index ¶
Constants ¶
const ( ValueTypeObjectID = "objectID" ValueTypeArrayObject = "array[object]" ValueTypeArrayString = "array[string]" ValueTypeArrayNumber = "array[number]" ValueTypeArrayInt = "array[integer]" ValueTypeArrayBoolean = "array[boolean]" ValueTypeMapStringInt64 = "map[string]int64" ValueTypeMapStringInt32 = "map[string]int32" ValueTypeMapStringInt = "map[string]int" ValueTypeMapStringString = "map[string]string" )
Value types extend the OpenAPI specification to support more types.
const (
// JsonMediaType is support request body media type.
JsonMediaType = "application/json"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct {
Version string `json:"version"`
Short string `json:"short"`
Long string `json:"long,omitempty"`
Operations []Operation `json:"operations,omitempty"`
}
API represents an abstracted API description, include details used to build CLI commands.
func LoadOpenAPI ¶
LoadOpenAPI load OpenAPI schema from response body and generate API.
type ArrayObjectFlag ¶
type ArrayObjectFlag []any
ArrayObjectFlag creates a custom flag for []interface.
func (*ArrayObjectFlag) Set ¶
func (i *ArrayObjectFlag) Set(value string) error
Set a new value on the flag.
func (*ArrayObjectFlag) String ¶
func (i *ArrayObjectFlag) String() string
String returns a string represent of this flag.
func (*ArrayObjectFlag) Type ¶
func (i *ArrayObjectFlag) Type() string
Type returns the type of this custom flag, which will be displayed in `--help` output.
type BodyParam ¶
type BodyParam struct {
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Default any `json:"default,omitempty"`
}
BodyParam represents each field in body.
func (BodyParam) AddFlag ¶
AddFlag adds a new option flag to a command's flag set for this body param.
func (BodyParam) OptionName ¶
OptionName returns the commandline option name for this parameter.
type BodyParams ¶
type BodyParams struct {
Type string `json:"type,omitempty"`
Params []*BodyParam `json:"params,omitempty"`
}
BodyParams represent request body and params type.
type ObjectFlag ¶
ObjectFlag creates a custom flag for map[string]interface{}.
func (*ObjectFlag) String ¶
func (i *ObjectFlag) String() string
String returns a string represent of this flag.
func (*ObjectFlag) Type ¶
func (i *ObjectFlag) Type() string
Type returns the type of this custom flag, which will be displayed in `--help` output.
type ObjectIDFlag ¶
ObjectIDFlag creates a custom flag for map[string]string{"id": "xxx"}.
func (ObjectIDFlag) Set ¶
func (i ObjectIDFlag) Set(value string) error
Set a new value on the flag.
func (ObjectIDFlag) String ¶
func (i ObjectIDFlag) String() string
String returns a string represent of this flag.
func (ObjectIDFlag) Type ¶
func (i ObjectIDFlag) Type() string
Type returns the type of this custom flag, which will be displayed in `--help` output.
type Operation ¶
type Operation struct {
Name string `json:"name"`
Group string `json:"group,omitempty"`
Short string `json:"short,omitempty"`
Long string `json:"long,omitempty"`
Method string `json:"method,omitempty"`
URITemplate string `json:"uriTemplate"`
URIParams []string `json:"uriParams"`
PathParams []*Param `json:"pathParams,omitempty"`
QueryParams []*Param `json:"queryParams,omitempty"`
HeaderParams []*Param `json:"headerParams,omitempty"`
BodyParams *BodyParams `json:"bodyParams,omitempty"`
BodyMediaType string `json:"bodyMediaType,omitempty"`
Hidden bool `json:"hidden,omitempty"`
Deprecated string `json:"deprecated,omitempty"`
Formats []string `json:"formats,omitempty"`
}
Operation represents an API action, e.g. list-things or create-user.
type Param ¶
type Param struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Style string `json:"style,omitempty"`
Explode bool `json:"explode,omitempty"`
Default any `json:"default,omitempty"`
DataFrom DataFrom `json:"dataFrom,omitempty"`
}
Param represents an API operation input parameter.
func (Param) OptionName ¶
OptionName returns the formatted commandline option name for this parameter.