Documentation ¶
Index ¶
- Constants
- type BodyObject
- type Components
- type Contact
- type ExternalDocs
- type Format
- type Info
- type License
- type MIMEType
- type Media
- type Method
- type OpenAPI
- func (o *OpenAPI) AddParam(ur UniqueRoute, rp RouteParam) error
- func (o *OpenAPI) AddReqBody(ur UniqueRoute, bo BodyObject) error
- func (o *OpenAPI) AddResp(ur UniqueRoute, bo BodyObject) error
- func (o *OpenAPI) AddRoute(path, method, tag, desc, summary string) (ur UniqueRoute, err error)
- func (o *OpenAPI) AddTag(tag, description string)
- func (o *OpenAPI) AddTags(t Tags)
- func (o *OpenAPI) JSON() string
- type Operation
- type OperationMap
- type Param
- type Params
- type Paths
- type Properties
- type Property
- type Ref
- type Reference
- type RequestBody
- type Requests
- type Response
- type Responses
- type Route
- type RouteParam
- type RouteReq
- type RouteResp
- type Schema
- type Schemas
- type Server
- type ServerVar
- type Tag
- type Tags
- type Type
- type UniqueRoute
Constants ¶
View Source
const Default = "default"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyObject ¶
type BodyObject struct { MIMEType MIMEType // the mimetype for the object HttpStatus string // Any HTTP status code, '200', '201', '400' the value of 'default' can be used to cover all responses not defined Array bool // is the reference to an array Body any // the response object example used to determine the type and name of each field returned Desc string // description of the body Title string // object title }
type Components ¶
type Components struct { Schemas Schemas `json:"schema,omitempty"` RequestBodies map[string]RequestBody `json:"requestBodies,omitempty"` Params map[string]Param `json:"params,omitempty"` }
reusable reference objects
type Contact ¶
type Contact struct { Name string `json:"name"` // The identifying name of the contact person/organization. URL string `json:"url"` // The URL pointing to the contact information. MUST be in the format of a URL. Email string `json:"email"` // The email address of the contact person/organization. MUST be in the format of an email address. }
type ExternalDocs ¶
type Format ¶
type Format int
const ( Int32 Format = iota + 1 Int64 Float Double Byte // base64 encoded characters Binary // any sequence of octets Date // full-date - https://www.rfc-editor.org/rfc/rfc3339#section-5.6 DateTime // date-time - https://www.rfc-editor.org/rfc/rfc3339#section-5.6 Password )
type Info ¶
type Info struct { Title string `json:"title"` // REQUIRED. The title of the API. Desc string `json:"description"` // A short description of the API. CommonMark syntax MAY be used for rich text representation. Terms string `json:"termsOfService"` // A URL to the Terms of Service for the API. MUST be in the format of a URL. Contact *Contact `json:"contact"` // The contact information for the exposed API. License *License `json:"license"` // The license information for the exposed API. Version string `json:"version" required:"true"` // REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version). }
type MIMEType ¶
type MIMEType string
const ( Json MIMEType = "application/json" Xml MIMEType = "application/xml" Text MIMEType = "text/plain" General MIMEType = "application/octet-stream" Html MIMEType = "text/html" XForm MIMEType = "application/x-www-form-urlencoded" Jscript MIMEType = "application/javascript" Form MIMEType = "multipart/form-data" )
common media types
type OpenAPI ¶
type OpenAPI struct { Version string `json:"openapi"` // the semantic version number of the OpenAPI Specification version Tags []Tag `json:"tags,omitempty"` // A list of tags used by the specification with additional metadata Servers []Server `json:"servers,omitempty"` // Array of Server Objects, which provide connectivity information to a target server. Paths Paths `json:"paths"` // REQUIRED. Map of uri paths mapped to methods i.e., get, put, post, delete Info Info `json:"info"` // REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. //Components Components `json:"components,omitempty"` // reuseable components not used here ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` //Additional external documentation. // non OpenAPI external reference for simplified routes Routes map[UniqueRoute]Route `json:"-"` }
func (*OpenAPI) AddParam ¶
func (o *OpenAPI) AddParam(ur UniqueRoute, rp RouteParam) error
AddParam adds a param object to the given unique route
func (*OpenAPI) AddReqBody ¶
func (o *OpenAPI) AddReqBody(ur UniqueRoute, bo BodyObject) error
AddReq adds request information to the api requestBody object
func (*OpenAPI) AddResp ¶
func (o *OpenAPI) AddResp(ur UniqueRoute, bo BodyObject) error
AddResp adds response information to the api responses map this is used for a request body, response body
type Operation ¶
type Operation struct { Tags []string `json:"tags,omitempty"` Summary string `json:"summary,omitempty"` Desc string `json:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` OperationID string `json:"operationId,omitempty"` Params []Param `json:"parameters,omitempty"` // A list of parameters that are applicable for this operation. RequestBody *RequestBody `json:"requestBody,omitempty"` // The request body applicable for this operation. Responses Responses `json:"responses,omitempty"` // key 200,400 REQUIRED. The list of possible responses as they are returned from executing this operation. }
type OperationMap ¶
type Param ¶
type Param struct { Name string `json:"name,omitempty"` // REQUIRED. The name of the parameter. Parameter names are case sensitive. Desc string `json:"description,omitempty"` // A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. In string `json:"in"` // REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie". }
type Paths ¶
type Paths map[string]OperationMap
type Properties ¶
func (Properties) Construct ¶
func (pr Properties) Construct(item any)
type Property ¶
type Property struct { Type string `json:"type"` Format string `json:"format"` Desc string `json:"description"` Properties `json:"properties"` Items *Schema `json:"items"` }
type RequestBody ¶
type Requests ¶
type Requests map[string]RequestBody
key is the reference name for the open api spec
type Route ¶
type Route struct { Tag string Desc string Content MIMEType ReqType Type // the request type for the path i.e., array, object, string, integer RespType Type // the response type for the path i.e., array, object, string, integer Responses map[string]RouteResp // key references for responses Params map[string]RouteParam // key reference for params Requests map[string]RouteReq // key reference for requests }
type RouteParam ¶
type RouteParam struct { Name string // unique name reference Desc string // A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. Required bool // is this paramater required Location string // REQUIRED. The location of the parameter. Possible values are "query", "header", "path" or "cookie". Example map[string]any }
type Server ¶
type Server struct { URL string `json:"url"` // 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}. Desc string `json:"description"` // An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. Vars map[string]ServerVar `json:"variables"` // A map between a variable name and its value. The value is used for substitution in the server's URL template. }
type ServerVar ¶
type ServerVar struct { Enum []string `json:"enum"` // An enumeration of string values to be used if the substitution options are from a limited set. The array SHOULD NOT be empty. Default string `json:"default"` // REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. Note this behavior is different than the Schema Object's treatment of default values, because in those cases parameter values are optional. If the enum is defined, the value SHOULD exist in the enum's values. Desc string `json:"description"` // An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. }
type Tag ¶
type Tag struct { Name string `json:"name"` Desc string `json:"description"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"` }
type UniqueRoute ¶
Click to show internal directories.
Click to hide internal directories.