openapi

package
v0.0.0-...-a9eb721 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package openapi GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectContext

func InjectContext(ctx context.Context, o *OpenAPI) context.Context

Types

type CallbacksObject

type CallbacksObject struct {
	Callbacks map[string]*PathItemObject `json:"callbacks,omitempty"`
}

func (*CallbacksObject) AddCallback

func (o *CallbacksObject) AddCallback(name string, c *PathItemObject)

func (CallbacksObject) RuntimeDoc

func (v CallbacksObject) RuntimeDoc(names ...string) ([]string, bool)

type ComponentsObject

type ComponentsObject struct {
	Schemas map[string]jsonschema.Schema `json:"schemas,omitempty"`
}

https://spec.openapis.org/oas/latest.html#components-object FIXME now only support schemas

func (*ComponentsObject) AddSchema

func (o *ComponentsObject) AddSchema(id string, s jsonschema.Schema)

func (*ComponentsObject) RefSchema

func (o *ComponentsObject) RefSchema(id string) jsonschema.Schema

func (ComponentsObject) RuntimeDoc

func (v ComponentsObject) RuntimeDoc(names ...string) ([]string, bool)

type Contact

type Contact struct {
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`
	Email string `json:"email,omitempty"`
}

func (Contact) RuntimeDoc

func (v Contact) RuntimeDoc(names ...string) ([]string, bool)

type ContentObject

type ContentObject struct {
	Content map[string]*MediaTypeObject `json:"content,omitempty"`
}

func (*ContentObject) AddContent

func (o *ContentObject) AddContent(contentType string, mt *MediaTypeObject)

func (ContentObject) RuntimeDoc

func (v ContentObject) RuntimeDoc(names ...string) ([]string, bool)

type EncodingObject

type EncodingObject struct {
	ContentType string `json:"contentType"`

	HeadersObject

	Style         ParameterStyle `json:"style,omitempty"`
	Explode       bool           `json:"explode,omitempty"`
	AllowReserved bool           `json:"allowReserved,omitempty"`

	jsonschema.Ext
}

func (EncodingObject) RuntimeDoc

func (v EncodingObject) RuntimeDoc(names ...string) ([]string, bool)

type HeaderObject

type HeaderObject = Parameter

type HeadersObject

type HeadersObject struct {
	Headers map[string]*HeaderObject `json:"headers,omitempty"`
}

func (*HeadersObject) AddHeader

func (object *HeadersObject) AddHeader(name string, h *Parameter)

func (HeadersObject) RuntimeDoc

func (v HeadersObject) RuntimeDoc(names ...string) ([]string, bool)

type InfoObject

type InfoObject struct {
	Title          string   `json:"title"`
	Description    string   `json:"description,omitempty"`
	TermsOfService string   `json:"termsOfService,omitempty"`
	Contact        *Contact `json:"contact,omitempty"`
	License        *License `json:"license,omitempty"`
	Version        string   `json:"version"`
}

https://spec.openapis.org/oas/latest.html#infoObject

func (InfoObject) RuntimeDoc

func (v InfoObject) RuntimeDoc(names ...string) ([]string, bool)

type License

type License struct {
	Name string `json:"name"`
	URL  string `json:"url,omitempty"`
}

func (License) RuntimeDoc

func (v License) RuntimeDoc(names ...string) ([]string, bool)

type MediaTypeObject

type MediaTypeObject struct {
	Schema   jsonschema.Schema          `json:"schema,omitempty"`
	Encoding map[string]*EncodingObject `json:"encoding,omitempty"`

	jsonschema.Ext
}

func (*MediaTypeObject) AddEncoding

func (o *MediaTypeObject) AddEncoding(name string, e *EncodingObject)

func (MediaTypeObject) RuntimeDoc

func (v MediaTypeObject) RuntimeDoc(names ...string) ([]string, bool)

type OpenAPI

type OpenAPI struct {
	OpenAPI string `json:"openapi"`

	InfoObject       `json:"info"`
	ComponentsObject `json:"components"`

	Paths map[string]*PathItemObject `json:"paths"`

	jsonschema.Ext
}

func FromContext

func FromContext(ctx context.Context) *OpenAPI

func NewOpenAPI

func NewOpenAPI() *OpenAPI

func (*OpenAPI) AddOperation

func (p *OpenAPI) AddOperation(method string, path string, op *OperationObject)

func (OpenAPI) RuntimeDoc

func (v OpenAPI) RuntimeDoc(names ...string) ([]string, bool)

type OperationObject

type OperationObject struct {
	Tags []string `json:"tags,omitempty"`

	Summary     string `json:"summary,omitempty"`
	Description string `json:"description,omitempty"`

	OperationId string `json:"operationId"`

	Parameters  []*ParameterObject `json:"parameters,omitempty"`
	RequestBody *RequestBodyObject `json:"requestBody,omitempty"`

	ResponsesObject

	CallbacksObject

	Deprecated *bool `json:"deprecated,omitempty"`

	jsonschema.Ext
}

func NewOperation

func NewOperation(operationId string) *OperationObject

func (*OperationObject) AddParameter

func (o *OperationObject) AddParameter(name string, in ParameterIn, p *Parameter)

func (OperationObject) RuntimeDoc

func (v OperationObject) RuntimeDoc(names ...string) ([]string, bool)

func (*OperationObject) SetRequestBody

func (o *OperationObject) SetRequestBody(rb *RequestBodyObject)

func (OperationObject) WithDesc

func (o OperationObject) WithDesc(desc string) *OperationObject

func (OperationObject) WithSummary

func (o OperationObject) WithSummary(summary string) *OperationObject

func (OperationObject) WithTags

func (o OperationObject) WithTags(tags ...string) *OperationObject

type Parameter

type Parameter struct {
	Schema      jsonschema.Schema `json:"schema"`
	Description string            `json:"description,omitempty"`
	Required    *bool             `json:"required,omitempty"`
	Deprecated  *bool             `json:"deprecated,omitempty"`

	// https://spec.openapis.org/oas/latest.html#parameter-object
	Style   ParameterStyle `json:"style,omitempty"`
	Explode *bool          `json:"explode,omitempty"`

	jsonschema.Ext
}

func (Parameter) RuntimeDoc

func (v Parameter) RuntimeDoc(names ...string) ([]string, bool)

type ParameterIn

type ParameterIn string
const (
	InQuery  ParameterIn = "query"
	InPath   ParameterIn = "path"
	InHeader ParameterIn = "header"
	InCookie ParameterIn = "cookie"
)

func (ParameterIn) RuntimeDoc

func (ParameterIn) RuntimeDoc(names ...string) ([]string, bool)

type ParameterObject

type ParameterObject struct {
	Name string      `json:"name"`
	In   ParameterIn `json:"in"`

	Parameter
}

https://spec.openapis.org/oas/latest.html#parameter-object

func NewParameter

func NewParameter(name string, in ParameterIn) *ParameterObject

func (ParameterObject) RuntimeDoc

func (v ParameterObject) RuntimeDoc(names ...string) ([]string, bool)

func (*ParameterObject) SetDefaultStyle

func (o *ParameterObject) SetDefaultStyle()

type ParameterStyle

type ParameterStyle string
const (
	// https://tools.ietf.org/html/rfc6570#section-3.2.7
	ParameterStyleMatrix ParameterStyle = "matrix"
	// https://tools.ietf.org/html/rfc6570#section-3.2.5
	ParameterStyleLabel ParameterStyle = "label"
	// https://tools.ietf.org/html/rfc6570#section-3.2.8
	ParameterStyleForm ParameterStyle = "form"
	// for array, csv https://tools.ietf.org/html/rfc6570#section-3.2.2
	ParameterStyleSimple ParameterStyle = "simple"
	// for array, ssv
	ParameterStyleSpaceDelimited ParameterStyle = "spaceDelimited"
	// for array, pipes
	ParameterStylePipeDelimited ParameterStyle = "pipeDelimited"
	// for object
	ParameterStyleDeepObject ParameterStyle = "deepObject"
)

func (ParameterStyle) RuntimeDoc

func (ParameterStyle) RuntimeDoc(names ...string) ([]string, bool)

type PathItemObject

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

	Operations map[string]*OperationObject `json:",inline"`
}

https://spec.openapis.org/oas/latest.html#pathItemObject no need $ref, server, parameters

func (PathItemObject) RuntimeDoc

func (v PathItemObject) RuntimeDoc(names ...string) ([]string, bool)

type Payload

type Payload struct {
	OpenAPI
}

func (Payload) MarshalJSON

func (p Payload) MarshalJSON() ([]byte, error)

func (Payload) RuntimeDoc

func (v Payload) RuntimeDoc(names ...string) ([]string, bool)

func (*Payload) UnmarshalJSON

func (p *Payload) UnmarshalJSON(data []byte) (err error)

type RequestBodyObject

type RequestBodyObject struct {
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`

	ContentObject

	jsonschema.Ext
}

func (RequestBodyObject) RuntimeDoc

func (v RequestBodyObject) RuntimeDoc(names ...string) ([]string, bool)

type ResponseObject

type ResponseObject struct {
	Description string `json:"description"`

	HeadersObject
	ContentObject

	jsonschema.Ext
}

func (ResponseObject) RuntimeDoc

func (v ResponseObject) RuntimeDoc(names ...string) ([]string, bool)

type ResponsesObject

type ResponsesObject struct {
	Responses map[string]*ResponseObject `json:"responses"`
}

func (*ResponsesObject) AddResponse

func (o *ResponsesObject) AddResponse(statusCode int, r *ResponseObject)

func (ResponsesObject) RuntimeDoc

func (v ResponsesObject) RuntimeDoc(names ...string) ([]string, bool)

func (*ResponsesObject) SetDefaultResponse

func (o *ResponsesObject) SetDefaultResponse(r *ResponseObject)

Directories

Path Synopsis
Package jsonschema GENERATED BY gengo:deepcopy DON'T EDIT THIS FILE
Package jsonschema GENERATED BY gengo:deepcopy DON'T EDIT THIS FILE
extractors
Package extractors GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package extractors GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Jump to

Keyboard shortcuts

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