From 9c3207f6d302283179b2b87c4d69bb01e2239062 Mon Sep 17 00:00:00 2001
From: Yordan Kinkov <yordan.kinkov@vereign.com>
Date: Tue, 5 Apr 2022 14:16:25 +0300
Subject: [PATCH] #3 add GOA generated DSL code

---
 gen/cache/client.go                    |  4 +-
 gen/cache/service.go                   |  8 +--
 gen/http/cache/client/encode_decode.go |  2 +-
 gen/http/cache/server/encode_decode.go |  2 +-
 gen/http/cli/cache/cli.go              |  8 +--
 gen/http/openapi.json                  |  2 +-
 gen/http/openapi.yaml                  |  8 +--
 gen/http/openapi3.json                 |  2 +-
 gen/http/openapi3.yaml                 | 84 ++------------------------
 9 files changed, 20 insertions(+), 100 deletions(-)

diff --git a/gen/cache/client.go b/gen/cache/client.go
index d4e423c..d076c91 100644
--- a/gen/cache/client.go
+++ b/gen/cache/client.go
@@ -28,13 +28,13 @@ func NewClient(get, set goa.Endpoint) *Client {
 }
 
 // Get calls the "Get" endpoint of the "cache" service.
-func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res []byte, err error) {
+func (c *Client) Get(ctx context.Context, p *CacheGetRequest) (res interface{}, err error) {
 	var ires interface{}
 	ires, err = c.GetEndpoint(ctx, p)
 	if err != nil {
 		return
 	}
-	return ires.([]byte), nil
+	return ires.(interface{}), nil
 }
 
 // Set calls the "Set" endpoint of the "cache" service.
diff --git a/gen/cache/service.go b/gen/cache/service.go
index 55b9528..ec2b3af 100644
--- a/gen/cache/service.go
+++ b/gen/cache/service.go
@@ -13,11 +13,9 @@ import (
 
 // Cache service allows storing and retrieving data from distributed cache.
 type Service interface {
-	// Get value from the cache. The result is a sequence of bytes which the client
-	// must decode.
-	Get(context.Context, *CacheGetRequest) (res []byte, err error)
-	// Set value in the cache. The HTTP request body is stored as value and the key
-	// is assembled from HTTP request headers.
+	// Get JSON value from the cache.
+	Get(context.Context, *CacheGetRequest) (res interface{}, err error)
+	// Set a JSON value in the cache.
 	Set(context.Context, *CacheSetRequest) (err error)
 }
 
diff --git a/gen/http/cache/client/encode_decode.go b/gen/http/cache/client/encode_decode.go
index 248a4a0..be26cb4 100644
--- a/gen/http/cache/client/encode_decode.go
+++ b/gen/http/cache/client/encode_decode.go
@@ -77,7 +77,7 @@ func DecodeGetResponse(decoder func(*http.Response) goahttp.Decoder, restoreBody
 		switch resp.StatusCode {
 		case http.StatusOK:
 			var (
-				body []byte
+				body interface{}
 				err  error
 			)
 			err = decoder(resp).Decode(&body)
diff --git a/gen/http/cache/server/encode_decode.go b/gen/http/cache/server/encode_decode.go
index 583f395..1f443c6 100644
--- a/gen/http/cache/server/encode_decode.go
+++ b/gen/http/cache/server/encode_decode.go
@@ -20,7 +20,7 @@ import (
 // endpoint.
 func EncodeGetResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error {
 	return func(ctx context.Context, w http.ResponseWriter, v interface{}) error {
-		res, _ := v.([]byte)
+		res, _ := v.(interface{})
 		enc := encoder(ctx, w)
 		body := res
 		w.WriteHeader(http.StatusOK)
diff --git a/gen/http/cli/cache/cli.go b/gen/http/cli/cache/cli.go
index b474a20..007ace3 100644
--- a/gen/http/cli/cache/cli.go
+++ b/gen/http/cli/cache/cli.go
@@ -217,8 +217,8 @@ Usage:
     %[1]s [globalflags] cache COMMAND [flags]
 
 COMMAND:
-    get: Get value from the cache. The result is a sequence of bytes which the client must decode.
-    set: Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.
+    get: Get JSON value from the cache.
+    set: Set a JSON value in the cache.
 
 Additional help:
     %[1]s cache COMMAND --help
@@ -227,7 +227,7 @@ Additional help:
 func cacheGetUsage() {
 	fmt.Fprintf(os.Stderr, `%[1]s [flags] cache get -key STRING -namespace STRING -scope STRING
 
-Get value from the cache. The result is a sequence of bytes which the client must decode.
+Get JSON value from the cache.
     -key STRING: 
     -namespace STRING: 
     -scope STRING: 
@@ -240,7 +240,7 @@ Example:
 func cacheSetUsage() {
 	fmt.Fprintf(os.Stderr, `%[1]s [flags] cache set -body JSON -key STRING -namespace STRING -scope STRING
 
-Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.
+Set a JSON value in the cache.
     -body JSON: 
     -key STRING: 
     -namespace STRING: 
diff --git a/gen/http/openapi.json b/gen/http/openapi.json
index e764709..86a6fd8 100644
--- a/gen/http/openapi.json
+++ b/gen/http/openapi.json
@@ -1 +1 @@
-{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"byte"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}}
\ No newline at end of file
+{"swagger":"2.0","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":""},"host":"localhost:8083","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","required":true,"type":"string"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","required":true,"type":"string"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","required":true,"type":"string"},{"name":"any","in":"body","required":true,"schema":{"type":"string","format":"binary"}}],"responses":{"201":{"description":"Created response."}},"schemes":["http"]}}}}
\ No newline at end of file
diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml
index 605edd0..ea46a9b 100644
--- a/gen/http/openapi.yaml
+++ b/gen/http/openapi.yaml
@@ -40,8 +40,7 @@ paths:
       tags:
       - cache
       summary: Get cache
-      description: Get value from the cache. The result is a sequence of bytes which
-        the client must decode.
+      description: Get JSON value from the cache.
       operationId: cache#Get
       parameters:
       - name: x-cache-key
@@ -64,15 +63,14 @@ paths:
           description: OK response.
           schema:
             type: string
-            format: byte
+            format: binary
       schemes:
       - http
     post:
       tags:
       - cache
       summary: Set cache
-      description: Set value in the cache. The HTTP request body is stored as value
-        and the key is assembled from HTTP request headers.
+      description: Set a JSON value in the cache.
       operationId: cache#Set
       parameters:
       - name: x-cache-key
diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json
index 9dcf3fc..0ce517d 100644
--- a/gen/http/openapi3.json
+++ b/gen/http/openapi3.json
@@ -1 +1 @@
-{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get value from the cache. The result is a sequence of bytes which the client must decode.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"UXVpIGl1c3RvIGVuaW0gZXN0IGRvbG9yZXMgZG9sb3JlbSBldC4=","format":"binary"},"example":"UXVpc3F1YW0gYWIgZG9sb3JlcyBkaXN0aW5jdGlvIHF1aXMu"}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set value in the cache. The HTTP request body is stored as value and the key is assembled from HTTP request headers.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"responses":{"201":{"description":"Created response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]}
\ No newline at end of file
+{"openapi":"3.0.3","info":{"title":"Cache Service","description":"The cache service exposes interface for working with Redis.","version":"1.0"},"servers":[{"url":"http://localhost:8083","description":"Cache Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/cache":{"get":{"tags":["cache"],"summary":"Get cache","description":"Get JSON value from the cache.","operationId":"cache#Get","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Qui iusto enim est dolores dolorem et.","format":"binary"},"example":"Quisquam ab dolores distinctio quis."}}}}},"post":{"tags":["cache"],"summary":"Set cache","description":"Set a JSON value in the cache.","operationId":"cache#Set","parameters":[{"name":"x-cache-key","in":"header","description":"Cache entry key","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry key","example":"did:web:example.com"},"example":"did:web:example.com"},{"name":"x-cache-namespace","in":"header","description":"Cache entry namespace","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry namespace","example":"Login"},"example":"Login"},{"name":"x-cache-scope","in":"header","description":"Cache entry scope","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"Cache entry scope","example":"administration"},"example":"administration"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"string","example":"Et illum fugiat ut.","format":"binary"},"example":"Optio aliquam error nam."}}},"responses":{"201":{"description":"Created response."}}}}},"components":{},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"cache","description":"Cache service allows storing and retrieving data from distributed cache."}]}
\ No newline at end of file
diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml
index 33abaf4..b936940 100644
--- a/gen/http/openapi3.yaml
+++ b/gen/http/openapi3.yaml
@@ -30,8 +30,7 @@ paths:
       tags:
       - cache
       summary: Get cache
-      description: Get value from the cache. The result is a sequence of bytes which
-        the client must decode.
+      description: Get JSON value from the cache.
       operationId: cache#Get
       parameters:
       - name: x-cache-key
@@ -71,89 +70,14 @@ paths:
             application/json:
               schema:
                 type: string
-                example:
-                - 81
-                - 117
-                - 105
-                - 32
-                - 105
-                - 117
-                - 115
-                - 116
-                - 111
-                - 32
-                - 101
-                - 110
-                - 105
-                - 109
-                - 32
-                - 101
-                - 115
-                - 116
-                - 32
-                - 100
-                - 111
-                - 108
-                - 111
-                - 114
-                - 101
-                - 115
-                - 32
-                - 100
-                - 111
-                - 108
-                - 111
-                - 114
-                - 101
-                - 109
-                - 32
-                - 101
-                - 116
-                - 46
+                example: Qui iusto enim est dolores dolorem et.
                 format: binary
-              example:
-              - 81
-              - 117
-              - 105
-              - 115
-              - 113
-              - 117
-              - 97
-              - 109
-              - 32
-              - 97
-              - 98
-              - 32
-              - 100
-              - 111
-              - 108
-              - 111
-              - 114
-              - 101
-              - 115
-              - 32
-              - 100
-              - 105
-              - 115
-              - 116
-              - 105
-              - 110
-              - 99
-              - 116
-              - 105
-              - 111
-              - 32
-              - 113
-              - 117
-              - 105
-              - 115
-              - 46
+              example: Quisquam ab dolores distinctio quis.
     post:
       tags:
       - cache
       summary: Set cache
-      description: Set value in the cache. The HTTP request body is stored as value
-        and the key is assembled from HTTP request headers.
+      description: Set a JSON value in the cache.
       operationId: cache#Set
       parameters:
       - name: x-cache-key
-- 
GitLab