swagger2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountEndpointsByTag

func CountEndpointsByTag(spec Specification, tags []string) histogram.HistogramSet

func EndpointCount

func EndpointCount(spec Specification) int

EndpointCount returns a count of the endpoints for a specification.

func GetJsonBodyParameterExampleForKey

func GetJsonBodyParameterExampleForKey(params []Parameter, exampleKey string) (string, error)

func WriteEndpointCountCSV

func WriteEndpointCountCSV(filename string, hset histogram.HistogramSet) error

Types

type Definition

type Definition struct {
	Type       string              `json:"type,omitempty"`
	Properties map[string]Property `json:"properties,omitempty"`
}

type DocumentationPart

type DocumentationPart struct {
	Location   XAmazonApigatewayDocumentationPartLocation   `json:"location,omitempty"`
	Properties XAmazonApigatewayDocumentationPartProperties `json:"properties,omitempty"`
}

type Endpoint

type Endpoint struct {
	Tags                         []string                      `json:"tags,omitempty"`
	Summary                      string                        `json:"summary,omitempty"`
	OperationID                  string                        `json:"operationId,omitempty"`
	Description                  string                        `json:"description,omitempty"`
	Consumes                     []string                      `json:"consumes,omitempty"`
	Produces                     []string                      `json:"produces,omitempty"`
	Parameters                   []Parameter                   `json:"parameters,omitempty"`
	Responses                    map[string]Response           `json:"responses,omitempty"`
	XAmazonApigatewayIntegration *XAmazonApigatewayIntegration `json:"x-amazon-apigateway-integration,omitempty"`
}

Endpoint represents a Swagger 2.0 spec endpoint object.

func (*Endpoint) IsEmpty

func (ep *Endpoint) IsEmpty() bool

type ExternalDocs

type ExternalDocs struct {
	Description string `json:"description,omitempty"`
	URL         string `json:"url,omitempty"`
}

ExternalDocs represents a Swagger 2.0 spec tag object. The URL property is required.

type Header struct {
	Type        string `json:"type,omitempty"`
	Description string `json:"description,omitempty"`
}

type Info

type Info struct {
	Description    string `json:"description,omitempty"`
	Version        string `json:"version,omitempty"`
	Title          string `json:"title,omitempty"`
	TermsOfService string `json:"termsOfService,omitempty"`
}

Info represents a Swagger 2.0 spec info object.

type Items

type Items struct {
	Type string `json:"type,omitempty"`
	Ref  string `json:"$ref,omitempty"`
}

func (*Items) IsEmpty

func (items *Items) IsEmpty() bool

type Parameter

type Parameter struct {
	Name             string            `json:"name,omitempty"`
	Type             string            `json:"type,omitempty"`
	In               string            `json:"in,omitempty"`
	Description      string            `json:"description,omitempty"`
	Schema           *Schema           `json:"schema,omitempty"`
	Required         bool              `json:"required,omitempty"`
	CollectionFormat string            `json:"collectionFormat,omitempty"`
	Items            *Items            `json:"items,omitempty"`
	Default          interface{}       `json:"default,omitempty"`
	XExamples        map[string]string `json:"x-examples,omitempty"`
}

Parameter represents a Swagger 2.0 spec parameter object.

type Path

type Path struct {
	Get    *Endpoint `json:"get,omitempty"`
	Patch  *Endpoint `json:"patch,omitempty"`
	Post   *Endpoint `json:"post,omitempty"`
	Put    *Endpoint `json:"put,omitempty"`
	Delete *Endpoint `json:"delete,omitempty"`
	Ref    string    `json:"$ref,omitempty"`
}

Path represents a Swagger 2.0 spec path object.

func (*Path) HasMethodWithTag

func (p *Path) HasMethodWithTag(method string) bool

func (*Path) SetEndpoint

func (p *Path) SetEndpoint(method string, endpoint Endpoint) error

type Property

type Property struct {
	Description string `json:"description,omitempty"`
	Format      string `json:"format,omitempty"`
	Items       *Items `json:"items,omitempty"`
	Type        string `json:"type,omitempty"`
	Ref         string `json:"$ref,omitempty"`
}

type Response

type Response struct {
	Description string            `json:"description,omitempty"`
	Schema      *Schema           `json:"schema,omitempty"`
	Headers     map[string]Header `json:"headers,omitempty"`
	Examples    map[string]string `json:"examples,omitempty"`
}

type Schema

type Schema struct {
	Ref string `json:"$ref,omitempty"`
}

type Specification

type Specification struct {
	Swagger                        string                          `json:"swagger,omitempty"`
	Host                           string                          `json:"host,omitempty"`
	Info                           *Info                           `json:"info,omitempty"`
	BasePath                       string                          `json:"basePath,omitempty"`
	Schemes                        []string                        `json:"schemes,omitempty"`
	Tags                           []Tag                           `json:"tags,omitempty"`
	Paths                          map[string]Path                 `json:"paths,omitempty"`
	Definitions                    map[string]Definition           `json:"definitions,omitempty"`
	XAmazonApigatewayDocumentation *XAmazonApigatewayDocumentation `json:"x-amazon-apigateway-documentation,omitempty"`
}

Specification represents a Swagger 2.0 specification.

func CopyEndpointsByTag

func CopyEndpointsByTag(tag string, specOld, specNew Specification) (Specification, error)

func Merge

func Merge(specMaster, specExtra Specification) Specification

func MergeDefinitions

func MergeDefinitions(specMaster, specExtra Specification) Specification

func MergeDirectory

func MergeDirectory(dir string) (Specification, error)

func MergePaths

func MergePaths(specMaster, specExtra Specification) Specification

func MergeTags

func MergeTags(specMaster, specExtra Specification) Specification

func NewSpecificationFromBytes

func NewSpecificationFromBytes(data []byte) (Specification, error)

NewSpecificationFromBytes returns a Swagger Specification from a byte array.

func ReadSwagger2Spec added in v1.0.0

func ReadSwagger2Spec(filepath string) (Specification, error)

ReadSwagger2Spec returns a Swagger Specification from a filepath.

type Tag

type Tag struct {
	Name         string        `json:"name,omitempty"`
	Description  string        `json:"description,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty"`
}

Tag represents a Swagger 2.0 spec tag object.

type XAmazonApigatewayDocumentation

type XAmazonApigatewayDocumentation struct {
	Version            string              `json:"version,omitempty"`
	CreatedDate        string              `json:"createdDate,omitempty"`
	DocumentationParts []DocumentationPart `json:"documentationParts,omitempty"`
}

type XAmazonApigatewayDocumentationPartInfo

type XAmazonApigatewayDocumentationPartInfo struct {
	Description string `json:"description,omitempty"`
}

type XAmazonApigatewayDocumentationPartLocation

type XAmazonApigatewayDocumentationPartLocation struct {
	Type       string `json:"type,omitempty"`
	Method     string `json:"method,omitempty"`
	Path       string `json:"path,omitempty"`
	StatusCode string `json:"statusCode,omitempty"`
	Name       string `json:"name,omitempty"`
}

type XAmazonApigatewayDocumentationPartProperties

type XAmazonApigatewayDocumentationPartProperties struct {
	Tags        []string                                `json:"tags,omitempty"`
	Summary     string                                  `json:"summary,omitempty"`
	Description string                                  `json:"description,omitempty"`
	Info        *XAmazonApigatewayDocumentationPartInfo `json:"info,omitempty"`
}

type XAmazonApigatewayIntegration

type XAmazonApigatewayIntegration struct {
	Responses           map[string]XAmazonApigatewayIntegrationResponse `json:"responses,omitempty"`
	PassthroughBehavior string                                          `json:"passthroughBehavior,omitempty"`
	RequestTemplates    map[string]string                               `json:"requestTemplates,omitempty"`
	Type                string                                          `json:"type,omitempty"`
}

type XAmazonApigatewayIntegrationResponse

type XAmazonApigatewayIntegrationResponse struct {
	StatusCode         string            `json:"statusCode,omitempty"`
	ResponseParameters map[string]string `json:"responseParameters,omitempty"`
	ResponseTemplates  map[string]string `json:"responseTemplates,omitempty"`
}

Jump to

Keyboard shortcuts

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