Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when an Object is not found.
Functions ¶
func ParseParams ¶
ParseParams returns a map of data parsed from the params string.
Types ¶
type Field ¶
type Field struct {
Name string `json:"name"`
NameLowerCamel string `json:"nameLowerCamel"`
Type FieldType `json:"type"`
OmitEmpty bool `json:"omitEmpty"`
Comment string `json:"comment"`
Tag string `json:"tag"`
ParsedTags map[string]FieldTag `json:"parsedTags"`
Example interface{} `json:"example"`
// Metadata are typed key/value pairs extracted from the comments.
Metadata map[string]interface{} `json:"metadata"`
}
Field describes the field inside an Object.
type FieldTag ¶
type FieldTag struct {
// Value is the value of the tag.
Value string `json:"value"`
// Options are the options for the tag.
Options []string `json:"options"`
}
FieldTag is a parsed tag. For more information, see Struct Tags in Go.
type FieldType ¶
type FieldType struct {
TypeID string `json:"typeID"`
TypeName string `json:"typeName"`
ObjectName string `json:"objectName"`
IsPointer bool `json:"isPointer"`
// CleanObjectName is the ObjectName with * removed for pointer types.
CleanObjectName string `json:"cleanObjectName"`
ObjectNameLowerCamel string `json:"objectNameLowerCamel"`
Multiple bool `json:"multiple"`
Package string `json:"package"`
IsObject bool `json:"isObject"`
JSType string `json:"jsType"`
TSType string `json:"tsType"`
SwiftType string `json:"swiftType"`
PHPType string `json:"phpType"`
}
FieldType holds information about the type of data that this Field stores.
func (FieldType) IsOptional ¶
IsOptional returns true for pointer types (optional).
type Method ¶
type Method struct {
Name string `json:"name"`
NameLowerCamel string `json:"nameLowerCamel"`
InputObject FieldType `json:"inputObject"`
OutputObject FieldType `json:"outputObject"`
Comment string `json:"comment"`
// Metadata are typed key/value pairs extracted from the comments.
Metadata map[string]interface{} `json:"metadata"`
}
Method describes a method that a Service can perform.
type Object ¶
type Object struct {
TypeID string `json:"typeID"`
Name string `json:"name"`
Imported bool `json:"imported"`
Fields []Field `json:"fields"`
Comment string `json:"comment"`
// Metadata are typed key/value pairs extracted from the comments.
Metadata map[string]interface{} `json:"metadata"`
}
Object describes a data structure that is part of this definition.
type Parser ¶
Parser parses Oto Go definition packages.
type Root ¶
type Root struct {
// PackageName is the name of the package.
PackageName string `json:"packageName"`
// Services are the services described in this definition.
Services []Service `json:"services"`
// Objects are the structures that are used throughout this definition.
Objects []Object `json:"objects"`
// Imports is a map of Go imports that should be imported into Go code.
Imports map[string]string `json:"imports"`
// Params contains additional data parsed from command line arguments
Params map[string]interface{} `json:"params"`
}
Root contains all service definitions and will be passed to template.
func (*Root) Example ¶
Example generates an object that is a realistic example of this object. Examples are read from the docs. This is experimental.
func (*Root) Object ¶
Object looks up an object by name. Returns ErrNotFound error if it cannot find it.
func (*Root) ObjectIsInput ¶
ObjectIsInput gets whether this object is a method input (request) type or not. Returns true if any method.InputObject.ObjectName matches name.
func (*Root) ObjectIsOutput ¶
ObjectIsOutput gets whether this object is a method output (response) type or not. Returns true if any method.OutputObject.ObjectName matches name.
type Service ¶
type Service struct {
Name string `json:"name"`
Methods []Method `json:"methods"`
Comment string `json:"comment"`
// Metadata are typed key/value pairs extracted from the comments.
Metadata map[string]interface{} `json:"metadata"`
}
Service describes a service, akin to an interface in Go.