Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tools/cli/internal/apiversion/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func (v *APIVersion) newVersion(version string, date time.Time) {
if IsPreviewStabilityLevel(version) {
v.stabilityVersion = PreviewStabilityLevel
}

if IsUpcomingStabilityLevel(version) {
v.stabilityVersion = UpcomingStabilityLevel
}
}

// WithVersion sets the version on the APIVersion.
Expand Down Expand Up @@ -166,7 +170,7 @@ func (v *APIVersion) StabilityLevel() string {
}

func (v *APIVersion) ExactMatchOnly() bool {
return v.IsPreview()
return v.IsPreview() || v.IsUpcoming()
}

func (v *APIVersion) IsPreview() bool {
Expand All @@ -181,6 +185,7 @@ func (v *APIVersion) IsPublicPreview() bool {
return v.IsPreview() && !v.IsPrivatePreview()
}

func (v *APIVersion) IsUpcoming() bool { return IsUpcomingStabilityLevel(v.stabilityVersion) }
func FindMatchesFromContentType(contentType string) []string {
return contentPattern.FindStringSubmatch(contentType)
}
Expand Down
20 changes: 20 additions & 0 deletions tools/cli/internal/cli/split/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,26 @@ func TestSplitPrivatePreviewRun(t *testing.T) {
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups")
}

func TestSplitUpcomingRun(t *testing.T) {
t.Parallel()
fs := afero.NewMemMapFs()
opts := &Opts{
basePath: "../../../test/data/openapi_with_upcoming.json",
outputPath: "foas.yaml",
fs: fs,
env: "dev",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the-absolute-super-nit: set format to yaml so that you only generate a yaml as "all" is the default and we'll generate an unused file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry i approved can be in your next PR

}

require.NoError(t, opts.Run())

info, err := loadRunResultOas(fs, "foas-2025-09-22.upcoming.yaml")
require.NoError(t, err)

// check paths has only one
require.Len(t, info.Spec.Paths.Map(), 1)
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/openapi/info")
}

func TestSplitMultiplePreviewsRun(t *testing.T) {
t.Parallel()
fs := afero.NewMemMapFs()
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/internal/openapi/filter/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/getkin/kin-openapi/openapi3"
)

// ExtensionFilter: is a filter that removes the x-xgen-IPA-exception extension from the OpenAPI spec.
// ExtensionFilter is a filter that removes the x-xgen-IPA-exception extension from the OpenAPI spec.
type ExtensionFilter struct {
oas *openapi3.T
metadata *Metadata
Expand Down
4 changes: 2 additions & 2 deletions tools/cli/internal/openapi/filter/hidden_envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const (
hiddenEnvsExtKey = "envs"
)

// HiddenEnvsFilter: is a filter that removes paths, operations,
// request/response bodies and content types that are hidden for the target environment.
// HiddenEnvsFilter removes paths, operations, request/response bodies and content types
// that are hidden for the target environment.
type HiddenEnvsFilter struct {
oas *openapi3.T
metadata *Metadata
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/internal/openapi/filter/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/mongodb/openapi/tools/cli/internal/apiversion"
)

// InfoVersioningFilter: Filter that modifies the Info object in the OpenAPI spec with the target version.
// InfoVersioningFilter modifies the Info object in the OpenAPI spec with the target version.
type InfoVersioningFilter struct {
oas *openapi3.T
metadata *Metadata
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/internal/openapi/filter/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/getkin/kin-openapi/openapi3"
)

// OperationsFilter: is a filter that removes the x-xgen-owner-team extension from operations.
// OperationsFilter is a filter that removes the x-xgen-owner-team extension from operations.
type OperationsFilter struct {
oas *openapi3.T
}
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/internal/openapi/filter/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/getkin/kin-openapi/openapi3"
)

// TagsFilter: removes tags that are not used in the operations.
// TagsFilter removes tags that are not used in the operations.
type TagsFilter struct {
oas *openapi3.T
}
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/internal/openapi/filter/versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/mongodb/openapi/tools/cli/internal/apiversion"
)

// VersioningFilter: is a filter that modifies the OpenAPI spec by removing operations and responses
// VersioningFilter is a filter that modifies the OpenAPI spec by removing paths, operations and responses
// that are not supported by the target version.
type VersioningFilter struct {
oas *openapi3.T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/mongodb/openapi/tools/cli/internal/apiversion"
)

// VersioningExtensionFilter: is a filter that updates the x-sunset and x-xgen-version extensions to a date string
// 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.
type VersioningExtensionFilter struct {
Expand Down
Loading