Skip to content
Closed
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
24 changes: 24 additions & 0 deletions pkg/lib/version/model_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Copy link
Contributor

@camilamacedo86 camilamacedo86 Feb 13, 2026

Choose a reason for hiding this comment

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

We do not add license in this project
So I think we should keep all as it is in the other files.
Could you please remove from all? And keep the current standards

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

The root Apache license should be sufficient. As pointed out, there's no copyright/licensing in individual files.


package version

// OpenAPIModelName returns the OpenAPI model name for this type.
// This ensures the OpenAPI schema uses the canonical name format (com.github...)
// instead of the URL-encoded Go import path format that causes lookup failures.
func (OperatorVersion) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.lib.version.OperatorVersion"
}
29 changes: 29 additions & 0 deletions pkg/lib/version/model_name_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package version

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestOperatorVersionOpenAPIModelName(t *testing.T) {
v := OperatorVersion{}
expected := "com.github.operator-framework.api.pkg.lib.version.OperatorVersion"
require.Equal(t, expected, v.OpenAPIModelName())
}
163 changes: 163 additions & 0 deletions pkg/operators/v1alpha1/model_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
Copyright Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

// OpenAPIModelName methods for all types that are referenced in OpenAPI schemas.
// This ensures the OpenAPI schema uses the canonical name format (com.github...)
// instead of the URL-encoded Go import path format that causes lookup failures.
//
// When Kubernetes serves OpenAPI schemas, "/" in type references gets URL-encoded
// to "~1". If the schema definition keys don't match, lookups fail with errors like:
// unknown model in reference: "github.com~1operator-framework~1api~1..."
//
// Adding OpenAPIModelName() makes openapi-gen use the canonical format for both
// the definition key and references, ensuring they match.

// OpenAPIModelName returns the OpenAPI model name for this type.
func (APIResourceReference) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.APIResourceReference"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (APIServiceDefinitions) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDefinitions"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (APIServiceDescription) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDescription"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ActionDescriptor) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ActionDescriptor"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (AppLink) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.AppLink"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (CRDDescription) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.CRDDescription"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (CleanupSpec) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupSpec"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (CleanupStatus) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupStatus"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ClusterServiceVersionCondition) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionCondition"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ClusterServiceVersionSpec) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionSpec"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ClusterServiceVersionStatus) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionStatus"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (CustomResourceDefinitions) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.CustomResourceDefinitions"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (DependentStatus) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.DependentStatus"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (Icon) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.Icon"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (InstallMode) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.InstallMode"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (Maintainer) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.Maintainer"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (NamedInstallStrategy) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.NamedInstallStrategy"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (RelatedImage) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.RelatedImage"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (RequirementStatus) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.RequirementStatus"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ResourceInstance) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceInstance"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (ResourceList) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceList"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (SpecDescriptor) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.SpecDescriptor"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (StatusDescriptor) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.StatusDescriptor"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (StrategyDeploymentPermissions) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentPermissions"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (StrategyDeploymentSpec) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentSpec"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (StrategyDetailsDeployment) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDetailsDeployment"
}

// OpenAPIModelName returns the OpenAPI model name for this type.
func (WebhookDescription) OpenAPIModelName() string {
return "com.github.operator-framework.api.pkg.operators.v1alpha1.WebhookDescription"
}
173 changes: 173 additions & 0 deletions pkg/operators/v1alpha1/model_name_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
Copyright Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestOpenAPIModelName(t *testing.T) {
tests := []struct {
name string
typeFunc func() string
expected string
}{
{
name: "APIResourceReference",
typeFunc: func() string { return APIResourceReference{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIResourceReference",
},
{
name: "APIServiceDefinitions",
typeFunc: func() string { return APIServiceDefinitions{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDefinitions",
},
{
name: "APIServiceDescription",
typeFunc: func() string { return APIServiceDescription{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.APIServiceDescription",
},
{
name: "ActionDescriptor",
typeFunc: func() string { return ActionDescriptor{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ActionDescriptor",
},
{
name: "AppLink",
typeFunc: func() string { return AppLink{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.AppLink",
},
{
name: "CRDDescription",
typeFunc: func() string { return CRDDescription{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CRDDescription",
},
{
name: "CleanupSpec",
typeFunc: func() string { return CleanupSpec{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupSpec",
},
{
name: "CleanupStatus",
typeFunc: func() string { return CleanupStatus{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CleanupStatus",
},
{
name: "ClusterServiceVersionCondition",
typeFunc: func() string { return ClusterServiceVersionCondition{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionCondition",
},
{
name: "ClusterServiceVersionSpec",
typeFunc: func() string { return ClusterServiceVersionSpec{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionSpec",
},
{
name: "ClusterServiceVersionStatus",
typeFunc: func() string { return ClusterServiceVersionStatus{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ClusterServiceVersionStatus",
},
{
name: "CustomResourceDefinitions",
typeFunc: func() string { return CustomResourceDefinitions{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.CustomResourceDefinitions",
},
{
name: "DependentStatus",
typeFunc: func() string { return DependentStatus{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.DependentStatus",
},
{
name: "Icon",
typeFunc: func() string { return Icon{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.Icon",
},
{
name: "InstallMode",
typeFunc: func() string { return InstallMode{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.InstallMode",
},
{
name: "Maintainer",
typeFunc: func() string { return Maintainer{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.Maintainer",
},
{
name: "NamedInstallStrategy",
typeFunc: func() string { return NamedInstallStrategy{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.NamedInstallStrategy",
},
{
name: "RelatedImage",
typeFunc: func() string { return RelatedImage{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.RelatedImage",
},
{
name: "RequirementStatus",
typeFunc: func() string { return RequirementStatus{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.RequirementStatus",
},
{
name: "ResourceInstance",
typeFunc: func() string { return ResourceInstance{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceInstance",
},
{
name: "ResourceList",
typeFunc: func() string { return ResourceList{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.ResourceList",
},
{
name: "SpecDescriptor",
typeFunc: func() string { return SpecDescriptor{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.SpecDescriptor",
},
{
name: "StatusDescriptor",
typeFunc: func() string { return StatusDescriptor{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StatusDescriptor",
},
{
name: "StrategyDeploymentPermissions",
typeFunc: func() string { return StrategyDeploymentPermissions{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentPermissions",
},
{
name: "StrategyDeploymentSpec",
typeFunc: func() string { return StrategyDeploymentSpec{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDeploymentSpec",
},
{
name: "StrategyDetailsDeployment",
typeFunc: func() string { return StrategyDetailsDeployment{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.StrategyDetailsDeployment",
},
{
name: "WebhookDescription",
typeFunc: func() string { return WebhookDescription{}.OpenAPIModelName() },
expected: "com.github.operator-framework.api.pkg.operators.v1alpha1.WebhookDescription",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expected, tt.typeFunc())
})
}
}
Loading