Documentation
¶
Index ¶
- Constants
- func NewParser(modulePath, mainFilePath, handlerPath string, debug bool) (*parser, error)
- type ComponentsOjbect
- type ContactObject
- type HeaderObject
- type Headers
- type InfoObject
- type LicenseObject
- type MediaTypeObject
- type OpenAPIObject
- type OperationObject
- type ParameterObject
- type PathItemObject
- type PathsObject
- type Properties
- type ReferenceObject
- type RequestBodyObject
- type ResponseObject
- type ResponsesObject
- type SchemaObject
- type SecuritySchemeOauthFlowObject
- type SecuritySchemeOauthObject
- type SecuritySchemeObject
- type ServerObject
Constants ¶
View Source
const ( OpenAPIVersion = "3.0.0" ContentTypeText = "text/plain" ContentTypeJson = "application/json" ContentTypeOctetStream = "application/octet-stream" ContentTypeForm = "multipart/form-data" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ComponentsOjbect ¶
type ComponentsOjbect struct {
Schemas map[string]*SchemaObject `json:"schemas,omitempty"`
SecuritySchemes map[string]*SecuritySchemeObject `json:"securitySchemes,omitempty"`
}
type ContactObject ¶
type HeaderObject ¶
type HeaderObject struct {
Schema *SchemaObject `json:"schema,omitempty"`
Description string `json:"description,omitempty"`
}
type Headers ¶
type Headers struct {
*orderedmap.OrderedMap[string, HeaderObject]
}
func NewHeaders ¶
func NewHeaders() *Headers
func (*Headers) MarshalJSON ¶
type InfoObject ¶
type InfoObject struct {
Title string `json:"title"`
Description string `json:"description,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *ContactObject `json:"contact,omitempty"`
License *LicenseObject `json:"license,omitempty"`
Version string `json:"version"`
}
type LicenseObject ¶
type MediaTypeObject ¶
type MediaTypeObject struct {
Schema SchemaObject `json:"schema,omitempty"`
}
type OpenAPIObject ¶
type OpenAPIObject struct {
OpenAPI string `json:"openapi"` // Required
Info InfoObject `json:"info"` // Required
Servers []ServerObject `json:"servers,omitempty"`
Paths PathsObject `json:"paths"` // Required
Components ComponentsOjbect `json:"components,omitempty"` // Required for Authorization header
Security []map[string][]string `json:"security,omitempty"`
}
type OperationObject ¶
type OperationObject struct {
Responses ResponsesObject `json:"responses"` // Required
Tags []string `json:"tags,omitempty"`
OperationID string `json:"operationId,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Parameters []ParameterObject `json:"parameters,omitempty"`
RequestBody *RequestBodyObject `json:"requestBody,omitempty"`
}
type ParameterObject ¶
type ParameterObject struct {
Name string `json:"name"` // Required
In string `json:"in"` // Required. Possible values are "query", "header", "path" or "cookie"
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Example interface{} `json:"example,omitempty"`
Schema *SchemaObject `json:"schema,omitempty"`
// Ref is used when ParameterOjbect is as a ReferenceObject
Ref string `json:"$ref,omitempty"`
}
type PathItemObject ¶
type PathItemObject struct {
Ref string `json:"$ref,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Get *OperationObject `json:"get,omitempty"`
Post *OperationObject `json:"post,omitempty"`
Patch *OperationObject `json:"patch,omitempty"`
Put *OperationObject `json:"put,omitempty"`
Delete *OperationObject `json:"delete,omitempty"`
Options *OperationObject `json:"options,omitempty"`
Head *OperationObject `json:"head,omitempty"`
Trace *OperationObject `json:"trace,omitempty"`
}
type PathsObject ¶
type PathsObject map[string]*PathItemObject
type Properties ¶
type Properties struct {
*orderedmap.OrderedMap[string, *SchemaObject]
}
func NewProperties ¶
func NewProperties() *Properties
func (*Properties) MarshalJSON ¶
func (p *Properties) MarshalJSON() ([]byte, error)
type ReferenceObject ¶
type ReferenceObject struct {
Ref string `json:"$ref,omitempty"`
}
type RequestBodyObject ¶
type RequestBodyObject struct {
Content map[string]*MediaTypeObject `json:"content"` // Required
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
// Ref is used when RequestBodyObject is as a ReferenceObject
Ref string `json:"$ref,omitempty"`
}
type ResponseObject ¶
type ResponseObject struct {
Description string `json:"description"` // Required
Headers *Headers `json:"headers,omitempty"`
Content map[string]*MediaTypeObject `json:"content,omitempty"`
// Ref is for ReferenceObject
Ref string `json:"$ref,omitempty"`
}
type ResponsesObject ¶
type ResponsesObject map[string]*ResponseObject // [status]ResponseObject
type SchemaObject ¶
type SchemaObject struct {
ID string `json:"-"` // For goas
PkgName string `json:"-"` // For goas
FieldName string `json:"-"` // For goas
DisabledFieldNames map[string]struct{} `json:"-"` // For goas
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Required []string `json:"required,omitempty"`
Properties *Properties `json:"properties,omitempty"`
Description string `json:"description,omitempty"`
Items *SchemaObject `json:"items,omitempty"` // use ptr to prevent recursive error
Example interface{} `json:"example,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Minimum *int64 `json:"minimum,omitempty"`
Maximum *int64 `json:"maximum,omitempty"`
MinLength *int64 `json:"minLength,omitempty"`
MaxLength *int64 `json:"maxLength,omitempty"`
MinItems *int64 `json:"minItems,omitempty"`
MaxItems *int64 `json:"maxItems,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
// Ref is used when SchemaObject is as a ReferenceObject
Ref string `json:"$ref,omitempty"`
}
type SecuritySchemeOauthObject ¶
type SecuritySchemeOauthObject struct {
Implicit *SecuritySchemeOauthFlowObject `json:"implicit,omitempty"`
AuthorizationCode *SecuritySchemeOauthFlowObject `json:"authorizationCode,omitempty"`
ResourceOwnerPassword *SecuritySchemeOauthFlowObject `json:"password,omitempty"`
ClientCredentials *SecuritySchemeOauthFlowObject `json:"clientCredentials,omitempty"`
}
func (*SecuritySchemeOauthObject) ApplyScopes ¶
func (s *SecuritySchemeOauthObject) ApplyScopes(scopes map[string]string)
type SecuritySchemeObject ¶
type SecuritySchemeObject struct {
// Generic fields
Type string `json:"type"` // Required
Description string `json:"description,omitempty"`
// http
Scheme string `json:"scheme,omitempty"`
// apiKey
In string `json:"in,omitempty"`
Name string `json:"name,omitempty"`
// OpenID
OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty"`
// OAuth2
OAuthFlows *SecuritySchemeOauthObject `json:"flows,omitempty"`
}
type ServerObject ¶
Click to show internal directories.
Click to hide internal directories.