openapi

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetRenderer added in v0.0.4

func SetRenderer(api *OpenAPI, renderer Renderer) error

func Traverse added in v0.0.4

func Traverse[T Traversable](node T, f TraversalFunc) (T, error)

Traverse takes a Traversable node and enters into a recursive loop (TraverseRecursor) that applies a given function to the node.

func TraverseRecursor added in v0.0.4

func TraverseRecursor[T Traversable](node T, f TraversalFunc) (T, error)

TraverseRecursor is an auxiliary function to Traverse that initiates a recursive loop over a tree of Traversable structs, applying a given function at every step.

Types

type Callback added in v0.0.4

type Callback struct{}

Callback is a programmatic representation of the Callback object defined here: https://swagger.io/specification/#callback-object

type Components

type Components struct {
	Schemas         map[string]Schema         // can also be a $ref
	Responses       map[string]Response       // can also be a $ref
	Parameters      map[string]Parameter      // can also be a $ref
	Examples        map[string]Example        // can also be a $ref
	RequestBodies   map[string]RequestBody    // can also be a $ref
	Headers         map[string]Header         // can also be a $ref
	SecuritySchemes map[string]SecurityScheme // can also be a $ref
	Links           map[string]Link           // can also be a $ref
	Callbacks       map[string]Callback       // can also be a $ref
}

Components is a programmatic representation of the Components object defined here: https://swagger.io/specification/#components-object

type Config added in v0.0.4

type Config struct {
	OpenAPIFile string
}

type Example added in v0.0.4

type Example struct {
	Summary       string      `yaml:"summary"`
	Description   string      `yaml:"description"`
	Value         interface{} `yaml:"value"` // TODO: does this imply an explicit need for reflective interpretation of data while marshalling?
	ExternalValue string      `yaml:"externalValue"`
}

Example is a programmatic representation of the Example object defined here: https://swagger.io/specification/#components-object

type ExternalDocs

type ExternalDocs struct {
	Description string `yaml:"description"`
	Url         string `yaml:"url"`
}

ExternalDocs is a programmatic representation of the External Docs object defined here: https://swagger.io/specification/#external-documentation-object

type GinRenderer added in v0.0.4

type GinRenderer struct{}
type Header struct{}

Header is a programmatic representation of the Header object defined here:https://swagger.io/specification/#header-object

type Info

type Info struct {
	Title          string `yaml:"title"`
	Description    string `yaml:"description"`
	TermsOfService string `yaml:"termsOfService"`
	Version        string `yaml:"version"`
	Contact        struct {
		Name  string `yaml:"name"`
		Url   string `yaml:"url"`
		Email string `yaml:"email"`
	}
	License struct {
		Name string `yaml:"name"`
		Url  string `yaml:"url"`
	}
}

Info is a programmatic representation of the Info object defined here: https://swagger.io/specification/#info-object

type Link struct{}

Link is a programmatic representation of the Link object defined here: https://swagger.io/specification/#link-object

type MediaType

type MediaType struct {
	Schema *Schema
	// contains filtered or unexported fields
}

MediaType is a programmatic representation of the MediaType object defined here: https://swagger.io/specification/#media-type-object

func (*MediaType) GetMetadata added in v0.0.4

func (n *MediaType) GetMetadata() map[string]string

func (*MediaType) GetName added in v0.0.4

func (m *MediaType) GetName() string

func (*MediaType) GetOutputFile added in v0.0.4

func (n *MediaType) GetOutputFile() string

func (*MediaType) GetParent added in v0.0.4

func (n *MediaType) GetParent() Traversable

func (*MediaType) SetMetadata added in v0.0.4

func (n *MediaType) SetMetadata(metadata map[string]string)

type OpenAPI

type OpenAPI struct {
	OpenAPI    string `yaml:"openapi"`
	Info       Info
	Servers    []Server
	Paths      map[string]*PathItem
	Components Components
	// contains filtered or unexported fields
}

OpenAPI is a programmatic representation of the OpenApi Document object defined here: https://swagger.io/specification/#openapi-object

func LoadOpenAPI

func LoadOpenAPI(openAPIFile string) (*OpenAPI, error)

func (*OpenAPI) GetMetadata added in v0.0.4

func (o *OpenAPI) GetMetadata() map[string]string

func (*OpenAPI) GetName added in v0.0.4

func (o *OpenAPI) GetName() string

func (*OpenAPI) GetOutputFile added in v0.0.4

func (o *OpenAPI) GetOutputFile() string

func (*OpenAPI) GetParent added in v0.0.4

func (n *OpenAPI) GetParent() Traversable

func (*OpenAPI) SetMetadata added in v0.0.4

func (o *OpenAPI) SetMetadata(metadata map[string]string)

type Operation

type Operation struct {
	Tags        []string
	Summary     string
	Description string
	Parameters  []Parameter          // can be a $ref
	RequestBody RequestBody          `yaml:"requestBody"` // can be a $ref
	Responses   map[string]*Response // can be a $ref
	//Callbacks 	map[string]*Callback // can be a $ref
	OperationId  string `yaml:"operationId"`
	ExternalDocs ExternalDocs
	// contains filtered or unexported fields
}

Operation is a programmatic representation of the Operation object defined here: https://swagger.io/specification/#operation-object

func (*Operation) GetMetadata added in v0.0.4

func (n *Operation) GetMetadata() map[string]string

func (*Operation) GetName added in v0.0.4

func (n *Operation) GetName() string

func (*Operation) GetOutputFile added in v0.0.4

func (n *Operation) GetOutputFile() string

func (*Operation) GetParent added in v0.0.4

func (n *Operation) GetParent() Traversable

func (*Operation) SetMetadata added in v0.0.4

func (n *Operation) SetMetadata(metadata map[string]string)

type Parameter

type Parameter struct {
	Ref             string  `yaml:"$ref"`
	Name            string  `yaml:"name"`
	In              string  `yaml:"in"`
	Description     string  `yaml:"description"`
	Required        bool    `yaml:"required"`
	Deprecated      bool    `yaml:"deprecated"`
	AllowEmptyValue bool    `yaml:"allowEmptyValue"`
	Schema          *Schema // Acts as alternative description of param
	// contains filtered or unexported fields
}

Parameter is a programmatic representation of the Parameter object defined here: https://swagger.io/specification/#parameter-object

func (*Parameter) GetMetadata added in v0.0.4

func (n *Parameter) GetMetadata() map[string]string

func (*Parameter) GetName added in v0.0.4

func (p *Parameter) GetName() string

func (*Parameter) GetOutputFile added in v0.0.4

func (p *Parameter) GetOutputFile() string

func (*Parameter) GetParent added in v0.0.4

func (n *Parameter) GetParent() Traversable

func (*Parameter) SetMetadata added in v0.0.4

func (n *Parameter) SetMetadata(metadata map[string]string)

type PathItem

type PathItem struct {
	Ref         string `yaml:"$ref"` // must be defined in the format of a PathItem object
	Summary     string
	Description string
	Get         *Operation
	Post        *Operation
	Patch       *Operation
	Delete      *Operation
	Parameters  []Parameter
	// contains filtered or unexported fields
}

PathItem is a programmatic representation of the Path Item object defined here: https://swagger.io/specification/#path-item-object

func (*PathItem) GetMetadata added in v0.0.4

func (n *PathItem) GetMetadata() map[string]string

func (*PathItem) GetName added in v0.0.4

func (n *PathItem) GetName() string

func (*PathItem) GetOutputFile added in v0.0.4

func (n *PathItem) GetOutputFile() string

func (*PathItem) GetParent added in v0.0.4

func (n *PathItem) GetParent() Traversable

func (*PathItem) GetPath added in v0.0.4

func (p *PathItem) GetPath() string

func (*PathItem) Operations

func (p *PathItem) Operations() map[string]Traversable

func (*PathItem) SetMetadata added in v0.0.4

func (n *PathItem) SetMetadata(metadata map[string]string)

type Renderer added in v0.0.4

type Renderer interface {
	// contains filtered or unexported methods
}

type RequestBody

type RequestBody struct {
	Ref         string
	Description string
	Content     map[string]*MediaType
	Required    bool
	// contains filtered or unexported fields
}

RequestBody is a programmatic representation of the RequestBody object defined here: https://swagger.io/specification/#request-body-object

func (*RequestBody) GetMetadata added in v0.0.4

func (n *RequestBody) GetMetadata() map[string]string

func (*RequestBody) GetName added in v0.0.4

func (r *RequestBody) GetName() string

func (*RequestBody) GetOutputFile added in v0.0.4

func (n *RequestBody) GetOutputFile() string

func (*RequestBody) GetParent added in v0.0.4

func (n *RequestBody) GetParent() Traversable

func (*RequestBody) SetMetadata added in v0.0.4

func (n *RequestBody) SetMetadata(metadata map[string]string)

type Response

type Response struct {
	Ref         string
	Description string            `yaml:"description"`
	Headers     map[string]Header // can also be a $ref
	Content     map[string]MediaType
	Links       map[string]Link // can also be a $ref
	// contains filtered or unexported fields
}

Response is a programmatic representation of the Response object defined here: https://swagger.io/specification/#response-object

func (*Response) GetMetadata added in v0.0.4

func (n *Response) GetMetadata() map[string]string

func (*Response) GetName added in v0.0.4

func (r *Response) GetName() string

func (*Response) GetOutputFile added in v0.0.4

func (n *Response) GetOutputFile() string

func (*Response) GetParent added in v0.0.4

func (n *Response) GetParent() Traversable

func (*Response) SetMetadata added in v0.0.4

func (n *Response) SetMetadata(metadata map[string]string)

type Schema

type Schema struct {
	Ref                  string `yaml:"$ref"`
	Description          string
	Type                 string
	Properties           map[string]*Schema
	Items                *Schema
	AdditionalProperties bool
	MinLength            int `yaml:"minLength"`
	MaxLength            int `yaml:"maxLength"`
	Pattern              string
	Format               string
	Required             []string
	// contains filtered or unexported fields
}

Schema is a programmatic representation of the Schema object defined here: https://swagger.io/specification/#schema-object

func (*Schema) GetMetadata added in v0.0.4

func (n *Schema) GetMetadata() map[string]string

func (*Schema) GetName added in v0.0.4

func (n *Schema) GetName() string

func (*Schema) GetOutputFile added in v0.0.4

func (n *Schema) GetOutputFile() string

func (*Schema) GetParent added in v0.0.4

func (n *Schema) GetParent() Traversable

func (*Schema) GetType added in v0.0.4

func (s *Schema) GetType() string

func (*Schema) SetMetadata added in v0.0.4

func (n *Schema) SetMetadata(metadata map[string]string)

type SecurityScheme added in v0.0.4

type SecurityScheme struct{}

SecurityScheme is a programmatic representation of the SecurityScheme object defined here: https://swagger.io/specification/#security-scheme-object

type Server added in v0.0.4

type Server struct {
	Url         string `yaml:"url"`
	Description string `yaml:"description"`
	Variables   map[string]ServerVariable
}

Server is a programmatic representation of the OpenApi Document object defined here: https://swagger.io/specification/#openapi-object

type ServerVariable added in v0.0.4

type ServerVariable struct {
	Enum        []string `yaml:"enum"`
	Default     string   `yaml:"default"`
	Description string   `yaml:"description"`
}

type Traversable added in v0.0.4

type Traversable interface {
	GetParent() Traversable

	// Node Attributes
	GetName() string

	GetOutputFile() string
	GetMetadata() map[string]string
	SetMetadata(metadata map[string]string)
	// contains filtered or unexported methods
}

func Dig added in v0.0.4

func Dig(node Traversable, key ...string) Traversable

type TraversalFunc added in v0.0.4

type TraversalFunc func(key string, parent, child Traversable) (Traversable, error)

Jump to

Keyboard shortcuts

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