Skip to content

Commit

Permalink
Fix openapi spec for cozystack apps
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <[email protected]>
  • Loading branch information
kvaps committed Jan 13, 2025
1 parent b08a5d3 commit f65f4c9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,21 @@ func (o *AppsServerOptions) Config() (*apiserver.Config, error) {
defs := swagger.Definitions

// Verify the presence of the base Application/ApplicationList definitions
appDef, exists := defs["com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.Application"]
appDef, exists := defs["com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.Application"]
if !exists {
return swagger, fmt.Errorf("Application definition not found")
}

listDef, exists := defs["com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.ApplicationList"]
listDef, exists := defs["com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.ApplicationList"]
if !exists {
return swagger, fmt.Errorf("ApplicationList definition not found")
}

// Iterate over all registered GVKs (e.g., Bucket, Database, etc.)
for _, gvk := range v1alpha1.RegisteredGVKs {
// This will be something like:
// "com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.Bucket"
resourceName := fmt.Sprintf("com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.%s", gvk.Kind)
// "com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.Bucket"
resourceName := fmt.Sprintf("com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.%s", gvk.Kind)

// 1. Create a copy of the base Application definition for the new resource
newDef, err := DeepCopySchema(&appDef)
Expand All @@ -242,7 +242,7 @@ func (o *AppsServerOptions) Config() (*apiserver.Config, error) {

// 4. Now handle the corresponding List type (e.g., BucketList).
// We'll start by copying the ApplicationList definition.
listResourceName := fmt.Sprintf("com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.%sList", gvk.Kind)
listResourceName := fmt.Sprintf("com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.%sList", gvk.Kind)
newListDef, err := DeepCopySchema(&listDef)
if err != nil {
return nil, fmt.Errorf("failed to deepcopy schema for %sList: %w", gvk.Kind, err)
Expand Down Expand Up @@ -275,8 +275,8 @@ func (o *AppsServerOptions) Config() (*apiserver.Config, error) {
}

// Remove the original Application/ApplicationList from the definitions
delete(defs, "com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.Application")
delete(defs, "com.github.aenix.io.cozystack.pkg.apis.apps.v1alpha1.ApplicationList")
delete(defs, "com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.Application")
delete(defs, "com.github.aenix-io.cozystack.pkg.apis.apps.v1alpha1.ApplicationList")

swagger.Definitions = defs
return swagger, nil
Expand Down

0 comments on commit f65f4c9

Please sign in to comment.