Skip to content

Commit

Permalink
Configure openapi v3 (#35)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Feb 10, 2024
1 parent 4622b7b commit 2473d4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/cmds/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func (o *UIServerOptions) Config() (*apiserver.Config, error) {
// Fixes https://github.com/Azure/AKS/issues/522
clientcmd.Fix(serverConfig.ClientConfig)

ignorePrefixes := []string{
"/swaggerapi",
fmt.Sprintf("/apis/%s/%s", uiv1alpha1.SchemeGroupVersion, uiv1alpha1.ResourceBackupOverviews),
}

serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(
ou.GetDefinitions(
api.GetOpenAPIDefinitions,
Expand All @@ -101,10 +106,17 @@ func (o *UIServerOptions) Config() (*apiserver.Config, error) {
openapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIConfig.Info.Title = "stash-ui-server"
serverConfig.OpenAPIConfig.Info.Version = v.Version.Version
serverConfig.OpenAPIConfig.IgnorePrefixes = []string{
"/swaggerapi",
fmt.Sprintf("/apis/%s/%s", uiv1alpha1.SchemeGroupVersion, uiv1alpha1.ResourceBackupOverviews),
}
serverConfig.OpenAPIConfig.IgnorePrefixes = ignorePrefixes

serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(
ou.GetDefinitions(
api.GetOpenAPIDefinitions,
uiv1alpha1.GetOpenAPIDefinitions,
),
openapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIV3Config.Info.Title = "stash-ui-server"
serverConfig.OpenAPIV3Config.Info.Version = v.Version.Version
serverConfig.OpenAPIV3Config.IgnorePrefixes = ignorePrefixes

if err := o.ExtraOptions.ApplyTo(serverConfig.ClientConfig); err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions pkg/registry/ui/backups/backupoverview.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"

stashapi "stash.appscode.dev/apimachinery/apis/stash"
Expand Down Expand Up @@ -56,6 +57,7 @@ var (
_ rest.Storage = &BackupOverviewStorage{}
_ rest.Getter = &BackupOverviewStorage{}
_ rest.Lister = &BackupOverviewStorage{}
_ rest.SingularNameProvider = &BackupOverviewStorage{}
)

func NewBackupOverviewStorage(kc client.Client, a authorizer.Authorizer) *BackupOverviewStorage {
Expand All @@ -77,6 +79,10 @@ func (r *BackupOverviewStorage) GroupVersionKind(_ schema.GroupVersion) schema.G
return uiapi.SchemeGroupVersion.WithKind(uiapi.ResourceKindBackupOverview)
}

func (r *BackupOverviewStorage) GetSingularName() string {
return strings.ToLower(uiapi.ResourceKindBackupOverview)
}

func (r *BackupOverviewStorage) NamespaceScoped() bool {
return true
}
Expand Down

0 comments on commit 2473d4b

Please sign in to comment.