Skip to content

Commit

Permalink
Fix openapi schema generator (#571)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Dec 24, 2023
1 parent 4dccc95 commit a2c5c86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openapi/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func RenderOpenAPISpec(cfg Config) (string, error) {
}
serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(cfg.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(cfg.Scheme))
serverConfig.OpenAPIConfig.Info.InfoProps = cfg.Info
serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(cfg.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(cfg.Scheme))
serverConfig.OpenAPIV3Config.Info.InfoProps = cfg.Info

genericServer, err := serverConfig.Complete().New("stash-server", genericapiserver.NewEmptyDelegate()) // completion is done in Complete, no need for a second time
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions openapi/std_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package openapi

import (
"context"
"strings"

metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -35,6 +36,7 @@ var (
_ rest.GroupVersionKindProvider = &StandardStorage{}
_ rest.Scoper = &StandardStorage{}
_ rest.StandardStorage = &StandardStorage{}
_ rest.SingularNameProvider = &StandardStorage{}
)

func NewStandardStorage(cfg ResourceInfo) *StandardStorage {
Expand All @@ -45,6 +47,10 @@ func (r *StandardStorage) GroupVersionKind(containingGV schema.GroupVersion) sch
return r.cfg.gvk
}

func (r *StandardStorage) GetSingularName() string {
return strings.ToLower(r.cfg.gvk.Kind)
}

func (r *StandardStorage) NamespaceScoped() bool {
return r.cfg.namespaceScoped
}
Expand Down

0 comments on commit a2c5c86

Please sign in to comment.