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 BodyKind
- type Definition
- type DefinitionDefault
- type Endpoint
- type Enum
- type EnumItem
- type EnumItems
- type Format
- type FormatError
- type HeaderParams
- type Http
- type HttpErrors
- 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
- 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 Security
- type SecurityRef
- type Spec
- type SpecOptions
- type SpecParseResult
- type SpecWalker
- func (w *SpecWalker) Api(api *Api)
- func (w *SpecWalker) HttpErrors(httpErrors *HttpErrors)
- func (w *SpecWalker) Model(model *NamedModel)
- func (w *SpecWalker) OnApi(callback func(api *Api)) *SpecWalker
- func (w *SpecWalker) OnHttpErrors(callback func(httpErrors *HttpErrors)) *SpecWalker
- func (w *SpecWalker) OnModel(callback func(model *NamedModel)) *SpecWalker
- func (w *SpecWalker) OnOperation(callback func(operation *NamedOperation)) *SpecWalker
- func (w *SpecWalker) OnOperationResponse(callback func(response *OperationResponse)) *SpecWalker
- func (w *SpecWalker) OnParam(callback func(param *NamedParam)) *SpecWalker
- func (w *SpecWalker) OnResponse(callback func(response *Response)) *SpecWalker
- func (w *SpecWalker) OnSpecification(callback func(specification *Spec)) *SpecWalker
- func (w *SpecWalker) OnType(callback func(typ *Type)) *SpecWalker
- func (w *SpecWalker) OnTypeDef(callback func(typ *TypeDef)) *SpecWalker
- func (w *SpecWalker) OnVersion(callback func(version *Version)) *SpecWalker
- func (w *SpecWalker) Operation(operation *NamedOperation)
- func (w *SpecWalker) OperationResponse(response *OperationResponse)
- func (w *SpecWalker) Param(param *NamedParam)
- func (w *SpecWalker) Response(response *Response)
- func (w *SpecWalker) Specification(specification *Spec)
- func (w *SpecWalker) Type(typ *Type)
- func (w *SpecWalker) TypeDef(typ *TypeDef)
- func (w *SpecWalker) Version(version *Version)
- 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 ¶
func MergeHttpStatusCodes ¶
func ReadSpecWithOptions ¶
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 InHttp *Http }
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 HttpErrors ¶
type HttpErrors struct { Responses Responses Models Models InSpec *Spec ResolvedModels []*NamedModel }
type Messages ¶
type Messages struct {
Items messages
}
func NewMessages ¶
func NewMessages() *Messages
func (*Messages) ContainsLevel ¶
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 NamedModel struct { Name Name Model InVersion *Version InHttpErrors *HttpErrors }
func OrderModels ¶
func OrderModels(models ModelsMap) []*NamedModel
type NamedOperation ¶
func (*NamedOperation) FullName ¶
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 ¶
type OperationResponse struct { Response Operation *NamedOperation }
type OperationResponses ¶
type OperationResponses []OperationResponse
func (OperationResponses) Get ¶
func (responses OperationResponses) Get(httpStatus string) *OperationResponse
func (OperationResponses) GetByStatusCode ¶
func (responses OperationResponses) GetByStatusCode(statusCode string) *OperationResponse
func (OperationResponses) HttpStatusCodes ¶
func (responses OperationResponses) HttpStatusCodes() []string
func (OperationResponses) MarshalYAML ¶
func (value OperationResponses) MarshalYAML() (interface{}, error)
func (*OperationResponses) UnmarshalYAML ¶
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 ¶
type Response struct { Name Name Definition }
type Responses ¶
type Responses []Response
func (Responses) GetByStatusCode ¶
func (Responses) GetByStatusName ¶
func (Responses) HttpStatusCodes ¶
func (Responses) MarshalYAML ¶
func (*Responses) UnmarshalYAML ¶
type Security ¶
type Security []SecurityRef
type SecurityRef ¶
type SecurityRef securityRef
func (SecurityRef) MarshalYAML ¶
func (value SecurityRef) MarshalYAML() (interface{}, error)
func (*SecurityRef) UnmarshalYAML ¶
func (value *SecurityRef) UnmarshalYAML(node *yaml.Node) error
type Spec ¶
type Spec struct { Meta Versions []Version HttpErrors *HttpErrors }
func (Spec) MarshalYAML ¶
func (*Spec) UnmarshalYAML ¶
type SpecOptions ¶
type SpecOptions struct {
AddErrors bool
}
type SpecParseResult ¶
type SpecWalker ¶
type SpecWalker struct {
// contains filtered or unexported fields
}
func NewWalker ¶
func NewWalker() *SpecWalker
func (*SpecWalker) Api ¶
func (w *SpecWalker) Api(api *Api)
func (*SpecWalker) HttpErrors ¶
func (w *SpecWalker) HttpErrors(httpErrors *HttpErrors)
func (*SpecWalker) Model ¶
func (w *SpecWalker) Model(model *NamedModel)
func (*SpecWalker) OnApi ¶
func (w *SpecWalker) OnApi(callback func(api *Api)) *SpecWalker
func (*SpecWalker) OnHttpErrors ¶
func (w *SpecWalker) OnHttpErrors(callback func(httpErrors *HttpErrors)) *SpecWalker
func (*SpecWalker) OnModel ¶
func (w *SpecWalker) OnModel(callback func(model *NamedModel)) *SpecWalker
func (*SpecWalker) OnOperation ¶
func (w *SpecWalker) OnOperation(callback func(operation *NamedOperation)) *SpecWalker
func (*SpecWalker) OnOperationResponse ¶
func (w *SpecWalker) OnOperationResponse(callback func(response *OperationResponse)) *SpecWalker
func (*SpecWalker) OnParam ¶
func (w *SpecWalker) OnParam(callback func(param *NamedParam)) *SpecWalker
func (*SpecWalker) OnResponse ¶
func (w *SpecWalker) OnResponse(callback func(response *Response)) *SpecWalker
func (*SpecWalker) OnSpecification ¶
func (w *SpecWalker) OnSpecification(callback func(specification *Spec)) *SpecWalker
func (*SpecWalker) OnType ¶
func (w *SpecWalker) OnType(callback func(typ *Type)) *SpecWalker
func (*SpecWalker) OnTypeDef ¶
func (w *SpecWalker) OnTypeDef(callback func(typ *TypeDef)) *SpecWalker
func (*SpecWalker) OnVersion ¶
func (w *SpecWalker) OnVersion(callback func(version *Version)) *SpecWalker
func (*SpecWalker) Operation ¶
func (w *SpecWalker) Operation(operation *NamedOperation)
func (*SpecWalker) OperationResponse ¶
func (w *SpecWalker) OperationResponse(response *OperationResponse)
func (*SpecWalker) Param ¶
func (w *SpecWalker) Param(param *NamedParam)
func (*SpecWalker) Response ¶
func (w *SpecWalker) Response(response *Response)
func (*SpecWalker) Specification ¶
func (w *SpecWalker) Specification(specification *Spec)
func (*SpecWalker) Type ¶
func (w *SpecWalker) Type(typ *Type)
func (*SpecWalker) TypeDef ¶
func (w *SpecWalker) TypeDef(typ *TypeDef)
func (*SpecWalker) Version ¶
func (w *SpecWalker) Version(version *Version)
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 ¶
type UrlPart struct { Part string Param *NamedParam }
type Version ¶
type Version struct { Name Name VersionSpecification InSpec *Spec ResolvedModels []*NamedModel }
type VersionSpecification ¶
func (VersionSpecification) MarshalYAML ¶
func (value VersionSpecification) MarshalYAML() (interface{}, error)
Source Files ¶
- api.go
- definition.go
- definitions.go
- endpoint.go
- enrich.go
- enrich_models.go
- enum.go
- errors.go
- format.go
- httpstatus.go
- message.go
- models.go
- models_order.go
- name.go
- object.go
- oneof.go
- operation.go
- operation_responses.go
- param.go
- params.go
- parse.go
- response.go
- security.go
- spec.go
- type.go
- util.go
- validation.go
- version.go
- walker.go
- yaml.go
Click to show internal directories.
Click to hide internal directories.