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

openapi

package
v0.9.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ListTool = "list"
	NoFilter = "<none>"
)
View Source
const GetSchemaTool = "get-schema"
View Source
const RunTool = "run"

Variables

This section is empty.

Functions

func GetSupportedMIMETypes

func GetSupportedMIMETypes() []string

func GetSupportedSecurityTypes

func GetSupportedSecurityTypes() []string

func HandleAuths

func HandleAuths(req *http.Request, envMap map[string]string, infoSets [][]SecurityInfo) error

HandleAuths will set up the request with the necessary authentication information. A set of sets of SecurityInfo is passed in, where each represents a possible set of security options.

func HandleCookieParameters

func HandleCookieParameters(req *http.Request, params []Parameter, input string)

HandleCookieParameters extracts each cookie parameter from the input JSON and adds it to the request cookies.

func HandleHeaderParameters

func HandleHeaderParameters(req *http.Request, params []Parameter, input string)

HandleHeaderParameters extracts each header parameter from the input JSON and adds it to the request headers.

func HandlePathParameters

func HandlePathParameters(path string, params []Parameter, input string) string

HandlePathParameters extracts each path parameter from the input JSON and replaces its placeholder in the URL path.

func HandleQueryParameters

func HandleQueryParameters(q url.Values, params []Parameter, input string) url.Values

HandleQueryParameters extracts each query parameter from the input JSON and adds it to the URL query.

func IsOpenAPI

func IsOpenAPI(data []byte) int

IsOpenAPI checks if the data is an OpenAPI definition and returns the version if it is.

func Load

func Load(source string) (*openapi3.T, error)

func LoadFromBytes

func LoadFromBytes(content []byte) (*openapi3.T, error)

func MatchFilters

func MatchFilters(filters []string, operationID string) (bool, error)

func Run

func Run(operationID, defaultHost, args string, t *openapi3.T, envs []string) (string, bool, error)

Types

type Operation

type Operation struct {
	Description string `json:"description,omitempty"`
	Summary     string `json:"summary,omitempty"`
}

type OperationInfo

type OperationInfo struct {
	Server          string           `json:"server"`
	Path            string           `json:"path"`
	Method          string           `json:"method"`
	BodyContentMIME string           `json:"bodyContentMIME"`
	SecurityInfos   [][]SecurityInfo `json:"securityInfos"`
	QueryParams     []Parameter      `json:"queryParameters"`
	PathParams      []Parameter      `json:"pathParameters"`
	HeaderParams    []Parameter      `json:"headerParameters"`
	CookieParams    []Parameter      `json:"cookieParameters"`
}

func GetSchema

func GetSchema(operationID, defaultHost string, t *openapi3.T) (string, OperationInfo, bool, error)

GetSchema returns the JSONSchema and OperationInfo for a particular OpenAPI operation. Return values in order: JSONSchema (string), OperationInfo, found (bool), error.

type OperationList

type OperationList struct {
	Operations map[string]Operation `json:"operations"`
}

func List

func List(t *openapi3.T, filter string) (OperationList, error)

type Parameter

type Parameter struct {
	Name    string `json:"name"`
	Style   string `json:"style"`
	Explode *bool  `json:"explode"`
}

type SecurityInfo

type SecurityInfo struct {
	Name       string `json:"name"`       // name as defined in the security schemes
	Type       string `json:"type"`       // http or apiKey
	Scheme     string `json:"scheme"`     // bearer or basic, for type==http
	APIKeyName string `json:"apiKeyName"` // name of the API key, for type==apiKey
	In         string `json:"in"`         // header, query, or cookie, for type==apiKey
}

A SecurityInfo represents a security scheme in OpenAPI.

func (SecurityInfo) GetCredentialToolStrings

func (i SecurityInfo) GetCredentialToolStrings(hostname string) []string

Jump to

Keyboard shortcuts

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