Documentation
¶
Index ¶
- func InjectContext(ctx context.Context, o *OpenAPI) context.Context
- type CallbacksObject
- type ComponentsObject
- type Contact
- type ContentObject
- type EncodingObject
- type HeaderObject
- type HeadersObject
- type InfoObject
- type License
- type MediaTypeObject
- type OpenAPI
- type OperationObject
- func (o *OperationObject) AddParameter(name string, in ParameterIn, p *Parameter)
- func (o *OperationObject) SetRequestBody(rb *RequestBodyObject)
- func (o OperationObject) WithDesc(desc string) *OperationObject
- func (o OperationObject) WithSummary(summary string) *OperationObject
- func (o OperationObject) WithTags(tags ...string) *OperationObject
- type Parameter
- type ParameterIn
- type ParameterObject
- type ParameterStyle
- type PathItemObject
- type Payload
- type RequestBodyObject
- type ResponseObject
- type ResponsesObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallbacksObject ¶
type CallbacksObject struct {
Callbacks internal.Record[string, *PathItemObject] `json:"callbacks,omitzero"`
}
func (*CallbacksObject) AddCallback ¶
func (o *CallbacksObject) AddCallback(name string, c *PathItemObject)
type ComponentsObject ¶
type ComponentsObject struct {
Schemas map[string]jsonschema.Schema `json:"schemas,omitzero"`
}
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
type ContentObject ¶
type ContentObject struct {
Content map[string]*MediaTypeObject `json:"content,omitzero"`
}
func (*ContentObject) AddContent ¶
func (o *ContentObject) AddContent(contentType string, mt *MediaTypeObject)
type EncodingObject ¶
type EncodingObject struct {
ContentType string `json:"contentType"`
HeadersObject
Style ParameterStyle `json:"style,omitzero"`
Explode bool `json:"explode,omitzero"`
AllowReserved bool `json:"allowReserved,omitzero"`
jsonschema.Ext
}
type HeaderObject ¶
type HeaderObject = Parameter
type HeadersObject ¶
type HeadersObject struct {
Headers map[string]*HeaderObject `json:"headers,omitzero"`
}
func (*HeadersObject) AddHeader ¶
func (object *HeadersObject) AddHeader(name string, h *Parameter)
type InfoObject ¶
type MediaTypeObject ¶
type MediaTypeObject struct {
Schema jsonschema.Schema `json:"schema,omitzero"`
Encoding map[string]*EncodingObject `json:"encoding,omitzero"`
jsonschema.Ext
}
func (*MediaTypeObject) AddEncoding ¶
func (o *MediaTypeObject) AddEncoding(name string, e *EncodingObject)
type OpenAPI ¶
type OpenAPI struct {
OpenAPI string `json:"openapi"`
InfoObject `json:"info"`
ComponentsObject `json:"components"`
Paths internal.Record[string, *PathItemObject] `json:"paths"`
jsonschema.Ext
}
func FromContext ¶
func NewOpenAPI ¶
func NewOpenAPI() *OpenAPI
func (*OpenAPI) AddOperation ¶
func (p *OpenAPI) AddOperation(method string, path string, op *OperationObject)
type OperationObject ¶
type OperationObject struct {
Tags []string `json:"tags,omitzero"`
Summary string `json:"summary,omitzero"`
Description string `json:"description,omitzero"`
OperationId string `json:"operationId"`
Parameters []*ParameterObject `json:"parameters,omitzero"`
RequestBody *RequestBodyObject `json:"requestBody,omitzero"`
ResponsesObject
CallbacksObject
Deprecated *bool `json:"deprecated,omitzero"`
jsonschema.Ext
}
func NewOperation ¶
func NewOperation(operationId string) *OperationObject
func (*OperationObject) AddParameter ¶
func (o *OperationObject) AddParameter(name string, in ParameterIn, p *Parameter)
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,omitzero"`
Required *bool `json:"required,omitzero"`
Deprecated *bool `json:"deprecated,omitzero"`
// https://spec.openapis.org/oas/latest.html#parameter-object
Style ParameterStyle `json:"style,omitzero"`
Explode *bool `json:"explode,omitzero"`
jsonschema.Ext
}
type ParameterIn ¶
type ParameterIn string
const ( InQuery ParameterIn = "query" InPath ParameterIn = "path" InHeader ParameterIn = "header" InCookie ParameterIn = "cookie" )
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) 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" )
type PathItemObject ¶
type PathItemObject = internal.Record[string, *OperationObject]
PathItemObject https://spec.openapis.org/oas/latest.html#pathItemObject no need $ref, server, parameters
type Payload ¶
type Payload struct {
OpenAPI
}
func (Payload) MarshalJSON ¶
func (*Payload) UnmarshalJSON ¶
type RequestBodyObject ¶
type RequestBodyObject struct {
Description string `json:"description,omitzero"`
Required bool `json:"required,omitzero"`
ContentObject
jsonschema.Ext
}
type ResponseObject ¶
type ResponseObject struct {
Description string `json:"description"`
HeadersObject
ContentObject
jsonschema.Ext
}
type ResponsesObject ¶
type ResponsesObject struct {
Responses map[string]*ResponseObject `json:"responses"`
}
func (*ResponsesObject) AddResponse ¶
func (o *ResponsesObject) AddResponse(statusCode int, r *ResponseObject)
func (*ResponsesObject) SetDefaultResponse ¶
func (o *ResponsesObject) SetDefaultResponse(r *ResponseObject)
Source Files
¶
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 |
Click to show internal directories.
Click to hide internal directories.