buttplugschema

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2021 License: ISC Imports: 15 Imported by: 0

Documentation

Overview

Package buttplugschema provides functions to fetch the buttplug.io JSON schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadRaw

func DownloadRaw(ref string) (*jsonschema.Schema, error)

DownloadRaw downloads the schema from GitHub with the given ref name.

func SchemaURL

func SchemaURL(ref string) string

SchemaURL gets the direct schema URL for the buttplug.io schema.

Types

type ArrayType

type ArrayType struct {
	BaseType
	Type Type
}

ArrayType describes a slice of type.

func (ArrayType) GoType

func (a ArrayType) GoType() string

type BaseType

type BaseType struct {
	// contains filtered or unexported fields
}

BaseType describes the base type that will always implement the Type interface but isn't useful by itself.

func (BaseType) Description

func (t BaseType) Description() string

Description implements Type.

func (BaseType) GoName

func (t BaseType) GoName() string

GoName implements Type.

func (BaseType) GoType

func (t BaseType) GoType() string

GoType implements Type.

func (BaseType) SchemaName

func (t BaseType) SchemaName() string

SchemaName implements Type.

type BooleanType

type BooleanType struct {
	BaseType
}

BooleanType describes a boolean type.

type EnumType

type EnumType struct {
	BaseType
	Values []EnumValue
}

EnumType describes an enumeration of string values.

type EnumValue

type EnumValue struct {
	GoName string
	Value  string
}

EnumValue is an enum value.

type Field

type Field struct {
	Type
	FieldName string // field name
	JSONName  string
	Required  bool
}

Field is a struct field.

func (Field) GoName

func (f Field) GoName() string

GoName returns the field name.

func (Field) ObjectType

func (f Field) ObjectType() ObjectType

ObjectType asserts Field's Type as an ObjectType.

type IntegerType

type IntegerType struct {
	BaseType
	Minimum *int
	Maximum *int
}

IntegerType describes an integer type.

func (IntegerType) LimitString

func (i IntegerType) LimitString() string

LimitString returns the limit in bracket notation. Null is translated to either "max" or "-max".

type Messages

type Messages struct {
	BaseType
	Fields []Field
}

Messages is the top-level message type.

type NumberType

type NumberType struct {
	BaseType
	Minimum *float64
	Maximum *float64
}

NumberType describes a floating point type.

func (NumberType) LimitString

func (n NumberType) LimitString() string

LimitString returns the limit in bracket notation. Null is translated to either "max" or "-max".

type ObjectType

type ObjectType struct {
	BaseType
	Fields []Field
}

ObjectType is a Type.

func (ObjectType) GoType

func (o ObjectType) GoType() string

func (ObjectType) RawGoType

func (o ObjectType) RawGoType() string

type OneOfType

type OneOfType struct {
	BaseType
	Types []Type
}

OneOfType describes a type union.

type Schema

type Schema struct {
	Messages  Messages
	Types     []Type
	GoImports []string
}

Schema provides methods to work with the buttplug.io JSON schema.

func Parse

func Parse(s *jsonschema.Schema) *Schema

Parse parses the given JSON schema.

func (*Schema) FindType

func (s *Schema) FindType(typeName string) Type

FindType finds the type with the given name from the global list of types.

type StringType

type StringType struct {
	BaseType
}

StringType describes a string type.

type Type

type Type interface {
	// GoName returns the Go name for the type. If it returns an empty string,
	// then the type is anonymous.
	GoName() string
	// GoType returns the Go representation of the type.
	GoType() string
	// SchemaName returns the original name.
	SchemaName() string
	// Description returns the description of the type.
	Description() string
	// contains filtered or unexported methods
}

Type describes any type.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL