filter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

README

List of filters applied to the OpenAPI specification

These examples are automatically generated from filters docs.

OpenAPI Filters

Why filtering OpenAPI?

The Atlas Admin API OpenAPI specifications are used not only to document REST endpoints, but also to capture extra functionality such as Versioning information, team ownership, and more. This extra information is used to then correctly generate the OpenAPI respective to each version of the API.

What is the general filter purpose?

  • Filtering per environment, so that only the endpoints that are available in that environment are shown.
  • Filtering per version, so that only the endpoints that are available in that version are shown.

What filters are available?

List of filters

ExtensionFilter: is a filter that removes the x-xgen-IPA-exception extension from the OpenAPI spec (unless keepIPAExceptions is set in metadata). HiddenEnvsFilter: is a filter that removes paths, operations,
InfoVersioningFilter: Filter that modifies the Info object in the OpenAPI spec with the target version.
OperationsFilter: is a filter that removes the x-xgen-owner-team extension from operations.
TagsFilter: removes tags that are not used in the operations.
VersioningExtensionFilter: is a filter that updates the x-sunset and x-xgen-version extensions to a date string
VersioningFilter: is a filter that modifies the OpenAPI spec by removing operations and responses

Documentation

Overview

Package filter is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilters

func ApplyFilters(doc *openapi3.T, metadata *Metadata, filters func(oas *openapi3.T, metadata *Metadata) []Filter) (*openapi3.T, error)

func MergeFilteredSpecs

func MergeFilteredSpecs(specs []*openapi3.T) (*openapi3.T, error)

MergeFilteredSpecs merges multiple filtered OpenAPI specs into a single spec.

Types

type BumpFilter

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

BumpFilter modifies includes the fields "x-state" and "x-beta" to the "preview" and "upcoming" APIs Operations. The "x-state" and "x-beta" fields are bump.sh custom fields to include budges Bump.sh feature: https://docs.bump.sh/help/specification-support/doc-badges/

func (*BumpFilter) Apply

func (f *BumpFilter) Apply() error

func (*BumpFilter) ValidateMetadata

func (f *BumpFilter) ValidateMetadata() error

type CodeSampleFilter

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

CodeSampleFilter modifies includes the fields "x-state" and "x-beta" to the "preview" and "upcoming" APIs Operations. The "x-state" and "x-beta" fields are bump.sh custom fields to include budges Bump.sh feature: https://docs.bump.sh/help/specification-support/doc-code-samples/#example-usage

func (*CodeSampleFilter) Apply

func (f *CodeSampleFilter) Apply() error

func (*CodeSampleFilter) ValidateMetadata

func (f *CodeSampleFilter) ValidateMetadata() error

type ExtensionFilter

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

ExtensionFilter is a filter that removes the x-xgen-IPA-exception extension from the OpenAPI spec. If metadata.keepIPAExceptions is true, the x-xgen-IPA-exception extensions are kept.

func (*ExtensionFilter) Apply

func (f *ExtensionFilter) Apply() error

func (*ExtensionFilter) ValidateMetadata

func (f *ExtensionFilter) ValidateMetadata() error

type Filter

type Filter interface {
	Apply() error
	ValidateMetadata() error
}

func DefaultFilters

func DefaultFilters(oas *openapi3.T, metadata *Metadata) []Filter

func FiltersToCleanupRefs

func FiltersToCleanupRefs(oas *openapi3.T) []Filter

func FiltersToGetVersions

func FiltersToGetVersions(oas *openapi3.T, metadata *Metadata) []Filter

FiltersToGetVersions returns a list of filters to apply to the OpenAPI document to get the versions.

func FiltersWithoutVersioning

func FiltersWithoutVersioning(oas *openapi3.T, metadata *Metadata) []Filter

type HiddenEnvsFilter

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

HiddenEnvsFilter removes paths, operations, request/response bodies and content types that are hidden for the target environment.

func (*HiddenEnvsFilter) Apply

func (f *HiddenEnvsFilter) Apply() error

func (*HiddenEnvsFilter) ValidateMetadata

func (f *HiddenEnvsFilter) ValidateMetadata() error

type InfoVersioningFilter

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

InfoVersioningFilter modifies the Info object in the OpenAPI spec with the target version.

func (*InfoVersioningFilter) Apply

func (f *InfoVersioningFilter) Apply() error

func (*InfoVersioningFilter) ValidateMetadata

func (f *InfoVersioningFilter) ValidateMetadata() error

type Metadata

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

func NewMetadata

func NewMetadata(targetVersion *apiversion.APIVersion, targetEnv string) *Metadata

func NewMetadataWithIPAExceptions

func NewMetadataWithIPAExceptions(targetVersion *apiversion.APIVersion, targetEnv string, keepIPAExceptions bool) *Metadata

type MockFilter

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

MockFilter is a mock of Filter interface.

func NewMockFilter

func NewMockFilter(ctrl *gomock.Controller) *MockFilter

NewMockFilter creates a new mock instance.

func (*MockFilter) Apply

func (m *MockFilter) Apply() error

Apply mocks base method.

func (*MockFilter) EXPECT

func (m *MockFilter) EXPECT() *MockFilterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockFilterMockRecorder

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

MockFilterMockRecorder is the mock recorder for MockFilter.

func (*MockFilterMockRecorder) Apply

func (mr *MockFilterMockRecorder) Apply() *gomock.Call

Apply indicates an expected call of Apply.

type OperationConfig

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

OperationConfig contains the information needed while parsing an operation of the OAS.

type OperationsFilter

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

OperationsFilter is a filter that removes the x-xgen-owner-team extension from operations.

func (*OperationsFilter) Apply

func (f *OperationsFilter) Apply() error

func (*OperationsFilter) ValidateMetadata

func (*OperationsFilter) ValidateMetadata() error

type ParametersFilter

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

func (*ParametersFilter) Apply

func (f *ParametersFilter) Apply() error

func (*ParametersFilter) ValidateMetadata

func (*ParametersFilter) ValidateMetadata() error

type ResponseFilter

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

func (*ResponseFilter) Apply

func (f *ResponseFilter) Apply() error

func (*ResponseFilter) ValidateMetadata

func (*ResponseFilter) ValidateMetadata() error

type SchemasFilter

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

SchemasFilter removes unused #/components/schemas/.

func (*SchemasFilter) Apply

func (f *SchemasFilter) Apply() error

Apply removes all unused schemas from the OpenAPI specification. A schema is considered used if it is referenced directly outside of #/components/schemas or transitively through other used schemas.

func (*SchemasFilter) ValidateMetadata

func (*SchemasFilter) ValidateMetadata() error

type State

type State struct {
	Label string `json:"label"`
	Color string `json:"color"`
}

type SunsetFilter

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

SunsetFilter removes the sunsetToBeDecided from the openapi specification.

func (*SunsetFilter) Apply

func (f *SunsetFilter) Apply() error

func (*SunsetFilter) ValidateMetadata

func (*SunsetFilter) ValidateMetadata() error

type TagsFilter

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

TagsFilter removes tags that are not used in the operations.

func (*TagsFilter) Apply

func (f *TagsFilter) Apply() error

func (*TagsFilter) ValidateMetadata

func (*TagsFilter) ValidateMetadata() error

type VersionConfig

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

VersionConfig contains the information needed during the versioning filtering of the OAS. It contains the parsed operations, the operations that need to be removed and the version under scrutiny.

type VersioningExtensionFilter

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

VersioningExtensionFilter is a filter that updates the x-sunset and x-xgen-version extensions to a date string and deletes the x-sunset extension if the latest matched version is deprecated by hidden versions for the target environment.

func (*VersioningExtensionFilter) Apply

func (f *VersioningExtensionFilter) Apply() error

func (*VersioningExtensionFilter) ValidateMetadata

func (f *VersioningExtensionFilter) ValidateMetadata() error

type VersioningFilter

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

VersioningFilter is a filter that modifies the OpenAPI spec by removing paths, operations and responses that are not supported by the target version.

func (*VersioningFilter) Apply

func (f *VersioningFilter) Apply() error

func (*VersioningFilter) ValidateMetadata

func (f *VersioningFilter) ValidateMetadata() error

Jump to

Keyboard shortcuts

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