filter

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package filter provides functionality to filter OpenAPI specs based on config. It allows filtering of paths, methods, components, and other OpenAPI elements while maintaining the integrity of the spec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectComponent added in v0.3.3

func CollectComponent(rc *RefsCollector,
	comps *openapi3.Components,
	typ ComponentType,
	name string,
)

func ComponentTypeToCfgNames added in v0.3.2

func ComponentTypeToCfgNames(
	cfg *config.FilterComponentsConfig,
	typ ComponentType,
) []string

func ComponentTypeToComponentMap added in v0.3.2

func ComponentTypeToComponentMap[T any](
	components *openapi3.Components,
	typ ComponentType,
) (compMap map[string]T)

func ComponentTypeToDef added in v0.3.2

func ComponentTypeToDef(typ ComponentType) string

Types

type ComponentType added in v0.3.2

type ComponentType int
const (
	ComponentTypeSchema ComponentType
	ComponentTypeParameter
	ComponentTypeHeader
	ComponentTypeRequestBody
	ComponentTypeResponse
	ContentTypeSecuritySchema
	ContentTypeExample
	ContentTypeLink
	ContentTypeCallback
)

func ComponentDefToType added in v0.3.2

func ComponentDefToType(def string) (typ ComponentType, ok bool)

func ComponentTypes added in v0.3.2

func ComponentTypes() []ComponentType

type OpenAPISpecFilter

type OpenAPISpecFilter struct {
	// contains filtered or unexported fields
}

OpenAPISpecFilter is the main type that handles filtering of OpenAPI specs.

func NewOpenAPISpecFilter

func NewOpenAPISpecFilter(
	cfg *config.Config,
	logger *zap.Logger,
) *OpenAPISpecFilter

NewOpenAPISpecFilter creates a new OpenAPISpecFilter instance with the provided configuration and logger. It initializes the OpenAPI loader.

func (*OpenAPISpecFilter) Filter

func (oaf *OpenAPISpecFilter) Filter(inputSpecPath, outSpecPath string) error

Filter processes an OpenAPI spec file according to the configured filters and writes the filtered result to the specified output path. It handles loading, filtering, and writing of the spec while maintaining all necessary references and components.

Parameters:

  • inputSpecPath: Path to the input OpenAPI spec file
  • outSpecPath: Path where the filtered spec will be written

Returns an error if any step of the filtering process fails.

type RefsCollector added in v0.3.0

type RefsCollector struct {
	// contains filtered or unexported fields
}

func NewRefsCollector added in v0.3.0

func NewRefsCollector() *RefsCollector

func (*RefsCollector) AddRef added in v0.3.0

func (rc *RefsCollector) AddRef(ref string)

func (*RefsCollector) CollectOperation added in v0.3.0

func (rc *RefsCollector) CollectOperation(op *openapi3.Operation)

func (*RefsCollector) Refs added in v0.3.0

func (rc *RefsCollector) Refs() map[string]struct{}

Jump to

Keyboard shortcuts

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