diff --git a/gen/cache/service.go b/gen/cache/service.go index e672fc7bc4db00887c9adb5e586ef105348ac07c..55b9528a4566bf6f32033055a48c47b726a1d251 100644 --- a/gen/cache/service.go +++ b/gen/cache/service.go @@ -40,7 +40,7 @@ type CacheGetRequest struct { // CacheSetRequest is the payload type of the cache service Set method. type CacheSetRequest struct { - Data []byte + Data interface{} Key string Namespace string Scope string diff --git a/gen/http/cache/client/cli.go b/gen/http/cache/client/cli.go index 831930f08a936972035d19196555ce387b10215d..6502a89ae3ee866ac1389db01de6fa73d87081c5 100644 --- a/gen/http/cache/client/cli.go +++ b/gen/http/cache/client/cli.go @@ -8,6 +8,9 @@ package client import ( + "encoding/json" + "fmt" + cache "code.vereign.com/gaiax/tsa/cache/gen/cache" ) @@ -35,9 +38,13 @@ func BuildGetPayload(cacheGetKey string, cacheGetNamespace string, cacheGetScope // BuildSetPayload builds the payload for the cache Set endpoint from CLI flags. func BuildSetPayload(cacheSetBody string, cacheSetKey string, cacheSetNamespace string, cacheSetScope string) (*cache.CacheSetRequest, error) { - var body []byte + var err error + var body interface{} { - body = []byte(cacheSetBody) + err = json.Unmarshal([]byte(cacheSetBody), &body) + if err != nil { + return nil, fmt.Errorf("invalid JSON for body, \nerror: %s, \nexample of valid JSON:\n%s", err, "\"Quasi ut.\"") + } } var key string { diff --git a/gen/http/cache/server/encode_decode.go b/gen/http/cache/server/encode_decode.go index 1e2d096e4798d5c66e211c11778fcac21f8bb6ab..583f39525a6fc58d009d96f71dc97cc32cfed493 100644 --- a/gen/http/cache/server/encode_decode.go +++ b/gen/http/cache/server/encode_decode.go @@ -73,7 +73,7 @@ func EncodeSetResponse(encoder func(context.Context, http.ResponseWriter) goahtt func DecodeSetRequest(mux goahttp.Muxer, decoder func(*http.Request) goahttp.Decoder) func(*http.Request) (interface{}, error) { return func(r *http.Request) (interface{}, error) { var ( - body []byte + body interface{} err error ) err = decoder(r).Decode(&body) diff --git a/gen/http/cache/server/types.go b/gen/http/cache/server/types.go index 67496e706748df08a202a8fd492e6db1e86bc912..c9d87f134992134625b260b82a3ceee77e0a0ee6 100644 --- a/gen/http/cache/server/types.go +++ b/gen/http/cache/server/types.go @@ -22,7 +22,7 @@ func NewGetCacheGetRequest(key string, namespace string, scope string) *cache.Ca } // NewSetCacheSetRequest builds a cache service Set endpoint payload. -func NewSetCacheSetRequest(body []byte, key string, namespace string, scope string) *cache.CacheSetRequest { +func NewSetCacheSetRequest(body interface{}, key string, namespace string, scope string) *cache.CacheSetRequest { v := body res := &cache.CacheSetRequest{ Data: v, diff --git a/gen/http/cli/cache/cli.go b/gen/http/cli/cache/cli.go index 94eec334197b11d9bd39f266cf35c9493ab497d3..b474a20b93c87ab24228c1deef824080a9c9bd47 100644 --- a/gen/http/cli/cache/cli.go +++ b/gen/http/cli/cache/cli.go @@ -238,15 +238,15 @@ Example: } func cacheSetUsage() { - fmt.Fprintf(os.Stderr, `%[1]s [flags] cache set -body STRING -key STRING -namespace STRING -scope STRING + 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. - -body STRING: + -body JSON: -key STRING: -namespace STRING: -scope STRING: Example: - %[1]s cache set --body "UXVhc2kgdXQu" --key "Quasi perspiciatis." --namespace "Accusantium animi non alias." --scope "Esse inventore ullam placeat aut." + %[1]s cache set --body "Quasi ut." --key "Quasi perspiciatis." --namespace "Accusantium animi non alias." --scope "Esse inventore ullam placeat aut." `, os.Args[0]) } diff --git a/gen/http/openapi.json b/gen/http/openapi.json index fd67bfa4d24ca8297c3f597e1dcb0b116b3885a9..e76470934646ac8c136c924b2312e80fd3c6d926 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":"bytes","in":"body","required":true,"schema":{"type":"string","format":"byte"}}],"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 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 diff --git a/gen/http/openapi.yaml b/gen/http/openapi.yaml index 690205fe03cff658813d035e2c458636847aec88..605edd04c48b59ecb1c56ecbb0f48ef7eecfe543 100644 --- a/gen/http/openapi.yaml +++ b/gen/http/openapi.yaml @@ -90,12 +90,12 @@ paths: description: Cache entry scope required: true type: string - - name: bytes + - name: any in: body required: true schema: type: string - format: byte + format: binary responses: "201": description: Created response. diff --git a/gen/http/openapi3.json b/gen/http/openapi3.json index 764795157afc8335019e957c26d8d35dbc4f7602..9dcf3fc756c4d50589a0a5cfd2ee32228c758381 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":"RXQgaWxsdW0gZnVnaWF0IHV0Lg==","format":"binary"},"example":"T3B0aW8gYWxpcXVhbSBlcnJvciBuYW0u"}}},"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 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 diff --git a/gen/http/openapi3.yaml b/gen/http/openapi3.yaml index 22a3272368b850853ab7c45d52c28fd3ab8b5771..33abaf4328a28695858c03b43b531b7006994e67 100644 --- a/gen/http/openapi3.yaml +++ b/gen/http/openapi3.yaml @@ -192,52 +192,9 @@ paths: application/json: schema: type: string - example: - - 69 - - 116 - - 32 - - 105 - - 108 - - 108 - - 117 - - 109 - - 32 - - 102 - - 117 - - 103 - - 105 - - 97 - - 116 - - 32 - - 117 - - 116 - - 46 + example: Et illum fugiat ut. format: binary - example: - - 79 - - 112 - - 116 - - 105 - - 111 - - 32 - - 97 - - 108 - - 105 - - 113 - - 117 - - 97 - - 109 - - 32 - - 101 - - 114 - - 114 - - 111 - - 114 - - 32 - - 110 - - 97 - - 109 - - 46 + example: Optio aliquam error nam. responses: "201": description: Created response.