Implement producer to handle appliation/zip

Fixed implementation for downloading chart by handling producer
for type appliation/zip.

Signed-off-by: subhash kumar singh <subh.singh@samsung.com>
Change-Id: I271a45e6fbbe15867518555f919dd0d3970b7bdf
diff --git a/api/ric-dms-api-2.0.yaml b/api/ric-dms-api-2.0.yaml
index ff55bf9..2243a42 100644
--- a/api/ric-dms-api-2.0.yaml
+++ b/api/ric-dms-api-2.0.yaml
@@ -49,7 +49,6 @@
     get:
       produces:
         - application/zip
-        - text/json
       parameters:
         - in: path
           name: xApp_name
@@ -63,8 +62,7 @@
         '200':
           description: Download helm chart OK
           schema:
-            format: binary
-            type: string
+            type: file
         '500':
           description: Get helm chart values.yaml failed
           schema:
diff --git a/pkg/charts/chart_manager.go b/pkg/charts/chart_manager.go
index 6a3fc8e..858323a 100644
--- a/pkg/charts/chart_manager.go
+++ b/pkg/charts/chart_manager.go
@@ -82,7 +82,7 @@
 		return nil, err
 	}
 
-	return resp.Request.Body, nil
+	return resp.Body, nil
 }
 
 func (c *ChartMgr) GetChartsByName(name string) ([]map[string]interface{}, error) {
diff --git a/pkg/restful/restful.go b/pkg/restful/restful.go
index 9c9e861..9b784a1 100644
--- a/pkg/restful/restful.go
+++ b/pkg/restful/restful.go
@@ -20,6 +20,9 @@
 package restful
 
 import (
+	"fmt"
+	"io"
+	"io/ioutil"
 	"log"
 	"os"
 
@@ -34,6 +37,7 @@
 	"gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/resthooks"
 	"gerrit.o-ran-sc.org/r/ric-plt/ricdms/pkg/ricdms"
 	"github.com/go-openapi/loads"
+	"github.com/go-openapi/runtime"
 	"github.com/go-openapi/runtime/middleware"
 )
 
@@ -93,6 +97,25 @@
 		return resp
 	})
 
+	api.ApplicationZipProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
+		if zp, ok := data.(io.ReadCloser); ok {
+			defer zp.Close()
+			b, err := ioutil.ReadAll(zp)
+
+			if err != nil {
+				ricdms.Logger.Error("error: %v", err)
+				return err
+			}
+			_, err = w.Write(b)
+
+			if err != nil {
+				ricdms.Logger.Error("error: %v", err)
+				return err
+			}
+			return nil
+		}
+		return fmt.Errorf("not support")
+	})
 	r.api = api
 }