spec

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright (C) 2016-2017 dapperdox.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var APISuite map[string]*APISpecification
View Source
var StatusCodes map[int]string

Functions

func CamelToKebab

func CamelToKebab(s string) string

func HTTPStatusDescription

func HTTPStatusDescription(status int) string

func JSONMarshalIndent

func JSONMarshalIndent(v interface{}) ([]byte, error)

----------------------------------------------------------------------------- Wrapper around MarshalIndent to prevent < > & from being escaped

func LoadSpecifications

func LoadSpecifications(specHost string, collapse bool) error

func LoadStatusCodes

func LoadStatusCodes()

func TitleToKebab

func TitleToKebab(s string) string

Types

type APIGroup

type APIGroup struct {
	ID                     string
	Name                   string
	URL                    *url.URL
	MethodNavigationByName bool
	MethodSortBy           []string
	Versions               map[string][]Method // All versions, keyed by version string.
	Methods                []Method            // The current version
	CurrentVersion         string              // The latest version in operation for the API
	Info                   *Info
	Consumes               []string
	Produces               []string
}

APIGroup parents all grouped API methods (Grouping controlled by tagging, if used, or by method path otherwise)

type APISet

type APISet []APIGroup

type APISpecification

type APISpecification struct {
	ID      string
	APIs    APISet // APIs represents the parsed APIs
	APIInfo Info
	URL     string

	SecurityDefinitions map[string]SecurityScheme
	DefaultSecurity     map[string]Security
	ResourceList        map[string]map[string]*Resource // Version->ResourceName->Resource
	APIVersions         map[string]APISet               // Version->APISet
}

func (*APISpecification) GetByID

func (c *APISpecification) GetByID(id string) *APIGroup

GetByID returns an API by ID

func (*APISpecification) GetByName

func (c *APISpecification) GetByName(name string) *APIGroup

GetByName returns an API by name

func (*APISpecification) Load

func (c *APISpecification) Load(specLocation string, specHost string) error

----------------------------------------------------------------------------- Load loads API specs from the supplied host (usually local!)

type Header struct {
	Name                        string
	Description                 string
	Type                        []string // Will contain two elements if an array [0]=array [1]=What type is in the array
	CollectionFormat            string
	CollectionFormatDescription string
	Default                     string
	Required                    bool
	Enum                        []string
}

type Info

type Info struct {
	Title       string
	Description string
}

type Method

type Method struct {
	ID              string
	Name            string
	Description     string
	Method          string
	OperationName   string
	NavigationName  string
	Path            string
	Consumes        []string
	Produces        []string
	PathParams      []Parameter
	QueryParams     []Parameter
	HeaderParams    []Parameter
	BodyParam       *Parameter
	FormParams      []Parameter
	Responses       map[int]Response
	DefaultResponse *Response // A ptr to allow of easy checking of its existance in templates
	Resources       []*Resource
	Security        map[string]Security
	APIGroup        *APIGroup
	SortKey         string
}

Method represents an API method

type OAuth2Scheme

type OAuth2Scheme struct {
	OAuth2Flow       string
	AuthorizationUrl string
	TokenUrl         string
	Scopes           map[string]string
}

type Parameter

type Parameter struct {
	Name                        string
	Description                 string
	In                          string
	CollectionFormat            string
	CollectionFormatDescription string
	Required                    bool
	Type                        []string
	Enum                        []string
	Resource                    *Resource // For "in body" parameters
	IsArray                     bool      // "in body" parameter is an array
}

Parameter represents an API method parameter

type Resource

type Resource struct {
	ID                    string
	FQNS                  []string
	Title                 string
	Description           string
	Example               string
	Schema                string
	Type                  []string // Will contain two elements if an array or map [0]=array [1]=What type is in the array
	Properties            map[string]*Resource
	Required              bool
	ReadOnly              bool
	ExcludeFromOperations []string
	Methods               map[string]*Method
	Enum                  []string
	// contains filtered or unexported fields
}

Resource represents an API resource

type ResourceOrigin

type ResourceOrigin int
const (
	RequestBody ResourceOrigin = iota
	MethodResponse
)

type Response

type Response struct {
	Description       string
	StatusDescription string
	Resource          *Resource
	Headers           []Header
	IsArray           bool
}

Response represents an API method response

type Security

type Security struct {
	Scheme *SecurityScheme
	Scopes map[string]string
}

type SecurityScheme

type SecurityScheme struct {
	IsApiKey      bool
	IsBasic       bool
	IsOAuth2      bool
	Type          string
	Description   string
	ParamName     string
	ParamLocation string
	OAuth2Scheme
}

type SortMethods

type SortMethods []Method

func (SortMethods) Len

func (a SortMethods) Len() int

func (SortMethods) Less

func (a SortMethods) Less(i, j int) bool

func (SortMethods) Swap

func (a SortMethods) Swap(i, j int)

type Version

type Version struct {
	Version string
	Methods []Method
}

Jump to

Keyboard shortcuts

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