Documentation
¶
Index ¶
- Constants
- Variables
- func GetSpecVersion(data []byte) (*string, error)
- func HttpStatusCode(statusName Name) string
- func UrlParamStr(paramName string) string
- func WriteSpec(spec *Spec) ([]byte, error)
- func WriteSpecFile(spec *Spec, filepath string) error
- func YamlString(value string) yaml.Node
- type Api
- type Apis
- type Definition
- type DefinitionDefault
- type Endpoint
- type Enum
- type EnumItem
- type EnumItems
- type Format
- type FormatError
- type HeaderParams
- 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 NamedResponse
- type Object
- type OneOf
- type Operation
- type Operations
- type Params
- type QueryParams
- type Responses
- type Spec
- type SpecParseResult
- type Type
- type TypeDef
- type TypeInfo
- type TypeNode
- type TypeStructure
- type UrlParams
- type Version
- type YamlMap
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 ( LevelError string = "error" LevelWarning string = "warning" )
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 SpecVersion = "2"
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 GetSpecVersion ¶
func HttpStatusCode ¶
func UrlParamStr ¶
func WriteSpecFile ¶
func YamlString ¶
Types ¶
type Api ¶
type Api struct {
Name Name
Operations Operations
Apis *Apis
}
type Apis ¶
func (Apis) MarshalYAML ¶
type Definition ¶
type Definition definition
func (Definition) MarshalYAML ¶
func (value Definition) MarshalYAML() (interface{}, error)
func (*Definition) UnmarshalYAML ¶
func (value *Definition) UnmarshalYAML(node *yaml.Node) error
type DefinitionDefault ¶
type DefinitionDefault definitionDefault
func (DefinitionDefault) MarshalYAML ¶
func (value DefinitionDefault) MarshalYAML() (interface{}, error)
func (*DefinitionDefault) UnmarshalYAML ¶
func (value *DefinitionDefault) UnmarshalYAML(node *yaml.Node) error
type Enum ¶
func (Enum) MarshalYAML ¶
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 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 ReadMetaFile ¶
func (Meta) MarshalYAML ¶
type ModelsMap ¶
type ModelsMap map[string]*NamedModel
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) FullUrl ¶
func (op *NamedOperation) FullUrl() string
type NamedParam ¶
type NamedParam struct {
Name Name
DefinitionDefault
}
type NamedResponse ¶
type NamedResponse struct {
Name Name
Definition
Operation *NamedOperation
}
type OneOf ¶
type OneOf struct {
Items NamedDefinitions `yaml:"oneOf"`
Discriminator *string `yaml:"discriminator"`
Description *string `yaml:"description"`
}
func (OneOf) MarshalYAML ¶
type Operation ¶
type Operation operation
func (*Operation) GetResponse ¶
func (operation *Operation) GetResponse(status string) *NamedResponse
func (Operation) MarshalYAML ¶
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 Spec ¶
func (Spec) MarshalYAML ¶
type SpecParseResult ¶
func ReadSpec ¶
func ReadSpec(data []byte) (*SpecParseResult, error)
func ReadSpecFile ¶
func ReadSpecFile(filepath string) (*SpecParseResult, error)
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 Version ¶
type Version struct {
Version Name
ResolvedModels []*NamedModel
// contains filtered or unexported fields
}
func (Version) MarshalYAML ¶
func (value Version) MarshalYAML() (interface{}, error)
type YamlMap ¶
func NewYamlMap ¶
func NewYamlMap() *YamlMap
func (*YamlMap) AddOmitNil ¶
func (*YamlMap) AddWithComment ¶
Click to show internal directories.
Click to hide internal directories.