load

package
v0.0.0-...-b7d109a Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package load loads OpenAPI specs from different sources like URLs, paths, globs and stdin Optionally, specs can be preprocessed after loading

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader interface {
	LoadFromURI(*url.URL) (*openapi3.T, error)
	LoadFromFile(string) (*openapi3.T, error)
	LoadFromStdin() (*openapi3.T, error)
}

Loader interface includes the OAS load functions

type Option

type Option func(Loader, []*SpecInfo) ([]*SpecInfo, error)

Option functions can be used to preprocess specs after loading them

func GetOption

func GetOption(option Option, enable bool) Option

GetOption returns the requested option or the identity option

func WithFlattenAllOf

func WithFlattenAllOf() Option

WithFlattenAllOf returns SpecInfos with flattened allOf

func WithFlattenParams

func WithFlattenParams() Option

WithFlattenParams returns SpecInfos with Common Parameters combined into operation parameters See here for Common Parameters definition: https://swagger.io/docs/specification/describing-parameters/

func WithIdentity

func WithIdentity() Option

WithIdentity returns the original SpecInfos

func WithLowercaseHeaders

func WithLowercaseHeaders() Option

WithLowercaseHeaders returns SpecInfos with header names converted to lowercase

type Source

type Source struct {
	Path string
	Uri  *url.URL
	Type SourceType
}

func NewSource

func NewSource(path string) *Source

func (*Source) IsFile

func (source *Source) IsFile() bool

func (*Source) IsStdin

func (source *Source) IsStdin() bool

func (*Source) Out

func (source *Source) Out() string

func (*Source) String

func (source *Source) String() string

type SourceType

type SourceType int
const (
	SourceTypeStdin SourceType = iota
	SourceTypeURL
	SourceTypeFile
)

type SpecInfo

type SpecInfo struct {
	Url     string
	Spec    *openapi3.T
	Version string
}

SpecInfo contains information about an OpenAPI spec and its metadata

func NewSpecInfo

func NewSpecInfo(loader Loader, source *Source, options ...Option) (*SpecInfo, error)

NewSpecInfo creates a SpecInfo from a local file path, a URL, or stdin

func NewSpecInfoFromGlob

func NewSpecInfoFromGlob(loader Loader, glob string, options ...Option) ([]*SpecInfo, error)

NewSpecInfoFromGlob creates SpecInfos from local files matching the specified glob parameter

func (*SpecInfo) GetVersion

func (specInfo *SpecInfo) GetVersion() string

type SpecInfoPair

type SpecInfoPair struct {
	Base     *SpecInfo
	Revision *SpecInfo
}

func NewSpecInfoPair

func NewSpecInfoPair(specInfo1, specInfo2 *SpecInfo) *SpecInfoPair

func (*SpecInfoPair) GetBaseVersion

func (specInfoPair *SpecInfoPair) GetBaseVersion() string

func (*SpecInfoPair) GetRevisionVersion

func (specInfoPair *SpecInfoPair) GetRevisionVersion() string

Jump to

Keyboard shortcuts

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