Documentation ¶
Index ¶
- func GetMapString(v map[string]interface{}, key string) (string, error)
- func PrintAPIs(apis []API)
- func UnmarshalJSONString(v map[string]interface{}, key string, dest interface{}) error
- type API
- func LoadJSONBytes(buf []byte) ([]API, error)
- func LoadJSONFile(filename string) (schema []API, err error)
- func LoadJSONReader(r io.Reader) (schema []API, err error)
- func LoadJSONString(buf string) ([]API, error)
- func SlowLoadJSONBytes(buf []byte) ([]API, error)
- func SlowLoadJSONFile(filename string) (schema []API, err error)
- type ContentType
- type Operation
- type OperationTypes
- type Operations
- type Parameter
- func (p Parameter) GetAdditionalProperties() *Schema
- func (p Parameter) GetAllOf() []Schema
- func (p Parameter) GetDefault() interface{}
- func (p Parameter) GetExample() interface{}
- func (p Parameter) GetFormat() string
- func (p Parameter) GetIn() string
- func (p Parameter) GetItems() *Schema
- func (p Parameter) GetMaximum() float64
- func (p Parameter) GetMinimum() float64
- func (p Parameter) GetName() string
- func (p Parameter) GetPattern() string
- func (p Parameter) GetProperties() map[string]Schema
- func (p Parameter) GetSchema() *Schema
- func (p Parameter) GetType() string
- type Path
- type Schema
- func (s Schema) GetAdditionalProperties() *Schema
- func (s Schema) GetAllOf() []Schema
- func (s Schema) GetDefault() interface{}
- func (s Schema) GetExample() interface{}
- func (s Schema) GetFormat() string
- func (s Schema) GetIn() string
- func (s Schema) GetItems() *Schema
- func (s Schema) GetMaximum() float64
- func (s Schema) GetMinimum() float64
- func (s Schema) GetName() string
- func (s Schema) GetPattern() string
- func (s Schema) GetProperties() map[string]Schema
- func (s Schema) GetSchema() *Schema
- func (s Schema) GetType() string
- func (s Schema) IsZero() bool
- type SecurityDefinition
- type Typer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalJSONString ¶
Types ¶
type API ¶
type API struct { ID string `json:"ksuid,omitempty"` URL string `json:"url"` SecurityDefinitions map[string]SecurityDefinition `json:"securityDefinitions"` Paths map[Path]Operations `json:"paths"` }
func LoadJSONBytes ¶
LoadJSONBytes will load the schema from the provided bytes
func LoadJSONFile ¶
LoadJSONFile will load the json schema from the specified file
func LoadJSONString ¶
LoadString will load the schema from the provided string
func SlowLoadJSONBytes ¶
SlowLoadJSONBytes will unmarshal the buf into an interface{} and attempt to unmarshal each individual API while printing errors about the object This is a painful manual process when the kitebuilder spec was non-finalised
func SlowLoadJSONFile ¶
SlowLoadJSONFile will load the json schema from the specified file
type ContentType ¶
type ContentType string
type Operation ¶
type Operation struct { Description string `json:"description,omitempty"` OperationID string `json:"operationId,omitempty"` Parameters []Parameter `json:"parameter,omitempty"` Consumes []ContentType `json:"consume,omitempty"` Produces []ContentType `json:"produce,omitempty"` }
type OperationTypes ¶
type OperationTypes string
var ( GET OperationTypes = "get" DELETE OperationTypes = "delete" HEAD OperationTypes = "head" OPTIONS OperationTypes = "options" PATCH OperationTypes = "patch" POST OperationTypes = "post" PUT OperationTypes = "put" )
type Operations ¶
type Operations map[OperationTypes]Operation
Operations is a map of the verb to the operation data. technically we can have "parameters" here, but then we have dual types for this one object which is fucked
type Parameter ¶
type Parameter struct { Description string `json:"description,omitempty"` In string `json:"in,omitempty"` Name string `json:"name,omitempty"` Required interface{} `json:"required,omitempty"` Schema *Schema `json:"schema,omitempty"` // if in == "body" // if in != "body" Type string `json:"type,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty"` Pattern string `json:"pattern,omitempty"` Format string `json:"format,omitempty"` Example interface{} `json:"example,omitempty"` Minimum float64 `json:"minimum,omitempty"` Maximum float64 `json:"maximum,omitempty"` MaxLength uint64 `json:"maxLength,omitempty"` MaxItems uint64 `json:"maxItems,omitempty"` MinLength uint64 `json:"minLength,omitempty"` MinItems uint64 `json:"minItems,omitempty"` Enum []interface{} `json:"enum,omitempty"` // can be [1,2,3] ["a", "b", "c"] Default interface{} `json:"default,omitempty"` Items *Schema `json:"items,omitempty"` }
func (Parameter) GetAdditionalProperties ¶
func (Parameter) GetDefault ¶
func (p Parameter) GetDefault() interface{}
func (Parameter) GetExample ¶
func (p Parameter) GetExample() interface{}
func (Parameter) GetMaximum ¶
func (Parameter) GetMinimum ¶
func (Parameter) GetPattern ¶
func (Parameter) GetProperties ¶
type Schema ¶
type Schema struct { Properties map[string]Schema `json:"properties,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Title string `json:"title,omitempty" yaml:"title,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` Example interface{} `json:"example,omitempty" yaml:"example,omitempty"` Name string `json:"name,omitempty"` CollectionFormat string `json:"collectionFormat,omitempty"` // Array-related, here for struct compactness UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` // Number-related, here for struct compactness ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"` ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"` // Properties Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"` ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"` // can be either []string or bool. We don't actually pay attention to this field WriteOnly bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"` XML interface{} `json:"xml,omitempty" yaml:"xml,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` // Number Min float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"` Max float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"` MultipleOf float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"` // String MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"` MaxLength uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` // Array MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"` MaxItems uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"` Items *Schema `json:"items,omitempty" yaml:"items,omitempty"` AdditionalProperties *Schema `json:"additional_properties,omitempty"` // Object Required interface{} `json:"required,omitempty" yaml:"required,omitempty"` MinProps uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` MaxProps uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` AllOf []Schema `json:"allOf,omitempty"` }
func (Schema) GetAdditionalProperties ¶
func (Schema) GetDefault ¶
func (s Schema) GetDefault() interface{}
func (Schema) GetExample ¶
func (s Schema) GetExample() interface{}
func (Schema) GetMaximum ¶
func (Schema) GetMinimum ¶
func (Schema) GetPattern ¶
func (Schema) GetProperties ¶
type SecurityDefinition ¶
type Typer ¶
type Typer interface { GetType() string GetName() string GetExample() interface{} GetFormat() string GetPattern() string GetDefault() interface{} GetIn() string // exclusive to parameter, so a schema should return empty GetMinimum() float64 GetMaximum() float64 GetProperties() map[string]Schema GetAdditionalProperties() *Schema GetSchema() *Schema GetItems() *Schema GetAllOf() []Schema }
Typer provides an interface that makes parameter and schema generic. It provides a list of fields that allow both to be accessed as the same kind of object when reconstructing proute crumbs It doesnt totally fit over both, but its close/good enough with nillable types for determining whats possible and whats not possible