spec

package
v0.0.0-...-c7220b3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: MIT Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const (
	InPath   = "path"   // Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in /items/{itemId}, the path parameter is itemId.
	InQuery  = "query"  // Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.
	InHeader = "header" // Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
	InCookie = "cookie" // Used to pass a specific cookie value to the API.
)

Parameter Locations There are four possible parameter locations specified by the in field:

View Source
const (
	MimeJSON        = "application/json"
	MimeXML         = "application/xml"
	MimeTextPlain   = "text/plain"
	MimeOctetStream = "application/octet-stream"
	MimeURLEncoded  = "application/x-www-form-urlencoded"
	MimeFormData    = "multipart/form-data"
)

Media type definitions are spread across several resources. The media type definitions SHOULD be in compliance with RFC6838. Some examples of possible media type definitions:

View Source
const (
	TypeBoolean = "boolean"
	TypeNumber  = "number"
	TypeInteger = "integer"
	TypeString  = "string"
	TypeObject  = "object"
	TypeArray   = "array"
)

Primitive data types in the OAS are based on the types supported by the JSON Schema Specification Wright Draft 00. Note that integer as a type is also supported and is defined as a JSON number without a fraction or exponent part. null is not supported as a type (see nullable for an alternative solution). Models are defined using the Schema Object, which is an extended subset of JSON Schema Specification Wright Draft 00.

View Source
const (
	SecurityHTTP          = "http"
	SecurityAPIKey        = "apiKey"
	SecurityOAuth2        = "oauth2"
	SecurityOpenIDConnect = "openIdConnect"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any []byte

Any is a raw encoded JSON value. It implements Marshaler and Unmarshaler and can be used to delay JSON decoding or precompute a JSON encoding.

func NewAny

func NewAny(v interface{}) Any

NewAny Create an any

func (Any) MarshalJSON

func (m Any) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*Any) UnmarshalJSON

func (m *Any) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type AnyOrExpressions

type AnyOrExpressions struct {
	Expressions Expressions
	Any         Any
}

AnyOrExpressions It's the Union type of any and expressions

func (AnyOrExpressions) MarshalJSON

func (m AnyOrExpressions) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*AnyOrExpressions) UnmarshalJSON

func (m *AnyOrExpressions) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type Callback

type Callback struct {
	Refable
	// contains filtered or unexported fields
}

Callback It's the Union type of callback and Refable

func RefCallback

func RefCallback(ref string) *Callback

RefCallback creates a ref callback

func (Callback) MarshalJSON

func (m Callback) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of callback or Refable.

func (*Callback) UnmarshalJSON

func (m *Callback) UnmarshalJSON(data []byte) error

UnmarshalJSON sets callback or Refable to data.

type Components

type Components struct {

	// An object to hold reusable Schema Objects.
	Schemas map[string]*Schema `json:"schemas,omitempty"`

	// An object to hold reusable Response Objects.
	Responses map[string]*Response `json:"responses,omitempty"`

	// An object to hold reusable Parameter Objects.
	Parameters map[string]*Parameter `json:"parameters,omitempty"`

	// An object to hold reusable Example Objects.
	Examples map[string]*Example `json:"examples,omitempty"`

	// An object to hold reusable Request Body Objects.
	RequestBodies map[string]*RequestBody `json:"requestBodies,omitempty"`

	// An object to hold reusable Header Objects.
	Headers map[string]*Header `json:"headers,omitempty"`

	// An object to hold reusable Security Scheme Objects.
	SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`

	// An object to hold reusable Link Objects.
	Links map[string]*Link `json:"links,omitempty"`

	// An object to hold reusable Callback Objects.
	Callbacks map[string]*Callback `json:"callbacks,omitempty"`
}

Components Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.

func NewComponents

func NewComponents() *Components

NewComponents create a new new components

type Contact

type Contact struct {

	// The identifying name of the contact person/organization.
	Name string `json:"name"`

	// The URL pointing to the contact information.
	// MUST be in the format of a URL.
	URL string `json:"url,omitempty"`

	// The email address of the contact person/organization.
	// MUST be in the format of an email address.
	Email string `json:"email,omitempty"`
}

Contact information for the exposed API.

type Discriminator

type Discriminator struct {

	// REQUIRED.
	// The name of the property in the payload that will hold the discriminator value.
	PropertyName string `json:"propertyName"`

	// An object to hold mappings between payload values and schema names or references.
	Mapping map[string]string `json:"mapping,omitempty"`
}

Discriminator When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, inline schemas will not be considered.

type Encoding

type Encoding struct {

	// The Content-Type for encoding a specific property.
	// Default value depends on the property type: for string with format being binary – application/octet-stream;
	// for other primitive types – text/plain; for object - application/json; for array – the default is defined based on the inner type.
	// The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the two types.
	ContentType string `json:"contentType"`

	// A map allowing additional information to be provided as headers, for example Content-Disposition.
	// Content-Type is described separately and SHALL be ignored in this section.
	// This property SHALL be ignored if the request body media type is not a multipart.
	Headers map[string]*Header `json:"headers,omitempty"`

	// Describes how a specific property value will be serialized depending on its type.
	// See Parameter Object for details on the style property.
	// The behavior follows the same values as query parameters, including default values.
	// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
	Style string `json:"style,omitempty"`

	// When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map.
	// For other types of properties this property has no effect.
	// When style is form, the default value is true.
	// For all other styles, the default value is false.
	// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
	Explode bool `json:"explode,omitempty"`

	// Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without percent-encoding.
	// The default value is false.
	// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
	AllowReserved bool `json:"allowReserved,omitempty"`
}

Encoding A single encoding definition applied to a single schema property.

type Example

type Example struct {
	Refable
	// contains filtered or unexported fields
}

Example It's the Union type of example and Refable

func RefExample

func RefExample(ref string) *Example

RefExample creates a ref example

func (Example) MarshalJSON

func (m Example) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of example or Refable.

func (*Example) UnmarshalJSON

func (m *Example) UnmarshalJSON(data []byte) error

UnmarshalJSON sets example or Refable to data.

type Expressions

type Expressions string

Expressions Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. This mechanism is used by Link Objects and Callback Objects. The runtime expression is defined by the following ABNF syntax

expression = ( "$url" | "$method" | "$statusCode" | "$request." source | "$response." source )
source = ( header-reference | query-reference | path-reference | body-reference )
header-reference = "header." token
query-reference = "query." name
path-reference = "path." name
body-reference = "body" ["#" fragment]
fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901)
name = *( char )
char = as per RFC [7159](https://tools.ietf.org/html/rfc7159#section-7)
token = as per RFC [7230](https://tools.ietf.org/html/rfc7230#section-3.2.6)

The name identifier is case-sensitive, whereas token is not. The table below provides examples of runtime expressions and examples of their use in a value:

type ExternalDocumentation

type ExternalDocumentation struct {

	// A short description of the target documentation.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// REQUIRED.
	// The URL for the target documentation.
	// Value MUST be in the format of a URL.
	URL string `json:"url,omitempty"`
}

ExternalDocumentation Allows referencing an external resource for extended documentation.

type Header struct {
	Refable
	// contains filtered or unexported fields
}

Header It's the Union type of header and Refable

func RefHeader

func RefHeader(ref string) *Header

RefHeader creates a ref header

func (*Header) AllowsEmptyValues

func (h *Header) AllowsEmptyValues() *Header

AllowsEmptyValues flags this parameter as being ok with empty values

func (*Header) AsOptional

func (h *Header) AsOptional() *Header

AsOptional flags this parameter as optional

func (Header) MarshalJSON

func (m Header) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of header or Refable.

func (*Header) NoEmptyValues

func (h *Header) NoEmptyValues() *Header

NoEmptyValues flags this parameter as not liking empty values

func (*Header) UnmarshalJSON

func (m *Header) UnmarshalJSON(data []byte) error

UnmarshalJSON sets header or Refable to data.

func (*Header) WithDescription

func (h *Header) WithDescription(description string) *Header

WithDescription sets the description on this response, allows for chaining

type Info

type Info struct {

	// REQUIRED.
	// The title of the application.
	Title string `json:"title"`

	// A short description of the application.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`

	// A URL to the Terms of Service for the API.
	// MUST be in the format of a URL.
	TermsOfService string `json:"termsOfService,omitempty"`

	// The contact information for the exposed API.
	Contact *Contact `json:"contact,omitempty"`

	// The license information for the exposed API.
	License *License `json:"license,omitempty"`

	// REQUIRED.
	// The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version).
	Version string `json:"version"`
}

Info The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.

type License

type License struct {

	// REQUIRED.
	// The license name used for the API.
	Name string `json:"name"`

	// A URL to the license used for the API.
	// MUST be in the format of a URL.
	URL string `json:"url,omitempty"`
}

License information for the exposed API.

type Link struct {
	Refable
	// contains filtered or unexported fields
}

Link It's the Union type of link and Refable

func RefLink(ref string) *Link

RefLink creates a ref link

func (Link) MarshalJSON

func (m Link) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of link or Refable.

func (*Link) UnmarshalJSON

func (m *Link) UnmarshalJSON(data []byte) error

UnmarshalJSON sets link or Refable to data.

type MediaType

type MediaType struct {
	// The schema defining the type used for the request body.
	Schema *Schema `json:"schema,omitempty"`

	// Any Example of the media type.
	// The example object SHOULD be in the correct format as specified by the media type.
	// The example field is mutually exclusive of the examples field.
	// Furthermore, if referencing a schema which contains an example, the example value SHALL override the example provided by the schema.
	Example Any `json:"example,omitempty"`

	// Examples of the media type. Each example object SHOULD match the media type and specified schema if present.
	// The examples field is mutually exclusive of the example field. Furthermore, if referencing a schema which contains an example, the examples value SHALL override the example provided by the schema.
	Examples map[string]*Example `json:"examples,omitempty"`

	// A map between a property name and its encoding information.
	// The key, being the property name, MUST exist in the schema as a property.
	// The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded.
	Encoding map[string]*Encoding `json:"encoding,omitempty"`
}

MediaType Each Media Type Object provides schema and examples for the media type identified by its key.

type OAuthFlow

type OAuthFlow struct {

	// oauth2 ("implicit", "authorizationCode")
	// REQUIRED.
	// The authorization URL to be used for this flow.
	// This MUST be in the form of a URL.
	AuthorizationURL string `json:"authorizationUrl,omitempty"`

	// oauth2 ("password", "clientCredentials", "authorizationCode")
	// REQUIRED.
	// The token URL to be used for this flow.
	// This MUST be in the form of a URL.
	TokenURL string `json:"tokenUrl,omitempty"`

	// oauth2	The URL to be used for obtaining refresh tokens.
	// This MUST be in the form of a URL.
	RefreshURL string `json:"refreshUrl,omitempty"`

	// oauth2
	// REQUIRED.
	// The available scopes for the OAuth2 security scheme.
	// A map between the scope name and a short description for it.
	Acopes map[string]string `json:"acopes,omitempty"`
}

OAuthFlow Configuration details for a supported OAuth Flow

type OAuthFlows

type OAuthFlows struct {

	// Configuration for the OAuth Implicit flow
	Implicit *OAuthFlow `json:"implicit,omitempty"`

	// Configuration for the OAuth Resource Owner Password flow
	Password *OAuthFlow `json:"password,omitempty"`

	// Configuration for the OAuth Client Credentials flow.
	// Previously called application in OpenAPI 2.0.
	ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty"`

	// Configuration for the OAuth Authorization Code flow.
	// Previously called accessCode in OpenAPI 2.0.
	AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty"`
}

OAuthFlows Allows configuration of the supported OAuth Flows.

type OpenAPI

type OpenAPI struct {

	// REQUIRED.
	// This string MUST be the semantic version number of the OpenAPI Specification version that the OpenAPI document uses.
	// The openapi field SHOULD be used by tooling specifications and clients to interpret the OpenAPI document.
	// This is not related to the API info.version string.
	OpenAPI string `json:"openapi,omitempty"`

	// REQUIRED.
	// Provides metadata about the API.
	// The metadata MAY be used by tooling as required.
	Info *Info `json:"info,omitempty"`

	// An array of Server Objects, which provide connectivity information to a target server.
	// If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /.
	Servers []*Server `json:"servers,omitempty"`

	// REQUIRED.
	// The available paths and operations for the API.
	Paths Paths `json:"paths,omitempty"`

	// An element to hold various schemas for the specification.
	Components *Components `json:"components,omitempty"`

	// A declaration of which security mechanisms can be used across the API.
	// The list of values includes alternative security requirement objects that can be used.
	// Only one of the security requirement objects need to be satisfied to authorize a request.
	// Individual operations can override this definition.
	Security []map[string]SecurityRequirement `json:"security,omitempty"`

	// A list of tags used by the specification with additional metadata.
	// The order of the tags can be used to reflect on their order by the parsing tools.
	// Not all tags that are used by the Operation Object must be declared.
	// The tags that are not declared MAY be organized randomly or based on the tools' logic.
	// Each tag name in the list MUST be unique.
	Tags []*Tag `json:"tags,omitempty"`

	// Additional extern
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

OpenAPI This is the root document object of the OpenAPI document.

type Operation

type Operation struct {

	// A list of tags for API documentation control.
	// Tags can be used for logical grouping of operations by resources or any other qualifier.
	Tags []string `json:"tags,omitempty"`

	// A short summary of what the operation does.
	Summary string `json:"summary,omitempty"`

	// A verbose explanation of the operation behavior.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this operation.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`

	// Unique string used to identify the operation.
	// The id MUST be unique among all operations described in the API.
	// Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.
	OperationID string `json:"operationId,omitempty"`

	// A list of parameters that are applicable for this operation.
	// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it.
	// The list MUST NOT include duplicated parameters.
	// A unique parameter is defined by a combination of a name and location.
	// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.
	Parameters []*Parameter `json:"parameters,omitempty"`

	// The request body applicable for this operation.
	// The requestBody is only supported in HTTP methods where the HTTP 1.1 specification RFC7231 has explicitly defined semantics for request bodies.
	// In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers.
	RequestBody *RequestBody `json:"requestBody,omitempty"`

	// REQUIRED.
	// The list of possible responses as they are returned from executing this operation.
	Responses map[string]*Response `json:"responses,omitempty"`

	// A map of possible out-of band callbacks related to the parent operation.
	// The key is a unique identifier for the Callback Object.
	// Each value in the map is a Callback Object that describes a request that may be initiated by the API provider and the expected responses.
	// The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.
	Callbacks map[string]*Callback `json:"callbacks,omitempty"`

	// Declares this operation to be deprecated.
	// Consumers SHOULD refrain from usage of the declared operation.
	// Default value is false.
	Deprecated bool `json:"deprecated,omitempty"`

	// A declaration of which security mechanisms can be used for this operation.
	// The list of values includes alternative security requirement objects that can be used.
	// Only one of the security requirement objects need to be satisfied to authorize a request.
	// This definition overrides any declared top-level security.
	// To remove a top-level security declaration, an empty array can be used.
	Security []map[string]SecurityRequirement `json:"security,omitempty"`

	// An alternative server array to service this operation.
	// If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this value.
	Servers []*Server `json:"servers,omitempty"`
}

Operation Describes a single API operation on a path.

type Parameter

type Parameter struct {
	Refable
	// contains filtered or unexported fields
}

Parameter It's the Union type of parameter and Refable

func CookieParam

func CookieParam(name string, schema *Schema) *Parameter

CookieParam creates a path parameter, this is always required

func HeaderParam

func HeaderParam(name string, schema *Schema) *Parameter

HeaderParam creates a header parameter, this is always required by default

func PathParam

func PathParam(name string, schema *Schema) *Parameter

PathParam creates a path parameter, this is always required

func QueryParam

func QueryParam(name string, schema *Schema) *Parameter

QueryParam creates a query parameter

func RefParameter

func RefParameter(ref string) *Parameter

RefParameter creates a ref rarameter

func (*Parameter) AllowsEmptyValues

func (p *Parameter) AllowsEmptyValues() *Parameter

AllowsEmptyValues flags this parameter as being ok with empty values

func (*Parameter) AsOptional

func (p *Parameter) AsOptional() *Parameter

AsOptional flags this parameter as optional

func (Parameter) MarshalJSON

func (m Parameter) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of parameter or Refable.

func (*Parameter) NoEmptyValues

func (p *Parameter) NoEmptyValues() *Parameter

NoEmptyValues flags this parameter as not liking empty values

func (*Parameter) UnmarshalJSON

func (m *Parameter) UnmarshalJSON(data []byte) error

UnmarshalJSON sets parameter or Refable to data.

func (*Parameter) WithDescription

func (p *Parameter) WithDescription(description string) *Parameter

WithDescription sets the description on this response, allows for chaining

func (*Parameter) WithLocation

func (p *Parameter) WithLocation(in string) *Parameter

WithLocation a fluent builder method to override the location of the parameter

func (*Parameter) WithName

func (p *Parameter) WithName(name string) *Parameter

WithName a fluent builder method to override the name of the parameter

func (*Parameter) WithSchema

func (p *Parameter) WithSchema(schema *Schema) *Parameter

WithSchema a fluent builder method to override the schema of the parameter

type PathItem

type PathItem struct {

	// An optional, string summary, intended to apply to all operations in this path.
	Summary string `json:"summary,omitempty"`

	// An optional, string description, intended to apply to all operations in this path.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`

	// A definition of a GET operation on this path.
	Get *Operation `json:"get,omitempty"`

	// A definition of a PUT operation on this path.
	Put *Operation `json:"put,omitempty"`

	// A definition of a POST operation on this path.
	Post *Operation `json:"post,omitempty"`

	// A definition of a DELETE operation on this path.
	Delete *Operation `json:"delete,omitempty"`

	// A definition of a OPTIONS operation on this path.
	Options *Operation `json:"options,omitempty"`

	// A definition of a HEAD operation on this path.
	Head *Operation `json:"head,omitempty"`

	// A definition of a PATCH operation on this path.
	Patch *Operation `json:"patch,omitempty"`

	// A definition of a TRACE operation on this path.
	Trace *Operation `json:"trace,omitempty"`

	// An alternative server array to service all operations in this path.
	Servers []*Server `json:"servers,omitempty"`

	// A list of parameters that are applicable for all the operations described under this path.
	// These parameters can be overridden at the operation level, but cannot be removed there.
	// The list MUST NOT include duplicated parameters.
	// A unique parameter is defined by a combination of a name and location.
	// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.
	Parameters []*Parameter `json:"parameters,omitempty"`
}

PathItem Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.

type Paths

type Paths map[string]*PathItem

Paths Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the Server Object in order to construct the full URL. The Paths MAY be empty, due to ACL constraints.

type Refable

type Refable struct {
	// REQUIRED.
	// The reference string.
	Ref        string
	Components string
}

Refable A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification.

func (Refable) MarshalJSON

func (m Refable) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*Refable) UnmarshalJSON

func (m *Refable) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type RequestBody

type RequestBody struct {
	Refable
	// contains filtered or unexported fields
}

RequestBody It's the Union type of requestBody and Refable

func FormDataRequestBody

func FormDataRequestBody(schema *Schema) *RequestBody

FormDataRequestBody creates a request body

func JSONRequestBody

func JSONRequestBody(schema *Schema) *RequestBody

JSONRequestBody creates a request body

func NewRequestBody

func NewRequestBody(typ string, schema *Schema) *RequestBody

NewRequestBody creates a request body

func OctetStreamRequestBody

func OctetStreamRequestBody(schema *Schema) *RequestBody

OctetStreamRequestBody creates a request body

func RefRequestBody

func RefRequestBody(ref string) *RequestBody

RefRequestBody creates a ref request body

func TextPlainRequestBody

func TextPlainRequestBody(schema *Schema) *RequestBody

TextPlainRequestBody creates a request body

func URLEncodedRequestBody

func URLEncodedRequestBody(schema *Schema) *RequestBody

URLEncodedRequestBody creates a request body

func XMLRequestBody

func XMLRequestBody(schema *Schema) *RequestBody

XMLRequestBody creates a request body

func (RequestBody) MarshalJSON

func (m RequestBody) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of requestBody or Refable.

func (*RequestBody) UnmarshalJSON

func (m *RequestBody) UnmarshalJSON(data []byte) error

UnmarshalJSON sets requestBody or Refable to data.

type Response

type Response struct {
	Refable
	// contains filtered or unexported fields
}

Response It's the Union type of response and Refable

func FormDataResponse

func FormDataResponse(schema *Schema) *Response

FormDataResponse creates a request body

func JSONResponse

func JSONResponse(schema *Schema) *Response

JSONResponse creates a request body

func NewResponse

func NewResponse(typ string, schema *Schema) *Response

NewResponse creates a response

func OctetStreamResponse

func OctetStreamResponse(schema *Schema) *Response

OctetStreamResponse creates a request body

func RefResponse

func RefResponse(ref string) *Response

RefResponse creates a ref responses

func TextPlainResponse

func TextPlainResponse(schema *Schema) *Response

TextPlainResponse creates a request body

func URLEncodedResponse

func URLEncodedResponse(schema *Schema) *Response

URLEncodedResponse creates a request body

func XMLResponse

func XMLResponse(schema *Schema) *Response

XMLResponse creates a request body

func (*Response) AddContent

func (r *Response) AddContent(name string, content *MediaType) *Response

AddContent adds a content to this response

func (*Response) AddHeader

func (r *Response) AddHeader(name string, header *Header) *Response

AddHeader adds a header to this response

func (r *Response) AddLink(name string, link *Link) *Response

AddLink adds a link to this response

func (Response) MarshalJSON

func (m Response) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of response or Refable.

func (*Response) RemoveContent

func (r *Response) RemoveContent(name string) *Response

RemoveContent removes a content from this response

func (*Response) RemoveHeader

func (r *Response) RemoveHeader(name string) *Response

RemoveHeader removes a header from this response

func (r *Response) RemoveLink(name string) *Response

RemoveLink removes a link from this response

func (*Response) UnmarshalJSON

func (m *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON sets response or Refable to data.

func (*Response) WithDescription

func (r *Response) WithDescription(description string) *Response

WithDescription sets the description on this response, allows for chaining

type Schema

type Schema struct {
	Refable
	// contains filtered or unexported fields
}

Schema It's the Union type of schema and Refable

func AllSchema

func AllSchema(schemas ...*Schema) *Schema

AllSchema creates a schema with allOf

func AnySchema

func AnySchema(schemas ...*Schema) *Schema

AnySchema creates a schema with anyOf

func ArrayProperty

func ArrayProperty(items *Schema) *Schema

ArrayProperty creates an array property

func BinaryProperty

func BinaryProperty() *Schema

BinaryProperty creates a string property any sequence of octets.

func BooleanProperty

func BooleanProperty() *Schema

BooleanProperty creates a boolean property

func ByteProperty

func ByteProperty() *Schema

ByteProperty creates a string property base64 encoded characters.

func DateProperty

func DateProperty() *Schema

DateProperty creates a date property

func DateTimeProperty

func DateTimeProperty() *Schema

DateTimeProperty creates a date time property

func Float32Property

func Float32Property() *Schema

Float32Property creates a float32/float property

func Float64Property

func Float64Property() *Schema

Float64Property creates a float64/double property

func FloatFmtProperty

func FloatFmtProperty(format string) *Schema

FloatFmtProperty creates a property for the named float format

func Int16Property

func Int16Property() *Schema

Int16Property creates an int16 property

func Int32Property

func Int32Property() *Schema

Int32Property creates an int32 property

func Int64Property

func Int64Property() *Schema

Int64Property creates an int64 property

func Int8Property

func Int8Property() *Schema

Int8Property creates an int8 property

func IntFmtProperty

func IntFmtProperty(format string) *Schema

IntFmtProperty creates a property for the named int format

func MapProperty

func MapProperty(property *Schema) *Schema

MapProperty creates a map property

func NotSchema

func NotSchema(schema *Schema) *Schema

NotSchema creates a schema with not

func OneSchema

func OneSchema(schemas ...*Schema) *Schema

OneSchema creates a schema with oneOf

func PasswordProperty

func PasswordProperty() *Schema

PasswordProperty creates a string property A hint to UIs to obscure input.

func RefSchemas

func RefSchemas(ref string) *Schema

RefSchemas creates a ref schemas

func StrFmtProperty

func StrFmtProperty(format string) *Schema

StrFmtProperty creates a property for the named string format

func StringProperty

func StringProperty() *Schema

StringProperty creates a string property

func (*Schema) AddRequired

func (s *Schema) AddRequired(items ...string) *Schema

AddRequired adds field names to the required properties array

func (*Schema) AddToAllOf

func (s *Schema) AddToAllOf(schemas ...*Schema) *Schema

AddToAllOf adds a schema to the allOf property

func (*Schema) AllowDuplicates

func (s *Schema) AllowDuplicates() *Schema

AllowDuplicates this array can have duplicates

func (*Schema) AsReadOnly

func (s *Schema) AsReadOnly() *Schema

AsReadOnly flags this schema as readonly

func (*Schema) AsUnwrappedXML

func (s *Schema) AsUnwrappedXML() *Schema

AsUnwrappedXML flags this object as an xml node

func (*Schema) AsWrappedXML

func (s *Schema) AsWrappedXML() *Schema

AsWrappedXML flags this object as wrapped, this is mostly useful for array types

func (*Schema) AsWritable

func (s *Schema) AsWritable() *Schema

AsWritable flags this schema as writeable (not read-only)

func (*Schema) AsXMLAttribute

func (s *Schema) AsXMLAttribute() *Schema

AsXMLAttribute flags this object as xml attribute

func (*Schema) AsXMLElement

func (s *Schema) AsXMLElement() *Schema

AsXMLElement flags this object as an xml node

func (Schema) MarshalJSON

func (m Schema) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of schema or Refable.

func (*Schema) UniqueValues

func (s *Schema) UniqueValues() *Schema

UniqueValues dictates that this array can only have unique items

func (*Schema) UnmarshalJSON

func (m *Schema) UnmarshalJSON(data []byte) error

UnmarshalJSON sets schema or Refable to data.

func (*Schema) WithAllOf

func (s *Schema) WithAllOf(schemas ...*Schema) *Schema

WithAllOf sets the all of property

func (*Schema) WithDefault

func (s *Schema) WithDefault(defaultValue Any) *Schema

WithDefault sets the default value on this parameter

func (*Schema) WithDescription

func (s *Schema) WithDescription(description string) *Schema

WithDescription sets the description for this schema, allows for chaining

func (*Schema) WithEnum

func (s *Schema) WithEnum(values ...Any) *Schema

WithEnum sets a the enum values (replace)

func (*Schema) WithExample

func (s *Schema) WithExample(example Any) *Schema

WithExample sets the example for this schema

func (*Schema) WithExternalDocs

func (s *Schema) WithExternalDocs(description, url string) *Schema

WithExternalDocs sets/removes the external docs for/from this schema. When you pass empty strings as params the external documents will be removed. When you pass non-empty string as one value then those values will be used on the external docs object. So when you pass a non-empty description, you should also pass the url and vice versa.

func (*Schema) WithFormat

func (s *Schema) WithFormat(format string) *Schema

WithFormat sets the format of this schema for a single value item

func (*Schema) WithMaxItems

func (s *Schema) WithMaxItems(size int64) *Schema

WithMaxItems sets the max items

func (*Schema) WithMaxLength

func (s *Schema) WithMaxLength(max int64) *Schema

WithMaxLength sets a max length value

func (*Schema) WithMaxProperties

func (s *Schema) WithMaxProperties(max int64) *Schema

WithMaxProperties sets the max number of properties an object can have

func (*Schema) WithMaximum

func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema

WithMaximum sets a maximum number value

func (*Schema) WithMinItems

func (s *Schema) WithMinItems(size int64) *Schema

WithMinItems sets the min items

func (*Schema) WithMinLength

func (s *Schema) WithMinLength(min int64) *Schema

WithMinLength sets a min length value

func (*Schema) WithMinProperties

func (s *Schema) WithMinProperties(min int64) *Schema

WithMinProperties sets the min number of properties an object must have

func (*Schema) WithMinimum

func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema

WithMinimum sets a minimum number value

func (*Schema) WithMultipleOf

func (s *Schema) WithMultipleOf(number float64) *Schema

WithMultipleOf sets a multiple of value

func (*Schema) WithPattern

func (s *Schema) WithPattern(pattern string) *Schema

WithPattern sets a pattern value

func (*Schema) WithProperties

func (s *Schema) WithProperties(schemas map[string]*Schema) *Schema

WithProperties sets the properties for this schema

func (*Schema) WithProperty

func (s *Schema) WithProperty(name string, schema *Schema) *Schema

WithProperty sets a property on this schema

func (*Schema) WithRequired

func (s *Schema) WithRequired(items ...string) *Schema

WithRequired flags this parameter as required

func (*Schema) WithTitle

func (s *Schema) WithTitle(title string) *Schema

WithTitle sets the title for this schema, allows for chaining

func (*Schema) WithType

func (s *Schema) WithType(typ, format string) *Schema

WithType sets the type of this schema for a single value item

func (*Schema) WithXMLName

func (s *Schema) WithXMLName(name string) *Schema

WithXMLName sets the xml name for the object

func (*Schema) WithXMLNamespace

func (s *Schema) WithXMLNamespace(namespace string) *Schema

WithXMLNamespace sets the xml namespace for the object

func (*Schema) WithXMLPrefix

func (s *Schema) WithXMLPrefix(prefix string) *Schema

WithXMLPrefix sets the xml prefix for the object

type SecurityRequirement

type SecurityRequirement []string

SecurityRequirement Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the Open API object or Operation Object, only one of Security Requirement Objects in the list needs to be satisfied to authorize the request. Each name MUST correspond to a security scheme which is declared in the Security Schemes under the Components Object. If the security scheme is of type "oauth2" or "openIdConnect", then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.

type SecurityScheme

type SecurityScheme struct {
	Refable
	// contains filtered or unexported fields
}

SecurityScheme It's the Union type of securityScheme and Refable

func APIKeyAuth

func APIKeyAuth(fieldName, valueSource string) *SecurityScheme

APIKeyAuth creates an api key auth security scheme

func BasicAuth

func BasicAuth() *SecurityScheme

BasicAuth creates a basic auth security scheme

func BearerAuth

func BearerAuth(bearerFormat string) *SecurityScheme

BearerAuth creates a bearer auth security scheme

func OAuth2AuthorizationCode

func OAuth2AuthorizationCode(tokenURL string) *SecurityScheme

OAuth2AuthorizationCode creates an application flow oauth2 security scheme

func OAuth2ClientCredentials

func OAuth2ClientCredentials(authorizationURL, tokenURL string) *SecurityScheme

OAuth2ClientCredentials creates an access token flow oauth2 security scheme

func OAuth2Implicit

func OAuth2Implicit(authorizationURL string) *SecurityScheme

OAuth2Implicit creates an implicit flow oauth2 security scheme

func OAuth2Password

func OAuth2Password(tokenURL string) *SecurityScheme

OAuth2Password creates a password flow oauth2 security scheme

func RefSecurityScheme

func RefSecurityScheme(ref string) *SecurityScheme

RefSecurityScheme creates a ref security schemes

func (SecurityScheme) MarshalJSON

func (m SecurityScheme) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of securityScheme or Refable.

func (*SecurityScheme) UnmarshalJSON

func (m *SecurityScheme) UnmarshalJSON(data []byte) error

UnmarshalJSON sets securityScheme or Refable to data.

type Server

type Server struct {

	// REQUIRED.
	// A URL to the target host.
	// This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served.
	// Variable substitutions will be made when a variable is named in {brackets}.
	URL string `json:"url"`

	// An optional string describing the host designated by the URL.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`

	// A map between a variable name and its value.
	// The value is used for substitution in the server's URL template.
	Variables map[string]*ServerVariable `json:"variables,omitempty"`
}

Server An object representing a Server.

func NewServers

func NewServers(uris ...string) ([]*Server, error)

NewServers Will list all possible server options based on all servers

type ServerVariable

type ServerVariable struct {

	// An enumeration of string values to be used if the substitution options are from a limited set.
	Enum []string `json:"enum,omitempty"`

	// REQUIRED.
	// The default value to use for substitution, and to send, if an alternate value is not supplied.
	// Unlike the Schema Object's default, this value MUST be provided by the consumer.
	Default string `json:"default"`

	// An optional description for the server variable.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`
}

ServerVariable An object representing a Server Variable for server URL template substitution.

type Tag

type Tag struct {

	// REQUIRED.
	// The name of the tag.
	Name string `json:"name"`

	// A short description for the tag.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this tag
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

Tag Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.

type XML

type XML struct {

	// Replaces the name of the element/attribute used for the described schema property.
	// When defined within items, it will affect the name of the individual XML elements within the list.
	// When defined alongside type being array (outside the items), it will affect the wrapping element and only if wrapped is true.
	// If wrapped is false, it will be ignored.
	Name string `json:"name"`

	// The URI of the namespace definition.
	// Value MUST be in the form of an absolute URI.
	Namespace string `json:"namespace,omitempty"`

	// The prefix to be used for the name.
	Prefix string `json:"prefix,omitempty"`

	// Declares whether the property definition translates to an attribute instead of an element.
	// Default value is false.
	Attribute bool `json:"attribute,omitempty"`

	// MAY be used only for an array definition.
	// Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>).
	// Default value is false.
	// The definition takes effect only when defined alongside type being array (outside the items).
	Wrapped bool `json:"wrapped,omitempty"`
}

XML A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are not inferred (for singular/plural forms) and the name property SHOULD be used to add that information. See examples for expected behavior.

func (*XML) AsAttribute

func (x *XML) AsAttribute() *XML

AsAttribute flags this object as xml attribute

func (*XML) AsElement

func (x *XML) AsElement() *XML

AsElement flags this object as an xml node

func (*XML) AsUnwrapped

func (x *XML) AsUnwrapped() *XML

AsUnwrapped flags this object as an xml node

func (*XML) AsWrapped

func (x *XML) AsWrapped() *XML

AsWrapped flags this object as wrapped, this is mostly useful for array types

func (*XML) WithName

func (x *XML) WithName(name string) *XML

WithName sets the xml name for the object

func (*XML) WithNamespace

func (x *XML) WithNamespace(namespace string) *XML

WithNamespace sets the xml namespace for the object

func (*XML) WithPrefix

func (x *XML) WithPrefix(prefix string) *XML

WithPrefix sets the xml prefix for the object

Directories

Path Synopsis
+build ignore +build ignore
+build ignore +build ignore

Jump to

Keyboard shortcuts

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