Documentation
¶
Index ¶
- type Callback
- type CallbackObject
- type ComponentRefer
- type Components
- type ComponentsObject
- func (object *ComponentsObject) AddParameter(id string, p *Parameter)
- func (object *ComponentsObject) AddRequestBody(id string, e *RequestBody)
- func (object *ComponentsObject) AddResponse(id string, r *Response)
- func (object *ComponentsObject) AddSchema(id string, s *Schema)
- func (object *ComponentsObject) RefCallback(id string) *Callback
- func (object *ComponentsObject) RefExample(id string) *Example
- func (object *ComponentsObject) RefHeader(id string) *Header
- func (object *ComponentsObject) RefLink(id string) *Link
- func (object *ComponentsObject) RefParameter(id string) *Parameter
- func (object *ComponentsObject) RefRequestBody(id string) *RequestBody
- func (object *ComponentsObject) RefResponse(id string) *Response
- func (object *ComponentsObject) RefSchema(id string) *Schema
- func (object *ComponentsObject) RequireSecurity(id string, scopes ...string) SecurityRequirement
- type Contact
- type ContactObject
- type Discriminator
- type Encoding
- type EncodingObject
- type Example
- type ExampleObject
- type ExternalDoc
- type Header
- type HttpMethod
- type Info
- type InfoObject
- type License
- type LicenseObject
- type Link
- type LinkObject
- type MediaType
- type MediaTypeObject
- type OAuthFlow
- type OAuthFlowObject
- type OAuthFlows
- type OAuthFlowsObject
- type OpenAPI
- type OpenAPIObject
- type Operation
- type OperationObject
- type Operations
- type Parameter
- type ParameterCommonObject
- type ParameterObject
- type ParameterStyle
- type PathItem
- type PathItemObject
- type Paths
- type Position
- type Props
- type Refer
- type Reference
- type RequestBody
- type RequestBodyObject
- type Response
- type ResponseObject
- type Responses
- type ResponsesObject
- type RuntimeExpression
- type Schema
- func AllOf(schemas ...*Schema) *Schema
- func AnyOf(schemas ...*Schema) *Schema
- func Binary() *Schema
- func Boolean() *Schema
- func Byte() *Schema
- func Date() *Schema
- func DateTime() *Schema
- func Double() *Schema
- func Float() *Schema
- func Integer() *Schema
- func ItemsOf(items *Schema) *Schema
- func KeyValueOf(k *Schema, s *Schema) *Schema
- func Long() *Schema
- func MapOf(s *Schema) *Schema
- func NewSchema(tpe Type, fmt string) *Schema
- func Not(schema *Schema) *Schema
- func ObjectOf(props Props, required ...string) *Schema
- func OneOf(schemas ...*Schema) *Schema
- func Password() *Schema
- func RefSchema(ref string) *Schema
- func RefSchemaByRefer(refer Refer) *Schema
- func String() *Schema
- func (s Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) SetProperty(name string, propSchema *Schema, required bool)
- func (s *Schema) UnmarshalJSON(data []byte) error
- func (s Schema) WithDesc(desc string) *Schema
- func (s Schema) WithDiscriminator(discriminator *Discriminator) *Schema
- func (s Schema) WithTitle(title string) *Schema
- func (s Schema) WithValidation(validation *SchemaValidation) *Schema
- type SchemaObject
- type SchemaOrBool
- type SchemaValidation
- type SecurityRequirement
- type SecurityScheme
- func NewAPIKeySecurityScheme(name string, in Position) *SecurityScheme
- func NewHTTPSecurityScheme(scheme string, bearerFormat string) *SecurityScheme
- func NewOAuth2SecurityScheme(oauthFlowsObject OAuthFlowsObject) *SecurityScheme
- func NewOpenIdConnectSecurityScheme(openIdConnectUrl string) *SecurityScheme
- type SecuritySchemeObject
- type SecurityType
- type Server
- type ServerObject
- type ServerVariable
- type ServerVariableObject
- type SpecExtensions
- type StringRefer
- type Tag
- type TagObject
- type Type
- type WithCallbacks
- type WithContent
- type WithContentOrSchema
- type WithEncoding
- type WithExamples
- type WithHeaders
- type WithLinks
- type WithParameters
- type WithSecurityRequirement
- type WithSecuritySchemes
- type WithServers
- type WithTags
- type XML
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { Reference CallbackObject SpecExtensions }
func NewCallback ¶
func NewCallback(method HttpMethod, rule RuntimeExpression, op *Operation) *Callback
func (Callback) MarshalJSON ¶
func (*Callback) UnmarshalJSON ¶
type CallbackObject ¶
type CallbackObject map[RuntimeExpression]*PathItem
type ComponentRefer ¶
func NewComponentRefer ¶
func NewComponentRefer(group string, id string) *ComponentRefer
func ParseComponentRefer ¶
func ParseComponentRefer(ref string) *ComponentRefer
func (ComponentRefer) RefString ¶
func (ref ComponentRefer) RefString() string
type Components ¶
type Components struct { ComponentsObject SpecExtensions }
func (Components) MarshalJSON ¶
func (i Components) MarshalJSON() ([]byte, error)
func (*Components) UnmarshalJSON ¶
func (i *Components) UnmarshalJSON(data []byte) error
type ComponentsObject ¶
type ComponentsObject struct { Schemas map[string]*Schema `json:"schemas,omitempty"` Responses map[string]*Response `json:"responses,omitempty"` Parameters map[string]*Parameter `json:"parameters,omitempty"` WithExamples RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty"` WithHeaders WithSecuritySchemes WithLinks WithCallbacks }
func (*ComponentsObject) AddParameter ¶
func (object *ComponentsObject) AddParameter(id string, p *Parameter)
func (*ComponentsObject) AddRequestBody ¶
func (object *ComponentsObject) AddRequestBody(id string, e *RequestBody)
func (*ComponentsObject) AddResponse ¶
func (object *ComponentsObject) AddResponse(id string, r *Response)
func (*ComponentsObject) AddSchema ¶
func (object *ComponentsObject) AddSchema(id string, s *Schema)
func (*ComponentsObject) RefCallback ¶
func (object *ComponentsObject) RefCallback(id string) *Callback
func (*ComponentsObject) RefExample ¶
func (object *ComponentsObject) RefExample(id string) *Example
func (*ComponentsObject) RefHeader ¶
func (object *ComponentsObject) RefHeader(id string) *Header
func (*ComponentsObject) RefLink ¶
func (object *ComponentsObject) RefLink(id string) *Link
func (*ComponentsObject) RefParameter ¶
func (object *ComponentsObject) RefParameter(id string) *Parameter
func (*ComponentsObject) RefRequestBody ¶
func (object *ComponentsObject) RefRequestBody(id string) *RequestBody
func (*ComponentsObject) RefResponse ¶
func (object *ComponentsObject) RefResponse(id string) *Response
func (*ComponentsObject) RefSchema ¶
func (object *ComponentsObject) RefSchema(id string) *Schema
func (*ComponentsObject) RequireSecurity ¶
func (object *ComponentsObject) RequireSecurity(id string, scopes ...string) SecurityRequirement
type Contact ¶
type Contact struct { ContactObject SpecExtensions }
func (Contact) MarshalJSON ¶
func (*Contact) UnmarshalJSON ¶
type ContactObject ¶
type Discriminator ¶
type Encoding ¶
type Encoding struct { EncodingObject SpecExtensions }
func NewEncoding ¶
func NewEncoding() *Encoding
func (Encoding) MarshalJSON ¶
func (*Encoding) UnmarshalJSON ¶
type EncodingObject ¶
type EncodingObject struct { ContentType string `json:"contentType,omitempty"` WithHeaders Style ParameterStyle `json:"style,omitempty"` Explode bool `json:"explode,omitempty"` AllowReserved bool `json:"allowReserved,omitempty"` }
type Example ¶
type Example struct { Reference ExampleObject SpecExtensions }
func NewExample ¶
func NewExample() *Example
func (Example) MarshalJSON ¶
func (*Example) UnmarshalJSON ¶
type ExampleObject ¶
type ExternalDoc ¶
type ExternalDoc struct { Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` }
func NewExternalDoc ¶
func NewExternalDoc(url string, desc string) *ExternalDoc
type Header ¶
type Header struct { Reference ParameterCommonObject SpecExtensions }
func NewHeaderWithSchema ¶
func (Header) MarshalJSON ¶
func (*Header) UnmarshalJSON ¶
type HttpMethod ¶
type HttpMethod string
const ( GET HttpMethod = "get" PUT HttpMethod = "put" POST HttpMethod = "post" DELETE HttpMethod = "delete" OPTIONS HttpMethod = "options" HEAD HttpMethod = "head" PATCH HttpMethod = "patch" TRACE HttpMethod = "trace" )
type Info ¶
type Info struct { InfoObject SpecExtensions }
func (Info) MarshalJSON ¶
func (*Info) UnmarshalJSON ¶
type InfoObject ¶
type License ¶
type License struct { LicenseObject SpecExtensions }
func (License) MarshalJSON ¶
func (*License) UnmarshalJSON ¶
type LicenseObject ¶
type Link ¶
type Link struct { Reference LinkObject SpecExtensions }
func (Link) MarshalJSON ¶
func (*Link) UnmarshalJSON ¶
type LinkObject ¶
type LinkObject struct { OperationRef string `json:"operationRef,omitempty"` OperationId string `json:"operationId,omitempty"` Parameters map[string]RuntimeExpression `json:"parameters,omitempty"` RequestBody RuntimeExpression `json:"requestBody,omitempty"` Description string `json:"description,omitempty"` Server *Server `json:"server,omitempty"` }
func (*LinkObject) AddParameter ¶
func (o *LinkObject) AddParameter(name string, expr RuntimeExpression)
func (*LinkObject) SetRequestBody ¶
func (o *LinkObject) SetRequestBody(expr RuntimeExpression)
type MediaType ¶
type MediaType struct { MediaTypeObject SpecExtensions }
func NewMediaTypeWithSchema ¶
func (MediaType) MarshalJSON ¶
func (*MediaType) UnmarshalJSON ¶
type MediaTypeObject ¶
type MediaTypeObject struct { Schema *Schema `json:"schema,omitempty"` Example interface{} `json:"example,omitempty"` WithExamples WithEncoding }
type OAuthFlow ¶
type OAuthFlow struct { OAuthFlowObject SpecExtensions }
func NewOAuthFlow ¶
func (OAuthFlow) MarshalJSON ¶
func (*OAuthFlow) UnmarshalJSON ¶
type OAuthFlowObject ¶
type OAuthFlows ¶
type OAuthFlows struct { OAuthFlowsObject SpecExtensions }
func (OAuthFlows) MarshalJSON ¶
func (i OAuthFlows) MarshalJSON() ([]byte, error)
func (*OAuthFlows) UnmarshalJSON ¶
func (i *OAuthFlows) UnmarshalJSON(data []byte) error
type OAuthFlowsObject ¶
type OpenAPI ¶
type OpenAPI struct { OpenAPIObject SpecExtensions }
Example ¶
openapi := NewOpenAPI() openapi.Version = "1.0.0" openapi.Title = "Swagger Petstore" openapi.License = &License{ LicenseObject: LicenseObject{ Name: "MIT", }, } openapi.AddTag(nil) openapi.AddTag(NewTag("pets")) openapi.AddSecurityScheme("token", NewHTTPSecurityScheme("bearer", "JWT")) openapi.AddServer(NewServer("http://petstore.swagger.io/v1")) openapi.AddSchema("Pet", ObjectOf(Props{ "id": Long(), "name": String(), "tag": String(), }, "id", "name")) openapi.AddSchema("Pets", ItemsOf(openapi.RefSchema("Pet"))) openapi.AddSchema("Error", ObjectOf(Props{ "code": Integer(), "message": String(), }, "code", "message")) { op := NewOperation("listPets") op.Summary = "List all pets" op.Tags = []string{"pets"} parameterLimit := QueryParameter("limit", Integer(), false). WithDesc("How many items to return at one time (max 100)") op.AddParameter(parameterLimit) { resp := NewResponse("An paged array of pets") s := String() s.Description = "A link to the next page of responses" resp.AddHeader("x-next", NewHeaderWithSchema(s)) resp.AddContent("application/json", NewMediaTypeWithSchema(openapi.RefSchema("Pets"))) op.AddResponse(http.StatusOK, resp) } { resp := NewResponse("unexpected error") resp.AddContent("application/json", NewMediaTypeWithSchema(openapi.RefSchema("Error"))) op.SetDefaultResponse(resp) } openapi.AddOperation(GET, "/pets", op) } { op := NewOperation("createPets") op.Summary = "Create a pet" op.Tags = []string{"pets"} { resp := NewResponse("Null response") op.AddResponse(http.StatusNoContent, resp) } { resp := NewResponse("unexpected error") resp.AddContent("application/json", NewMediaTypeWithSchema(openapi.RefSchema("Error"))) op.SetDefaultResponse(resp) } openapi.AddOperation(POST, "/pets", op) } data, _ := json.MarshalIndent(openapi, "\t", "\t") fmt.Println(string(data)) /* Output: { "openapi": "3.0.3", "info": { "title": "Swagger Petstore", "license": { "name": "MIT" }, "version": "1.0.0" }, "paths": { "/pets": { "get": { "tags": [ "pets" ], "summary": "List all pets", "operationId": "listPets", "parameters": [ { "name": "limit", "in": "query", "description": "How many items to return at one time (max 100)", "schema": { "type": "integer", "format": "int32" } } ], "responses": { "200": { "description": "An paged array of pets", "headers": { "x-next": { "schema": { "type": "string", "description": "A link to the next page of responses" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Pets" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "tags": [ "pets" ], "summary": "Create a pet", "operationId": "createPets", "responses": { "204": { "description": "Null response" }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } } }, "servers": [ { "url": "http://petstore.swagger.io/v1" } ], "tags": [ { "name": "pets" } ], "components": { "schemas": { "Error": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "code", "message" ] }, "Pet": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "id", "name" ] }, "Pets": { "type": "array", "items": { "$ref": "#/components/schemas/Pet" } } }, "securitySchemes": { "token": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } } */
Output: { "openapi": "3.0.3", "info": { "title": "Swagger Petstore", "license": { "name": "MIT" }, "version": "1.0.0" }, "paths": { "/pets": { "get": { "tags": [ "pets" ], "summary": "List all pets", "operationId": "listPets", "parameters": [ { "name": "limit", "in": "query", "description": "How many items to return at one time (max 100)", "schema": { "type": "integer", "format": "int32" } } ], "responses": { "200": { "description": "An paged array of pets", "headers": { "x-next": { "schema": { "type": "string", "description": "A link to the next page of responses" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Pets" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "post": { "tags": [ "pets" ], "summary": "Create a pet", "operationId": "createPets", "responses": { "204": { "description": "Null response" }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } } }, "servers": [ { "url": "http://petstore.swagger.io/v1" } ], "tags": [ { "name": "pets" } ], "components": { "schemas": { "Error": { "type": "object", "properties": { "code": { "type": "integer", "format": "int32" }, "message": { "type": "string" } }, "required": [ "code", "message" ] }, "Pet": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" } }, "required": [ "id", "name" ] }, "Pets": { "type": "array", "items": { "$ref": "#/components/schemas/Pet" } } }, "securitySchemes": { "token": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } } } }
func NewOpenAPI ¶
func NewOpenAPI() *OpenAPI
func (OpenAPI) MarshalJSON ¶
func (*OpenAPI) UnmarshalJSON ¶
type OpenAPIObject ¶
type OpenAPIObject struct { OpenAPI string `json:"openapi"` Info `json:"info"` Paths `json:"paths"` WithServers WithSecurityRequirement WithTags Components `json:"components"` }
type Operation ¶
type Operation struct { OperationObject SpecExtensions }
func NewOperation ¶
func (Operation) MarshalJSON ¶
func (*Operation) UnmarshalJSON ¶
func (Operation) WithSummary ¶
type OperationObject ¶
type OperationObject struct { Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` ExternalDocs *ExternalDoc `json:"externalDocs,omitempty"` OperationId string `json:"operationId"` WithParameters RequestBody *RequestBody `json:"requestBody,omitempty"` Responses Responses `json:"responses"` WithCallbacks WithSecurityRequirement Deprecated bool `json:"deprecated,omitempty"` WithServers }
func (*OperationObject) AddResponse ¶
func (o *OperationObject) AddResponse(statusCode int, r *Response)
func (*OperationObject) SetDefaultResponse ¶
func (o *OperationObject) SetDefaultResponse(r *Response)
func (*OperationObject) SetRequestBody ¶
func (o *OperationObject) SetRequestBody(rb *RequestBody)
type Operations ¶
type Operations struct {
Operations map[HttpMethod]*Operation
}
func (*Operations) AddOperation ¶
func (v *Operations) AddOperation(method HttpMethod, op *Operation)
func (Operations) MarshalJSON ¶
func (v Operations) MarshalJSON() ([]byte, error)
func (*Operations) UnmarshalJSON ¶
func (v *Operations) UnmarshalJSON(data []byte) error
type Parameter ¶
type Parameter struct { Reference ParameterObject SpecExtensions }
func PathParameter ¶
func (Parameter) MarshalJSON ¶
func (*Parameter) UnmarshalJSON ¶
type ParameterCommonObject ¶
type ParameterCommonObject struct { Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` Deprecated bool `json:"deprecated,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty"` Style ParameterStyle `json:"style,omitempty"` Explode bool `json:"explode,omitempty"` AllowReserved bool `json:"allowReserved,omitempty"` WithContentOrSchema Example interface{} `json:"example,omitempty"` WithExamples }
type ParameterObject ¶
type ParameterObject struct { Name string `json:"name"` In Position `json:"in"` ParameterCommonObject }
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 PathItem ¶
type PathItem struct { Operations PathItemObject SpecExtensions }
func (PathItem) MarshalJSON ¶
func (*PathItem) UnmarshalJSON ¶
type PathItemObject ¶
type Paths ¶
type Paths struct { Paths map[string]*PathItem SpecExtensions }
func (*Paths) AddOperation ¶
func (p *Paths) AddOperation(method HttpMethod, path string, op *Operation)
func (Paths) MarshalJSON ¶
func (*Paths) UnmarshalJSON ¶
type Reference ¶
type Reference struct {
Refer Refer
}
func (Reference) MarshalJSONRefFirst ¶
func (*Reference) UnmarshalJSONRefFirst ¶
type RequestBody ¶
type RequestBody struct { Reference RequestBodyObject SpecExtensions }
func NewRequestBody ¶
func NewRequestBody(desc string, required bool) *RequestBody
func (RequestBody) MarshalJSON ¶
func (r RequestBody) MarshalJSON() ([]byte, error)
func (*RequestBody) UnmarshalJSON ¶
func (r *RequestBody) UnmarshalJSON(data []byte) error
type RequestBodyObject ¶
type RequestBodyObject struct { Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` WithContent }
type Response ¶
type Response struct { Reference ResponseObject SpecExtensions }
func NewResponse ¶
func (Response) MarshalJSON ¶
func (*Response) UnmarshalJSON ¶
type ResponseObject ¶
type ResponseObject struct { Description string `json:"description"` WithHeaders WithContent WithLinks }
type Responses ¶
type Responses struct { ResponsesObject SpecExtensions }
func (Responses) MarshalJSON ¶
func (*Responses) UnmarshalJSON ¶
type ResponsesObject ¶
func (*ResponsesObject) AddResponse ¶
func (o *ResponsesObject) AddResponse(statusCode int, r *Response)
func (ResponsesObject) MarshalJSON ¶
func (o ResponsesObject) MarshalJSON() ([]byte, error)
func (*ResponsesObject) SetDefaultResponse ¶
func (o *ResponsesObject) SetDefaultResponse(r *Response)
func (*ResponsesObject) UnmarshalJSON ¶
func (o *ResponsesObject) UnmarshalJSON(data []byte) error
type RuntimeExpression ¶
type RuntimeExpression string
type Schema ¶
type Schema struct { Reference SchemaObject SpecExtensions }
func KeyValueOf ¶ added in v1.2.0
func RefSchemaByRefer ¶
func (Schema) MarshalJSON ¶
func (*Schema) SetProperty ¶
func (*Schema) UnmarshalJSON ¶
func (Schema) WithDiscriminator ¶
func (s Schema) WithDiscriminator(discriminator *Discriminator) *Schema
func (Schema) WithValidation ¶
func (s Schema) WithValidation(validation *SchemaValidation) *Schema
type SchemaObject ¶
type SchemaObject struct { Title string `json:"title,omitempty"` Type Type `json:"type,omitempty"` Format string `json:"format,omitempty"` Items *Schema `json:"items,omitempty"` Properties map[string]*Schema `json:"properties,omitempty"` AdditionalProperties *SchemaOrBool `json:"additionalProperties,omitempty"` PropertyNames *Schema `json:"propertyNames,omitempty"` SchemaValidation AllOf []*Schema `json:"allOf,omitempty"` AnyOf []*Schema `json:"anyOf,omitempty"` OneOf []*Schema `json:"oneOf,omitempty"` Not *Schema `json:"not,omitempty"` Description string `json:"description,omitempty"` Default interface{} `json:"default,omitempty"` Nullable bool `json:"nullable,omitempty"` Discriminator *Discriminator `json:"discriminator,omitempty"` ReadOnly bool `json:"readOnly,omitempty"` WriteOnly bool `json:"writeOnly,omitempty"` XML *XML `json:"xml,omitempty"` ExternalDocs *ExternalDoc `json:"external_docs,omitempty"` Example interface{} `json:"example,omitempty"` Deprecated bool `json:"deprecated,omitempty"` }
type SchemaOrBool ¶
func (*SchemaOrBool) MarshalJSON ¶
func (s *SchemaOrBool) MarshalJSON() ([]byte, error)
func (*SchemaOrBool) UnmarshalJSON ¶
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error
type SchemaValidation ¶
type SchemaValidation struct { // numbers MultipleOf *float64 `json:"multipleOf,omitempty"` Maximum *float64 `json:"maximum,omitempty"` ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"` Minimum *float64 `json:"minimum,omitempty"` ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"` // string MaxLength *uint64 `json:"maxLength,omitempty"` MinLength *uint64 `json:"minLength,omitempty"` Pattern string `json:"pattern,omitempty"` // array MaxItems *uint64 `json:"maxItems,omitempty"` MinItems *uint64 `json:"minItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` // object MaxProperties *uint64 `json:"maxProperties,omitempty"` MinProperties *uint64 `json:"minProperties,omitempty"` Required []string `json:"required,omitempty"` // any Enum []interface{} `json:"enum,omitempty"` }
type SecurityRequirement ¶
type SecurityScheme ¶
type SecurityScheme struct { SecuritySchemeObject SpecExtensions }
func NewAPIKeySecurityScheme ¶
func NewAPIKeySecurityScheme(name string, in Position) *SecurityScheme
func NewHTTPSecurityScheme ¶
func NewHTTPSecurityScheme(scheme string, bearerFormat string) *SecurityScheme
func NewOAuth2SecurityScheme ¶
func NewOAuth2SecurityScheme(oauthFlowsObject OAuthFlowsObject) *SecurityScheme
func NewOpenIdConnectSecurityScheme ¶
func NewOpenIdConnectSecurityScheme(openIdConnectUrl string) *SecurityScheme
func (SecurityScheme) MarshalJSON ¶
func (i SecurityScheme) MarshalJSON() ([]byte, error)
func (*SecurityScheme) UnmarshalJSON ¶
func (i *SecurityScheme) UnmarshalJSON(data []byte) error
type SecuritySchemeObject ¶
type SecuritySchemeObject struct { Type SecurityType `json:"type"` Description string `json:"description,omitempty"` Name string `json:"name,omitempty"` In Position `json:"in,omitempty"` Scheme string `json:"scheme,omitempty"` BearerFormat string `json:"bearerFormat,omitempty"` Flows *OAuthFlows `json:"flows,omitempty"` OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty"` }
type SecurityType ¶
type SecurityType string
const ( SecurityTypeAPIKey SecurityType = "apiKey" SecurityTypeHttp SecurityType = "http" SecurityTypeOAuth2 SecurityType = "oauth2" SecurityTypeOpenIdConnect SecurityType = "openIdConnect" )
type Server ¶
type Server struct { ServerObject SpecExtensions }
func (Server) MarshalJSON ¶
func (*Server) UnmarshalJSON ¶
type ServerObject ¶
type ServerObject struct { URL string `json:"url"` Description string `json:"description,omitempty"` Variables map[string]*ServerVariable `json:"variables,omitempty"` }
func (*ServerObject) AddVariable ¶
func (o *ServerObject) AddVariable(key string, v *ServerVariable)
type ServerVariable ¶
type ServerVariable struct { ServerVariableObject SpecExtensions }
func NewServerVariable ¶
func NewServerVariable(defaultValue string) *ServerVariable
func (ServerVariable) MarshalJSON ¶
func (i ServerVariable) MarshalJSON() ([]byte, error)
func (*ServerVariable) UnmarshalJSON ¶
func (i *ServerVariable) UnmarshalJSON(data []byte) error
type ServerVariableObject ¶
type SpecExtensions ¶
type SpecExtensions struct {
Extensions map[string]interface{}
}
func (*SpecExtensions) AddExtension ¶
func (v *SpecExtensions) AddExtension(key string, value interface{})
func (SpecExtensions) MarshalJSON ¶
func (v SpecExtensions) MarshalJSON() ([]byte, error)
func (*SpecExtensions) UnmarshalJSON ¶
func (v *SpecExtensions) UnmarshalJSON(data []byte) error
type StringRefer ¶
type StringRefer struct {
Ref string `json:"$ref,omitempty"`
}
func (StringRefer) RefString ¶
func (ref StringRefer) RefString() string
type Tag ¶
type Tag struct { TagObject SpecExtensions }
func (Tag) MarshalJSON ¶
func (*Tag) UnmarshalJSON ¶
type TagObject ¶
type TagObject struct { Name string `json:"name"` Description string `json:"description,omitempty"` ExternalDocs *ExternalDoc `json:"externalDocs,omitempty"` }
type WithCallbacks ¶
func (*WithCallbacks) AddCallback ¶
func (o *WithCallbacks) AddCallback(name string, c *Callback)
type WithContent ¶
func (*WithContent) AddContent ¶
func (o *WithContent) AddContent(contentType string, mt *MediaType)
type WithContentOrSchema ¶
type WithContentOrSchema struct { Schema *Schema `json:"schema,omitempty"` WithContent }
func (*WithContentOrSchema) AddContent ¶
func (o *WithContentOrSchema) AddContent(contentType string, mt *MediaType)
func (*WithContentOrSchema) SetSchema ¶
func (o *WithContentOrSchema) SetSchema(s *Schema)
type WithEncoding ¶
func (*WithEncoding) AddEncoding ¶
func (o *WithEncoding) AddEncoding(name string, e *Encoding)
type WithExamples ¶
func (*WithExamples) AddExample ¶
func (o *WithExamples) AddExample(name string, e *Example)
type WithHeaders ¶
func (*WithHeaders) AddHeader ¶
func (object *WithHeaders) AddHeader(name string, h *Header)
type WithParameters ¶
type WithParameters struct {
Parameters []*Parameter `json:"parameters,omitempty"`
}
func (*WithParameters) AddParameter ¶
func (object *WithParameters) AddParameter(p *Parameter)
type WithSecurityRequirement ¶
type WithSecurityRequirement struct {
Security []*SecurityRequirement `json:"security,omitempty"`
}
func (*WithSecurityRequirement) AddSecurityRequirement ¶
func (o *WithSecurityRequirement) AddSecurityRequirement(sr *SecurityRequirement)
type WithSecuritySchemes ¶
type WithSecuritySchemes struct {
SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`
}
func (*WithSecuritySchemes) AddSecurityScheme ¶
func (o *WithSecuritySchemes) AddSecurityScheme(name string, ss *SecurityScheme)
type WithServers ¶
type WithServers struct {
Servers []*Server `json:"servers,omitempty"`
}
func (*WithServers) AddServer ¶
func (o *WithServers) AddServer(s *Server)
Click to show internal directories.
Click to hide internal directories.