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

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git


The following commit(s) were added to refs/heads/master by this push:
     new e65aa88  SCB-1382 fix schema error in delete api (#21)
e65aa88 is described below

commit e65aa88d67fbbf28e6acfd46bdc9f7f53a89fe63
Author: Jon Wang <[email protected]>
AuthorDate: Wed Jul 17 16:19:35 2019 +0800

    SCB-1382 fix schema error in delete api (#21)
    
    * SCB-1382 fix schema error in delete api
    
    * fix ParamType
---
 client/client.go                  | 2 +-
 server/resource/v1/doc_struct.go  | 9 +++++++--
 server/resource/v1/kv_resource.go | 5 +++--
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/client/client.go b/client/client.go
index c80fbee..c1975ff 100644
--- a/client/client.go
+++ b/client/client.go
@@ -148,7 +148,7 @@ func (c *Client) Get(ctx context.Context, key string, opts 
...GetOption) ([]*mod
 
 //Delete remove kv
 func (c *Client) Delete(ctx context.Context, kvID, labelID string) error {
-       url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, APIPathKV, kvID)
+       url := fmt.Sprintf("%s/%s/?kvID=%s", c.opts.Endpoint, APIPathKV, kvID)
        if labelID != "" {
                url = fmt.Sprintf("%s?labelID=%s", url, labelID)
        }
diff --git a/server/resource/v1/doc_struct.go b/server/resource/v1/doc_struct.go
index d39fc7e..5b79d17 100644
--- a/server/resource/v1/doc_struct.go
+++ b/server/resource/v1/doc_struct.go
@@ -44,10 +44,15 @@ var (
                Name:      "key",
                ParamType: goRestful.PathParameterKind,
        }
+       kvIDParameters = &restful.Parameters{
+               DataType:  "string",
+               Name:      "kvID",
+               ParamType: goRestful.QueryParameterKind,
+       }
        labelIDParameters = &restful.Parameters{
                DataType:  "string",
-               Name:      "key",
-               ParamType: goRestful.PathParameterKind,
+               Name:      "labelID",
+               ParamType: goRestful.QueryParameterKind,
        }
 )
 
diff --git a/server/resource/v1/kv_resource.go 
b/server/resource/v1/kv_resource.go
index 443c1a5..d2b3524 100644
--- a/server/resource/v1/kv_resource.go
+++ b/server/resource/v1/kv_resource.go
@@ -169,7 +169,7 @@ func (r *KVResource) Delete(context *restful.Context) {
        if domain == nil {
                WriteErrResponse(context, http.StatusInternalServerError, 
MsgDomainMustNotBeEmpty, common.ContentTypeText)
        }
-       kvID := context.ReadPathParameter("kvID")
+       kvID := context.ReadQueryParameter("kvID")
        if kvID == "" {
                WriteErrResponse(context, http.StatusBadRequest, 
ErrKvIDMustNotEmpty, common.ContentTypeText)
                return
@@ -255,11 +255,12 @@ func (r *KVResource) URLPatterns() []restful.Route {
                        Produces: []string{goRestful.MIME_JSON},
                }, {
                        Method:           http.MethodDelete,
-                       Path:             "/v1/kv/{kvID}",
+                       Path:             "/v1/kv/",
                        ResourceFuncName: "Delete",
                        FuncDesc: "Delete key by kvID and labelID,If the 
labelID is nil, query the collection kv to get it." +
                                "It means if only get kvID, it can also delete 
normally.But if you want better performance, you need to pass the labelID",
                        Parameters: []*restful.Parameters{
+                               kvIDParameters,
                                labelIDParameters,
                        },
                        Returns: []*restful.Returns{

Reply via email to