openapi2

package
v1.18.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertOAS2FileToOAS3File

func ConvertOAS2FileToOAS3File(oas2file, oas3file string, perm os.FileMode, pretty bool) error

func CountEndpointsByTag

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

func EndpointCount

func EndpointCount(spec Specification) int

EndpointCount returns a count of the endpoints for a specification.

func FilenameIsYAML

func FilenameIsYAML(filename string) bool

FilenameIsYAML checks to see if a filename ends in `.yml` or `.yaml` with a case-insensitive match.

func GetJSONBodyParameterExampleForKey added in v1.12.0

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

func WriteEndpointCountCSV

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

func WriteFileDirMerge

func WriteFileDirMerge(outfile, inputDir string, perm os.FileMode) 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 {
	Delete  *Endpoint `json:"delete,omitempty"`
	Get     *Endpoint `json:"get,omitempty"`
	Head    *Endpoint `json:"head,omitempty"`
	Options *Endpoint `json:"options,omitempty"`
	Patch   *Endpoint `json:"patch,omitempty"`
	Post    *Endpoint `json:"post,omitempty"`
	Put     *Endpoint `json:"put,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 Spec added in v1.9.0

type Spec = oas2.T

func ConvertSpectrumOAS2ToKinOAS2

func ConvertSpectrumOAS2ToKinOAS2(smSpec *Specification) (*Spec, error)

func ReadOpenAPI2KinSpecFile

func ReadOpenAPI2KinSpecFile(filename string) (*Spec, error)

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 MergeFilepaths

func MergeFilepaths(filepaths []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 ReadOpenAPI2SpecFile

func ReadOpenAPI2SpecFile(filename string) (*Specification, error)

func ReadOpenAPI2SpecFileDirect

func ReadOpenAPI2SpecFileDirect(filename string) (Specification, error)

func ReadSwagger2SpecFile

func ReadSwagger2SpecFile(filepath string) (Specification, error)

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"`
}

Directories

Path Synopsis
openapi2openapi3 relies on `swagger2openapi` to convert Swagger 2.0 specs to OpenAPI 3.0 specs.
openapi2openapi3 relies on `swagger2openapi` to convert Swagger 2.0 specs to OpenAPI 3.0 specs.

Jump to

Keyboard shortcuts

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