This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit a01900260ed08c44715f5cbca031a5fd37f38ad4
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Fri Jan 7 09:48:56 2022 +0100

    fix(trait/openapi): proper content cast
---
 e2e/common/traits/openapi_test.go | 28 ++++++++++++++++++++++++++++
 examples/openapi/petstore.groovy  |  2 +-
 pkg/trait/kamelets.go             |  1 +
 pkg/trait/openapi.go              |  4 ++--
 4 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/e2e/common/traits/openapi_test.go 
b/e2e/common/traits/openapi_test.go
index 4b848bf..ccfbfe7 100644
--- a/e2e/common/traits/openapi_test.go
+++ b/e2e/common/traits/openapi_test.go
@@ -34,6 +34,34 @@ import (
        . "github.com/apache/camel-k/e2e/support"
 )
 
+func TestOpenAPI(t *testing.T) {
+       WithNewTestNamespace(t, func(ns string) {
+               Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
+
+               Expect(Kamel(
+                       "run",
+                       "-n", ns,
+                       "--name", "petstore",
+                       "--open-api", "file:files/openapi/petstore-api.yaml",
+                       "files/openapi/petstore.groovy",
+               ).Execute()).To(Succeed())
+
+               Eventually(IntegrationPodPhase(ns, "petstore"), 
TestTimeoutLong).
+                       Should(Equal(corev1.PodRunning))
+               Eventually(Deployment(ns, "petstore"), TestTimeoutLong).
+                       Should(Not(BeNil()))
+
+               Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+                       Should(ContainSubstring("Started listPets 
(rest://get:/v1:/pets)"))
+               Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+                       Should(ContainSubstring("Started createPets 
(rest://post:/v1:/pets)"))
+               Eventually(IntegrationLogs(ns, "petstore"), TestTimeoutMedium).
+                       Should(ContainSubstring("Started showPetById 
(rest://get:/v1:/pets/%7BpetId%7D)"))
+
+               Expect(Kamel("delete", "--all", "-n", 
ns).Execute()).To(Succeed())
+       })
+}
+
 func TestOpenAPIConfigmap(t *testing.T) {
        WithNewTestNamespace(t, func(ns string) {
                Expect(Kamel("install", "-n", ns).Execute()).To(Succeed())
diff --git a/examples/openapi/petstore.groovy b/examples/openapi/petstore.groovy
index 880e22b..e5221e1 100644
--- a/examples/openapi/petstore.groovy
+++ b/examples/openapi/petstore.groovy
@@ -17,7 +17,7 @@
  */
 
 //
-//  kamel run --dev --name petstore --open-api petstore-api.yaml 
petstore.groovy
+//  kamel run --dev --name petstore --open-api file:petstore-api.yaml 
petstore.groovy
 // 
 
 from('direct:listPets')
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 1079dfc..06d2122 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -254,6 +254,7 @@ func (t *kameletsTrait) configureApplicationProperties(e 
*Environment) error {
 func (t *kameletsTrait) addKameletAsSource(e *Environment, kamelet 
*v1alpha1.Kamelet) error {
        sources := make([]v1.SourceSpec, 0)
 
+       // nolint: staticcheck
        if kamelet.Spec.Template != nil || kamelet.Spec.Flow != nil {
                template := kamelet.Spec.Template
                if template == nil {
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index c94f6fa..a4545be 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -145,10 +145,10 @@ func (t *openAPITrait) generateFromConfigmaps(e 
*Environment, tmpDir string) ([]
                        e.Resources.Add(refCm)
                }
                // Iterate over each configmap key which may hold a different 
OpenAPI spec
-               for k, v := range 
cm.UnstructuredContent()["data"].(map[string]string) {
+               for k, v := range 
cm.UnstructuredContent()["data"].(map[string]interface{}) {
                        dataSpecs = append(dataSpecs, v1.DataSpec{
                                Name:        k,
-                               Content:     v,
+                               Content:     v.(string),
                                Compression: false,
                        })
                }

Reply via email to