This commit is contained in:
2023-08-12 20:55:20 +03:00
parent 816b43dc37
commit a11bb6b95c
13 changed files with 95 additions and 139 deletions

View File

@@ -65,7 +65,8 @@ paths:
in: path
required: true
schema:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
requestBody:
content:
application/json:
@@ -139,7 +140,8 @@ components:
type: object
properties:
idPackage:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
text:
type: string
AddCommentRsp:
@@ -152,9 +154,9 @@ components:
type: object
properties:
name:
$ref: '#/components/schemas/StringValue'
type: string
url:
$ref: '#/components/schemas/StringValue'
type: string
modules:
type: array
items:
@@ -162,7 +164,9 @@ components:
format: uint64
AddPackageRsp:
type: object
properties: {}
properties:
status:
type: string
Error:
type: object
properties:
@@ -233,30 +237,16 @@ components:
items:
type: integer
format: uint64
StringValue:
type: object
properties:
value:
type: string
description: The string value.
description: Wrapper message for `string`. The JSON representation for `StringValue` is JSON string.
UInt64Value:
type: object
properties:
value:
type: integer
description: The uint64 value.
format: uint64
description: Wrapper message for `uint64`. The JSON representation for `UInt64Value` is JSON string.
UpdatePackageReq:
type: object
properties:
id:
$ref: '#/components/schemas/UInt64Value'
type: integer
format: uint64
name:
$ref: '#/components/schemas/StringValue'
type: string
url:
$ref: '#/components/schemas/StringValue'
type: string
modules:
type: array
items:

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// versions:
// - protoc-gen-go-micro v3.10.3
// - protoc-gen-go-micro v4.0.2
// - protoc v4.23.4
// source: pkgdash.proto
@@ -8,53 +8,13 @@ package pkgdashpb
import (
context "context"
v3 "go.unistack.org/micro-server-http/v3"
client "go.unistack.org/micro/v3/client"
client "go.unistack.org/micro/v4/client"
emptypb "google.golang.org/protobuf/types/known/emptypb"
)
var (
PkgdashServiceName = "PkgdashService"
)
var (
PkgdashServiceServerEndpoints = []v3.EndpointMetadata{
{
Name: "PkgdashService.ListPackage",
Path: "/v1/packages",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "PkgdashService.UpdatePackage",
Path: "/v1/package/{id}",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddComment",
Path: "/v1/package/{pkg}/comment",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddPackage",
Path: "/v1/package",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.GetModule",
Path: "/v1/module",
Method: "GET",
Body: "",
Stream: false,
},
}
)
type PkgdashServiceClient interface {
ListPackage(ctx context.Context, req *emptypb.Empty, opts ...client.CallOption) (*ListPackageRsp, error)

View File

@@ -1,19 +1,59 @@
// Code generated by protoc-gen-go-micro. DO NOT EDIT.
// protoc-gen-go-micro version: v3.10.3
// protoc-gen-go-micro version: v4.0.2
// source: pkgdash.proto
package pkgdashpb
import (
context "context"
v3 "go.unistack.org/micro-client-http/v3"
v31 "go.unistack.org/micro-server-http/v3"
client "go.unistack.org/micro/v3/client"
server "go.unistack.org/micro/v3/server"
v41 "go.unistack.org/micro-client-http/v4"
v4 "go.unistack.org/micro-server-http/v4"
client "go.unistack.org/micro/v4/client"
server "go.unistack.org/micro/v4/server"
emptypb "google.golang.org/protobuf/types/known/emptypb"
http "net/http"
)
var (
PkgdashServiceServerEndpoints = []v4.EndpointMetadata{
{
Name: "PkgdashService.ListPackage",
Path: "/v1/packages",
Method: "GET",
Body: "",
Stream: false,
},
{
Name: "PkgdashService.UpdatePackage",
Path: "/v1/package/{id}",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddComment",
Path: "/v1/package/{pkg}/comment",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.AddPackage",
Path: "/v1/package",
Method: "POST",
Body: "*",
Stream: false,
},
{
Name: "PkgdashService.GetModule",
Path: "/v1/module",
Method: "GET",
Body: "",
Stream: false,
},
}
)
type pkgdashServiceClient struct {
c client.Client
name string
@@ -27,11 +67,11 @@ func (c *pkgdashServiceClient) ListPackage(ctx context.Context, req *emptypb.Emp
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodGet),
v3.Path("/v1/packages"),
v41.Method(http.MethodGet),
v41.Path("/v1/packages"),
)
rsp := &ListPackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.ListPackage", req), rsp, opts...)
@@ -45,12 +85,12 @@ func (c *pkgdashServiceClient) UpdatePackage(ctx context.Context, req *UpdatePac
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package/{id}"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package/{id}"),
v41.Body("*"),
)
rsp := &UpdatePackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.UpdatePackage", req), rsp, opts...)
@@ -64,12 +104,12 @@ func (c *pkgdashServiceClient) AddComment(ctx context.Context, req *AddCommentRe
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package/{pkg}/comment"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package/{pkg}/comment"),
v41.Body("*"),
)
rsp := &AddCommentRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddComment", req), rsp, opts...)
@@ -83,12 +123,12 @@ func (c *pkgdashServiceClient) AddPackage(ctx context.Context, req *AddPackageRe
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodPost),
v3.Path("/v1/package"),
v3.Body("*"),
v41.Method(http.MethodPost),
v41.Path("/v1/package"),
v41.Body("*"),
)
rsp := &AddPackageRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.AddPackage", req), rsp, opts...)
@@ -102,11 +142,11 @@ func (c *pkgdashServiceClient) GetModule(ctx context.Context, req *GetModuleReq,
errmap := make(map[string]interface{}, 1)
errmap["default"] = &ErrorRsp{}
opts = append(opts,
v3.ErrorMap(errmap),
v41.ErrorMap(errmap),
)
opts = append(opts,
v3.Method(http.MethodGet),
v3.Path("/v1/module"),
v41.Method(http.MethodGet),
v41.Path("/v1/module"),
)
rsp := &GetModuleRsp{}
err := c.c.Call(ctx, c.c.NewRequest(c.name, "PkgdashService.GetModule", req), rsp, opts...)
@@ -153,6 +193,6 @@ func RegisterPkgdashServiceServer(s server.Server, sh PkgdashServiceServer, opts
}
h := &pkgdashServiceServer{sh}
var nopts []server.HandlerOption
nopts = append(nopts, v31.HandlerEndpoints(PkgdashServiceServerEndpoints))
nopts = append(nopts, v4.HandlerEndpoints(PkgdashServiceServerEndpoints))
return s.Handle(s.NewHandler(&PkgdashService{h}, append(nopts, opts...)...))
}