Documentation
¶
Overview ¶
Package openapi is a generated GoMock package.
Package openapi is a generated GoMock package.
Index ¶
- Constants
- func CreateNormalizedOpenAPISpecFromPath(path string) (*load.SpecInfo, error)
- func ExtractVersionsWithEnv(oas *openapi3.T, env string) ([]string, error)
- func NewArrayBytesFromOAS(oas *Spec, path, format string) ([]byte, error)
- func Save(path string, oas *openapi3.T, format string, fs afero.Fs) error
- func SaveToFile[T any](path, format string, content T, fs afero.Fs) error
- func SerializeToJSON[T any](data T) ([]byte, error)
- func SerializeToYAML(data []byte) ([]byte, error)
- func ValidateFormatAndOutput(format, output string) error
- type ByName
- type Differ
- type Merger
- type MockDiffGetter
- func (m *MockDiffGetter) EXPECT() *MockDiffGetterMockRecorder
- func (m *MockDiffGetter) Get(arg0 *diff.Config, arg1, arg2 *openapi3.T) (*diff.Diff, error)
- func (m *MockDiffGetter) GetWithOperationsSourcesMap(arg0 *diff.Config, arg1, arg2 *load.SpecInfo) (*diff.Diff, *diff.OperationsSourcesMap, error)
- type MockDiffGetterMockRecorder
- type MockMerger
- type MockMergerMockRecorder
- type MockParser
- type MockParserMockRecorder
- type OasDiff
- func (o *OasDiff) GetDiffWithConfig(base, revision *load.SpecInfo, config *diff.Config) (*OasDiffResult, error)
- func (o *OasDiff) GetFlattenedDiff(base, revision *load.SpecInfo) (*OasDiffResult, error)
- func (o *OasDiff) GetSimpleDiff(base, revision *load.SpecInfo) (*OasDiffResult, error)
- func (o *OasDiff) MergeOpenAPISpecs(paths []string) (*Spec, error)
- type OasDiffResult
- type OpenAPI3
- type Parser
- type ResultGetter
- type Spec
Constants ¶
const ( JSON = "json" YAML = "yaml" ALL = "all" DotYAML = ".yaml" DotJSON = ".json" )
Variables ¶
This section is empty.
Functions ¶
func CreateNormalizedOpenAPISpecFromPath ¶
CreateNormalizedOpenAPISpecFromPath reads the OpenAPI spec from the given path and normalizes it by replacing versioned media types (e.g. application/vnd.atlas.2023-01-01) with standard media types (e.g. application/json)..
func ExtractVersionsWithEnv ¶
ExtractVersionsWithEnv extracts API version Content Type strings from the given OpenAPI specification and environment. When env is not set, the function returns the API Versions from all the environments.
func NewArrayBytesFromOAS ¶
func Save ¶
Save saves the OpenAPI document to a file in the specified format. This is important for public OpenAPI documents as it ensures to follow the order of the Spec object.
func SaveToFile ¶
SaveToFile saves the content to a file in the specified format. If format is empty or set to 'all', it saves the content in both JSON and YAML formats.
func SerializeToJSON ¶
func SerializeToYAML ¶
func ValidateFormatAndOutput ¶
ValidateFormatAndOutput validates the format and output file match.
Types ¶
type Differ ¶
type Differ interface {
Get(config *diff.Config, base, revision *openapi3.T) (*diff.Diff, error)
GetWithOperationsSourcesMap(config *diff.Config, base, revision *load.SpecInfo) (*diff.Diff, *diff.OperationsSourcesMap, error)
}
DiffGetter defines an interface for getting diffs.
func NewResultGetter ¶
func NewResultGetter() Differ
type MockDiffGetter ¶
type MockDiffGetter struct {
// contains filtered or unexported fields
}
MockDiffGetter is a mock of DiffGetter interface.
func NewMockDiffGetter ¶
func NewMockDiffGetter(ctrl *gomock.Controller) *MockDiffGetter
NewMockDiffGetter creates a new mock instance.
func (*MockDiffGetter) EXPECT ¶
func (m *MockDiffGetter) EXPECT() *MockDiffGetterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockDiffGetter) GetWithOperationsSourcesMap ¶
func (m *MockDiffGetter) GetWithOperationsSourcesMap(arg0 *diff.Config, arg1, arg2 *load.SpecInfo) (*diff.Diff, *diff.OperationsSourcesMap, error)
GetWithOperationsSourcesMap mocks base method.
type MockDiffGetterMockRecorder ¶
type MockDiffGetterMockRecorder struct {
// contains filtered or unexported fields
}
MockDiffGetterMockRecorder is the mock recorder for MockDiffGetter.
func (*MockDiffGetterMockRecorder) Get ¶
func (mr *MockDiffGetterMockRecorder) Get(arg0, arg1, arg2 any) *gomock.Call
Get indicates an expected call of Get.
func (*MockDiffGetterMockRecorder) GetWithOperationsSourcesMap ¶
func (mr *MockDiffGetterMockRecorder) GetWithOperationsSourcesMap(arg0, arg1, arg2 any) *gomock.Call
GetWithOperationsSourcesMap indicates an expected call of GetWithOperationsSourcesMap.
type MockMerger ¶
type MockMerger struct {
// contains filtered or unexported fields
}
MockMerger is a mock of Merger interface.
func NewMockMerger ¶
func NewMockMerger(ctrl *gomock.Controller) *MockMerger
NewMockMerger creates a new mock instance.
func (*MockMerger) EXPECT ¶
func (m *MockMerger) EXPECT() *MockMergerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockMerger) MergeOpenAPISpecs ¶
func (m *MockMerger) MergeOpenAPISpecs(arg0 []string) (*Spec, error)
MergeOpenAPISpecs mocks base method.
type MockMergerMockRecorder ¶
type MockMergerMockRecorder struct {
// contains filtered or unexported fields
}
MockMergerMockRecorder is the mock recorder for MockMerger.
func (*MockMergerMockRecorder) MergeOpenAPISpecs ¶
func (mr *MockMergerMockRecorder) MergeOpenAPISpecs(arg0 any) *gomock.Call
MergeOpenAPISpecs indicates an expected call of MergeOpenAPISpecs.
type MockParser ¶
type MockParser struct {
// contains filtered or unexported fields
}
MockParser is a mock of Parser interface.
func NewMockParser ¶
func NewMockParser(ctrl *gomock.Controller) *MockParser
NewMockParser creates a new mock instance.
func (*MockParser) CreateOpenAPISpecFromPath ¶
func (m *MockParser) CreateOpenAPISpecFromPath(arg0 string) (*load.SpecInfo, error)
CreateOpenAPISpecFromPath mocks base method.
func (*MockParser) EXPECT ¶
func (m *MockParser) EXPECT() *MockParserMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockParserMockRecorder ¶
type MockParserMockRecorder struct {
// contains filtered or unexported fields
}
MockParserMockRecorder is the mock recorder for MockParser.
func (*MockParserMockRecorder) CreateOpenAPISpecFromPath ¶
func (mr *MockParserMockRecorder) CreateOpenAPISpecFromPath(arg0 any) *gomock.Call
CreateOpenAPISpecFromPath indicates an expected call of CreateOpenAPISpecFromPath.
type OasDiff ¶
type OasDiff struct {
// contains filtered or unexported fields
}
func NewOasDiffWithSpecInfo ¶
func (*OasDiff) GetDiffWithConfig ¶
func (o *OasDiff) GetDiffWithConfig(base, revision *load.SpecInfo, config *diff.Config) (*OasDiffResult, error)
GetDiffWithConfig returns the diff between two OpenAPI specs with a custom config.
func (*OasDiff) GetFlattenedDiff ¶
func (o *OasDiff) GetFlattenedDiff(base, revision *load.SpecInfo) (*OasDiffResult, error)
GetFlattenedDiff returns the diff between two OpenAPI specs after flattening them.
func (*OasDiff) GetSimpleDiff ¶
func (o *OasDiff) GetSimpleDiff(base, revision *load.SpecInfo) (*OasDiffResult, error)
GetSimpleDiff returns the diff between two OpenAPI specs.
type OasDiffResult ¶
type OasDiffResult struct {
Report *diff.Diff
SourceMap *diff.OperationsSourcesMap
SpecInfoPair *load.SpecInfoPair
Config *diff.Config
}
type OpenAPI3 ¶
type OpenAPI3 struct {
IsExternalRefsAllowed bool
ExcludePrivatePaths bool
CircularReferenceCounter int
Loader *openapi3.Loader
}
func NewOpenAPI3 ¶
func NewOpenAPI3() *OpenAPI3
func (*OpenAPI3) CreateOpenAPISpecFromPath ¶
func (*OpenAPI3) WithExcludedPrivatePaths ¶
type ResultGetter ¶
type ResultGetter struct{}
func (ResultGetter) GetWithOperationsSourcesMap ¶
func (ResultGetter) GetWithOperationsSourcesMap( config *diff.Config, base, revision *load.SpecInfo) (*diff.Diff, *diff.OperationsSourcesMap, error)
type Spec ¶
type Spec struct {
Extensions map[string]any `json:"-" yaml:"-"`
OpenAPI string `json:"openapi" yaml:"openapi"`
Security openapi3.SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
Servers openapi3.Servers `json:"servers,omitempty" yaml:"servers,omitempty"`
Tags openapi3.Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
Info *openapi3.Info `json:"info" yaml:"info"`
Paths *openapi3.Paths `json:"paths" yaml:"paths"`
Components *openapi3.Components `json:"components,omitempty" yaml:"components,omitempty"`
ExternalDocs *openapi3.ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
}
Spec is a struct is a 1-to-1 copy of the Spec struct in the openapi3 package. We need this to override the order of the fields in the struct.
func (*Spec) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Spec. We need a custom definition of MarshalJSON to include support for Extensions map[string]any `json:"-" yaml:"-"` where we only what to serialize the value of the field.
func (*Spec) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Spec.