Skip to content

Commit f3c866f

Browse files
fixes
1 parent e708adb commit f3c866f

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

tools/cli/internal/openapi/filter/filter.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func DefaultFilters(oas *openapi3.T, metadata *Metadata) []Filter {
7878
&HiddenEnvsFilter{oas: oas, metadata: metadata},
7979
&TagsFilter{oas: oas},
8080
&OperationsFilter{oas: oas},
81+
&SchemasFilter{oas: oas},
8182
}
8283
}
8384

@@ -91,13 +92,6 @@ func FiltersWithoutVersioning(oas *openapi3.T, metadata *Metadata) []Filter {
9192
}
9293
}
9394

94-
func FiltersToRemoveUnusedElements(oas *openapi3.T) []Filter {
95-
return []Filter{
96-
&TagsFilter{oas: oas},
97-
&SchemasFilter{oas: oas},
98-
}
99-
}
100-
10195
// FiltersToGetVersions returns a list of filters to apply to the OpenAPI document to get the versions.
10296
func FiltersToGetVersions(oas *openapi3.T, metadata *Metadata) []Filter {
10397
return []Filter{

tools/cli/internal/openapi/filter/schemas.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ package filter
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
"github.com/getkin/kin-openapi/openapi3"
2120
"strings"
21+
22+
"github.com/getkin/kin-openapi/openapi3"
2223
)
2324

24-
// SchemasFilter removes tags that are not used in the operations.
25+
// SchemasFilter removes components that are not used in the operations.
2526
type SchemasFilter struct {
2627
oas *openapi3.T
2728
}
2829

30+
func (f *SchemasFilter) ValidateMetadata() error {
31+
//TODO implement me
32+
panic("implement me")
33+
}
34+
2935
func (f *SchemasFilter) Apply() error {
3036
if f.oas.Paths == nil {
3137
return nil

tools/cli/internal/openapi/openapi.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package openapi
1616

1717
//go:generate mockgen -destination=../openapi/mock_openapi.go -package=openapi github.com/mongodb/openapi/tools/cli/internal/openapi Parser,Merger
1818
import (
19-
"github.com/mongodb/openapi/tools/cli/internal/openapi/filter"
2019
"log"
2120

2221
"github.com/getkin/kin-openapi/openapi3"
@@ -64,12 +63,6 @@ func (o *OasDiff) MergeOpenAPISpecs(paths []string) (*Spec, error) {
6463
}
6564
}
6665

67-
for _, f := range filter.FiltersToRemoveUnusedElements(o.base.Spec) {
68-
if err := f.Apply(); err != nil {
69-
return nil, err
70-
}
71-
}
72-
7366
return newSpec(o.base.Spec), nil
7467
}
7568

tools/cli/internal/openapi/openapi3.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func (o *OpenAPI3) WithExcludedPrivatePaths() *OpenAPI3 {
4747

4848
func (o *OpenAPI3) CreateOpenAPISpecFromPath(path string) (*load.SpecInfo, error) {
4949
o.Loader.IsExternalRefsAllowed = o.IsExternalRefsAllowed
50-
5150
spec, err := load.NewSpecInfo(o.Loader, load.NewSource(path))
5251
if err != nil {
5352
return nil, err
@@ -57,7 +56,6 @@ func (o *OpenAPI3) CreateOpenAPISpecFromPath(path string) (*load.SpecInfo, error
5756
if o.ExcludePrivatePaths {
5857
removePrivatePaths(spec.Spec)
5958
}
60-
6159
return spec, nil
6260
}
6361

0 commit comments

Comments
 (0)