spec

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	Arg    *ifacetool.Param // The method argument.
	Params []*Parameter     // The corresponding request parameters
}

Binding represents a binding from a method argument to one or more request parameters.

func (*Binding) Description

func (b *Binding) Description() string

func (*Binding) In

func (b *Binding) In() Location

func (*Binding) IsAggregate

func (b *Binding) IsAggregate() bool

IsAggregate determines whether this binding is aggregate.

func (*Binding) IsBlank

func (b *Binding) IsBlank() bool

IsBlank determines whether this binding is a blank identifier.

func (*Binding) IsManual

func (b *Binding) IsManual() bool

IsManual determines whether this binding is specified manually (i.e. by handwritten annotations).

func (*Binding) Name

func (b *Binding) Name() string

func (*Binding) Required

func (b *Binding) Required() bool

func (*Binding) SetDescription

func (b *Binding) SetDescription(description string)

func (*Binding) SetIn

func (b *Binding) SetIn(in Location)

func (*Binding) SetName

func (b *Binding) SetName(name string)

func (*Binding) SetType

func (b *Binding) SetType(typ string)

func (*Binding) Type

func (b *Binding) Type() string

type Location

type Location string
const (
	InPath   Location = "path"
	InQuery  Location = "query"
	InHeader Location = "header"
	InCookie Location = "cookie"
	InBody   Location = "body"

	// InRequest indicates that the parameter is located in *http.Request.
	InRequest Location = "request"

	MediaTypeJSON = "application/json; charset=utf-8"
)

type Metadata

type Metadata struct {
	// Relative path to the OAS documentation.
	DocsPath string

	Title       string
	Version     string
	Description string
	BasePath    string

	// Default tags for operations those have no tags.
	DefaultTags []string
}

type Operation

type Operation struct {
	// In cases where multiple `//kun:op` are specified for one Go method,
	// Name and GoMethodName will be different.
	Name         string
	GoMethodName string

	Method           string
	Pattern          string
	Request          *Request
	SuccessResponse  *Response
	FailureResponses []*Response
	Description      string
	Tags             []string
}

func NewOperation

func NewOperation(name, goMethodName, description string) *Operation

func (*Operation) Resp

func (o *Operation) Resp(statusCode int, mediaType string, schema interface{}) *Operation

type Parameter

type Parameter struct {
	In          Location // The location of the parameter.
	Name        string   // The name of the parameter.
	Required    bool     // Whether this parameter is mandatory.
	Type        string   // The type of the parameter.
	Description string   // A brief description of the parameter.
}

Parameter represents a request parameter. See https://spec.openapis.org/oas/v3.1.0#parameter-object.

func (*Parameter) UniqueKey

func (p *Parameter) UniqueKey() string

type Request

type Request struct {
	MediaType string

	// The name of the request field whose value is mapped to the HTTP request body.
	// Otherwise, all fields not located in path/query/header will be mapped to the HTTP body
	BodyField string

	Bindings []*Binding
}

func (*Request) Bind

func (r *Request) Bind(arg *ifacetool.Param, params []*Parameter)

func (*Request) GetBinding

func (r *Request) GetBinding(argName string) *Binding

type Response

type Response struct {
	StatusCode int
	MediaType  string
	Schema     interface{}

	// The name of the response field whose value is mapped to the HTTP response body.
	// When omitted, the entire response struct will be used as the HTTP response body.
	BodyField string
}

type Specification

type Specification struct {
	Metadata   *Metadata
	Operations []*Operation
}

func (*Specification) OldSpec

func (s *Specification) OldSpec() *openapi.Specification

Jump to

Keyboard shortcuts

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