describers

package
v0.0.0-...-5c28cf3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package describers holds different sources of restful scenarios

Index

Constants

View Source
const (
	RU  Permission = Read | Update          // RU permits Read and Update
	RC             = Read | Create          // RC permits Read and Create
	UC             = Update | Create        // UC permits Update and Create
	RUC            = Read | Update | Create // RUC permits Read, Update, and Create
)

Combined permission constants

View Source
const (
	BoolField        reflect.Kind = reflect.Bool    // BoolField  JSON boolean value
	StringField                   = reflect.String  // JSON string value
	NumberField                   = reflect.Float64 // JSON Number primitive value
	ArrayField                    = reflect.Slice   // JSON Array
	ObjectField                   = reflect.Map     // JSON Object
	CustomStructType              = reflect.Struct  // MSON defined type...won't we use relationships for this?
)

reflection constants used to represent MSON data types

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Name              string            // name of the field
	Description       string            // description of the field
	Kind              reflect.Kind      // type of field
	ExampleString     string            // string version of example value
	Required          bool              // true if the record must have this attribute filled
	Nullable          bool              // true if a required value can be nil (if required is false, nullable is forced true).
	Fixed             bool              // true if the value is a fixed value (in which case .Example is that value)
	Enums             map[string]string // string form of legal values if an enum field and their descriptions
	Regexp            *regexp.Regexp    // embedded validator regexp
	PermissionsInDocs Permission        // we'll expand these later
	Deprecation       string            // if not empty the field is being deprecated with this explanation/info/timeline
	Finalized         bool              // you shouldn't use unfinalized attributes. Call resources.Register() do it.
}

Attribute describe one field in a response. Consider Default and example values might be best handled by an instance of the struct itself. or more type-safe (allowing us to excise reflect), a factory function

type Permission

type Permission int

Permission is a bit field of the field-level actions a role is permitted.

const (
	Read   Permission = 1 << iota // Read means the field can be read
	Update                        // Update means the field can be written to in an existing record
	Create                        // Create means the field can be written to in a new record
)

Base permission constants

type Resource

type Resource struct {
	Type        string // string that tags this type of resource
	Description string
	Attributes  []*Attribute // The native attributes of the core resource
	Includes    map[string]string
	Filters     map[string]string
	IDs         map[string]string // example ID's. IDs["default"] should always be set.
	Special     bool              // if true, it's not a normal resource
	Finalized   bool
}

Resource describes a type of value in a response.

type Resources

type Resources struct {
	All []*Resource
	// contains filtered or unexported fields
}

Resources represents a group of registered resources

type SwaggerDescriber

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

SwaggerDescriber provides restful scenarios from a swagger file.

func LoadSwaggerDescriber

func LoadSwaggerDescriber(filename string) (result *SwaggerDescriber, err error)

LoadSwaggerDescriber creates a SwaggerDescriber from a yaml or json OpenApi file.

func (*SwaggerDescriber) GetRequest

func (ss *SwaggerDescriber) GetRequest(requestID string, body string, params ...string) (
	req *http.Request, expected *http.Response, err error)

GetRequest implements the Describer interface

func (*SwaggerDescriber) GetSchema

func (ss *SwaggerDescriber) GetSchema(typeID string) (result interface{}, err error)

GetSchema implements the Describer interface

func (*SwaggerDescriber) Operations

func (ss *SwaggerDescriber) Operations(topicID string) (result []string)

Operations lists the swagger operation IDs under a path, all if topicID is blank

func (*SwaggerDescriber) Requests

func (ss *SwaggerDescriber) Requests(scenarioID string) (result []string)

Requests lists the request(s) that make up a scenario. Swagger 2.0 only supports one request per return code, but some systems may allow more to represent tests

func (*SwaggerDescriber) Scenarios

func (ss *SwaggerDescriber) Scenarios(operationID string) (result []string)

Scenarios lists the different status code responses of an operation (swagger verb + path)

func (*SwaggerDescriber) Topics

func (ss *SwaggerDescriber) Topics() (result []string)

Topics lists the paths in the swagger document

func (*SwaggerDescriber) Types

func (ss *SwaggerDescriber) Types() (result []string)

Types lists the embedded type definitions in the swagger spec.

Jump to

Keyboard shortcuts

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