Documentation ¶
Index ¶
- Constants
- Variables
- func HttpStatusCode(statusName Name) string
- func HttpStatusName(statusCode string) string
- func MergeHttpStatusCodes(left, right []string) []string
- func ReadSpec(data []byte) (*Spec, *Messages, error)
- func ReadSpecWithOptions(options SpecOptions, data []byte) (*Spec, *Messages, error)
- func UrlParamStr(param *NamedParam) string
- func WriteSpec(spec *Spec) ([]byte, error)
- type Api
- type Apis
- type BodyKind
- type Definition
- type DefinitionDefault
- type Endpoint
- type Enum
- type EnumItem
- type EnumItems
- type Format
- type FormatError
- type HeaderParams
- type Level
- type Location
- type Message
- type Messages
- type Meta
- type Model
- type Models
- type ModelsMap
- type Name
- func (self Name) CamelCase() string
- func (self Name) Check(format Format) error
- func (self Name) FlatCase() string
- func (value Name) MarshalYAML() (interface{}, error)
- func (self Name) PascalCase() string
- func (self Name) SnakeCase() string
- func (value *Name) UnmarshalYAML(node *yaml.Node) error
- func (self Name) UpperCase() string
- type NamedDefinition
- type NamedDefinitions
- type NamedEnumItem
- type NamedModel
- type NamedOperation
- type NamedParam
- type Object
- type OneOf
- type Operation
- func (operation *Operation) BodyIs(kind BodyKind) bool
- func (operation *Operation) BodyKind() BodyKind
- func (operation *Operation) GetResponse(status string) *OperationResponse
- func (operation *Operation) HasParams() bool
- func (value Operation) MarshalYAML() (interface{}, error)
- func (value *Operation) UnmarshalYAML(node *yaml.Node) error
- type OperationResponse
- type OperationResponses
- func (responses OperationResponses) Get(httpStatus string) *OperationResponse
- func (responses OperationResponses) GetByStatusCode(statusCode string) *OperationResponse
- func (responses OperationResponses) HttpStatusCodes() []string
- func (value OperationResponses) MarshalYAML() (interface{}, error)
- func (value *OperationResponses) UnmarshalYAML(node *yaml.Node) error
- type Operations
- type Params
- type QueryParams
- type Response
- type Responses
- func (responses Responses) GetByStatusCode(statusCode string) *Response
- func (responses Responses) GetByStatusName(httpStatus string) *Response
- func (responses Responses) HttpStatusCodes() []string
- func (responses Responses) MarshalYAML() (interface{}, error)
- func (responses *Responses) UnmarshalYAML(node *yaml.Node) error
- type Spec
- type SpecOptions
- type SpecParseResult
- type Type
- type TypeDef
- type TypeInfo
- type TypeNode
- type TypeStructure
- type UrlParams
- type UrlPart
- type Version
- type VersionSpecification
Constants ¶
View Source
const ( HttpStatusInternalServerError string = "internal_server_error" HttpStatusNotFound string = "not_found" HttpStatusBadRequest string = "bad_request" )
View Source
const ( TypeInt32 string = "int32" TypeInt64 string = "int64" TypeFloat string = "float" TypeDouble string = "double" TypeDecimal string = "decimal" TypeBoolean string = "boolean" TypeString string = "string" TypeUuid string = "uuid" TypeDate string = "date" TypeDateTime string = "datetime" TypeJson string = "json" TypeEmpty string = "empty" )
View Source
const ( TypeAliasInt string = "int" TypeAliasLong string = "long" TypeAliasBool string = "bool" TypeAliasStr string = "str" )
View Source
const BadRequestError string = "BadRequestError"
View Source
const ErrorLocation string = "ErrorLocation"
View Source
const InternalServerError string = "InternalServerError"
View Source
const NotFoundError string = "NotFound"
View Source
const ValidationError string = "ValidationError"
Variables ¶
View Source
var Boolean = Format{Name: "boolean", Regex: "^true$|^false$", Example: "true or false"}
View Source
var Date = Format{Name: "date", Regex: "^\\d{4}-\\d{2}-\\d{2}$", Example: "2019-12-31"}
View Source
var DateTime = Format{Name: "datetime", Regex: "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$", Example: "2019-12-31T15:53:45"}
View Source
var Float = Format{Name: "float", Regex: "^[-+]?\\d+\\.?\\d*$", Example: "123.4"}
View Source
var HttpMethod = Format{Name: "HTTP method", Regex: "^GET|POST|PUT|DELETE$", Example: "GET, POST, PUT, DELETE"}
View Source
var HttpParams = Format{Name: "symbols a-z, A-Z, 0-9, -, _ starting from letter", Regex: "^[a-zA-Z]([a-zA-Z0-9_-])*$", Example: "some123, Some-123, some_123"}
View Source
var Integer = Format{Name: "integer", Regex: "^[-+]?\\d+$", Example: "123"}
View Source
var JsonField = Format{Name: "symbols a-z, A-Z, 0-9, _ starting from letter or _", Regex: "^[a-zA-Z_]([a-zA-Z_0-9])*$", Example: "some123, Some123, some_123, _some123"}
View Source
var LowerCase = Format{Name: "lower case", Regex: "^[a-z][a-z]*[0-9]*$", Example: "thisislowercase"}
View Source
var PascalCase = Format{Name: "pascal case", Regex: "^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)*$", Example: "ThisIsPascalCase"}
View Source
var SnakeCase = Format{Name: "snake case", Regex: "^[a-z][a-z0-9]*(_[a-z][a-z0-9]*)*$", Example: "this_is_snake_case"}
View Source
var SpecOptionsDefault = SpecOptions{true}
View Source
var SpecVersion = "2.1"
View Source
var Types = map[string]TypeInfo{ TypeInt32: {StructureScalar, true, nil}, TypeInt64: {StructureScalar, true, nil}, TypeFloat: {StructureScalar, true, nil}, TypeDouble: {StructureScalar, true, nil}, TypeDecimal: {StructureScalar, true, nil}, TypeBoolean: {StructureScalar, true, nil}, TypeString: {StructureScalar, true, nil}, TypeUuid: {StructureScalar, true, nil}, TypeDate: {StructureScalar, true, nil}, TypeDateTime: {StructureScalar, true, nil}, TypeJson: {StructureObject, false, nil}, TypeEmpty: {StructureNone, false, nil}, }
View Source
var TypesAliases = map[string]string{ TypeAliasInt: TypeInt32, TypeAliasLong: TypeInt64, TypeAliasBool: TypeBoolean, TypeAliasStr: TypeString, }
View Source
var UUID = Format{Name: "uuid", Regex: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$", Example: "fbd3036f-0f1c-4e98-b71c-d4cd61213f90"}
View Source
var VersionFormat = Format{Name: "version", Regex: "^v\\d+$", Example: "v1"}
Functions ¶
func HttpStatusCode ¶
func HttpStatusName ¶ added in v2.1.1222
func MergeHttpStatusCodes ¶ added in v2.1.1724
func ReadSpecWithOptions ¶ added in v2.1.1728
func ReadSpecWithOptions(options SpecOptions, data []byte) (*Spec, *Messages, error)
func UrlParamStr ¶
func UrlParamStr(param *NamedParam) string
Types ¶
type Api ¶
type Api struct { Name Name Operations Operations Http *Apis }
type Definition ¶
func (Definition) MarshalYAML ¶
func (value Definition) MarshalYAML() (interface{}, error)
func (*Definition) UnmarshalYAML ¶
func (value *Definition) UnmarshalYAML(node *yaml.Node) error
type DefinitionDefault ¶
func (DefinitionDefault) MarshalYAML ¶
func (value DefinitionDefault) MarshalYAML() (interface{}, error)
func (*DefinitionDefault) UnmarshalYAML ¶
func (value *DefinitionDefault) UnmarshalYAML(node *yaml.Node) error
type EnumItems ¶
type EnumItems []NamedEnumItem
func (EnumItems) MarshalYAML ¶
func (*EnumItems) UnmarshalYAML ¶
type FormatError ¶
func (*FormatError) Error ¶
func (err *FormatError) Error() string
type HeaderParams ¶
type HeaderParams Params
func (HeaderParams) MarshalYAML ¶
func (params HeaderParams) MarshalYAML() (interface{}, error)
func (*HeaderParams) UnmarshalYAML ¶
func (value *HeaderParams) UnmarshalYAML(node *yaml.Node) error
type Messages ¶
type Messages struct {
Items messages
}
func NewMessages ¶ added in v2.1.1547
func NewMessages() *Messages
func (*Messages) ContainsLevel ¶ added in v2.1.1547
type Meta ¶
type Meta struct { SpecVersion string `yaml:"spec"` Name Name `yaml:"name"` Title *string `yaml:"title,omitempty"` Description *string `yaml:"description,omitempty"` Version string `yaml:"version"` }
func (Meta) MarshalYAML ¶
type Model ¶
type Model struct { Object *Object Enum *Enum OneOf *OneOf Description *string Location *yaml.Node }
func (Model) MarshalYAML ¶
func (*Model) UnmarshalYAML ¶
type ModelsMap ¶
type ModelsMap map[string]*NamedModel
type Name ¶
type Name struct { Source string Location *yaml.Node }
func (Name) MarshalYAML ¶
func (Name) PascalCase ¶
func (*Name) UnmarshalYAML ¶
type NamedDefinition ¶
type NamedDefinition struct { Name Name Definition }
type NamedDefinitions ¶
type NamedDefinitions []NamedDefinition
func (NamedDefinitions) MarshalYAML ¶
func (value NamedDefinitions) MarshalYAML() (interface{}, error)
func (*NamedDefinitions) UnmarshalYAML ¶
func (value *NamedDefinitions) UnmarshalYAML(node *yaml.Node) error
type NamedEnumItem ¶
type NamedModel ¶
type NamedOperation ¶
func (*NamedOperation) FullName ¶ added in v2.1.1218
func (op *NamedOperation) FullName() string
func (*NamedOperation) FullUrl ¶
func (op *NamedOperation) FullUrl() string
type NamedParam ¶
type NamedParam struct { Name Name DefinitionDefault }
type Object ¶
type Object struct {
Fields NamedDefinitions `yaml:"object"`
}
type OneOf ¶
type OneOf struct { Discriminator *string `yaml:"discriminator,omitempty"` Items NamedDefinitions `yaml:"oneOf"` }
type Operation ¶
type Operation operation
func (*Operation) GetResponse ¶
func (operation *Operation) GetResponse(status string) *OperationResponse
func (Operation) MarshalYAML ¶
func (*Operation) UnmarshalYAML ¶
type OperationResponse ¶ added in v2.1.1659
type OperationResponse struct { Response Operation *NamedOperation }
type OperationResponses ¶ added in v2.1.1724
type OperationResponses []OperationResponse
func (OperationResponses) Get ¶ added in v2.1.1724
func (responses OperationResponses) Get(httpStatus string) *OperationResponse
func (OperationResponses) GetByStatusCode ¶ added in v2.1.1724
func (responses OperationResponses) GetByStatusCode(statusCode string) *OperationResponse
func (OperationResponses) HttpStatusCodes ¶ added in v2.1.1724
func (responses OperationResponses) HttpStatusCodes() []string
func (OperationResponses) MarshalYAML ¶ added in v2.1.1724
func (value OperationResponses) MarshalYAML() (interface{}, error)
func (*OperationResponses) UnmarshalYAML ¶ added in v2.1.1724
func (value *OperationResponses) UnmarshalYAML(node *yaml.Node) error
type Operations ¶
type Operations []NamedOperation
func (Operations) MarshalYAML ¶
func (value Operations) MarshalYAML() (interface{}, error)
func (*Operations) UnmarshalYAML ¶
func (value *Operations) UnmarshalYAML(node *yaml.Node) error
type Params ¶
type Params []NamedParam
type QueryParams ¶
type QueryParams Params
func (QueryParams) MarshalYAML ¶
func (params QueryParams) MarshalYAML() (interface{}, error)
func (*QueryParams) UnmarshalYAML ¶
func (value *QueryParams) UnmarshalYAML(node *yaml.Node) error
type Response ¶ added in v2.1.1659
type Response struct { Name Name Definition }
type Responses ¶
type Responses []Response
func (Responses) GetByStatusCode ¶ added in v2.1.1724
func (Responses) GetByStatusName ¶ added in v2.1.1724
func (Responses) HttpStatusCodes ¶ added in v2.1.1724
func (Responses) MarshalYAML ¶
func (*Responses) UnmarshalYAML ¶
type SpecOptions ¶ added in v2.1.1728
type SpecOptions struct {
AddErrors bool
}
type SpecParseResult ¶
type Type ¶
type Type struct { Definition TypeDef Location *yaml.Node }
func (*Type) UnmarshalYAML ¶
type TypeDef ¶
func (*TypeDef) IsNullable ¶
type TypeInfo ¶
type TypeInfo struct { Structure TypeStructure Defaultable bool Model *NamedModel }
func ArrayTypeInfo ¶
func ArrayTypeInfo() *TypeInfo
func MapTypeInfo ¶
func MapTypeInfo() *TypeInfo
func ModelTypeInfo ¶
func ModelTypeInfo(model *NamedModel) *TypeInfo
func NullableTypeInfo ¶
type TypeStructure ¶
type TypeStructure int
const ( StructureNone TypeStructure = 0 StructureScalar TypeStructure = 1 StructureArray TypeStructure = 2 StructureObject TypeStructure = 3 )
type UrlPart ¶ added in v2.1.1033
type UrlPart struct { Part string Param *NamedParam }
type Version ¶
type Version struct { Version Name VersionSpecification ResolvedModels []*NamedModel }
type VersionSpecification ¶ added in v2.1.993
func (VersionSpecification) MarshalYAML ¶ added in v2.1.993
func (value VersionSpecification) MarshalYAML() (interface{}, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.