mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-16 00:59:37 -06:00
Add code generation for swagger and protoweb
Some of the Protobuf Messages were missing fields: - RemoveMemberRequest was missing the `account_id` field for the account/member id - ListMembersRequest was missing the `id` field for the group id Some of the endpoint annotations were not correct regarding declared bodies and the ids listed above.
This commit is contained in:
44
Makefile
44
Makefile
@@ -156,6 +156,44 @@ docs: docs-copy docs-build
|
||||
watch:
|
||||
go run github.com/cespare/reflex -c reflex.conf
|
||||
|
||||
.PHONY: pb
|
||||
pb:
|
||||
protoc -I=$(PROTO_SRC) -I=third_party --go_out=. --micro_out=. $(PROTO_SRC)/*.proto
|
||||
$(GOPATH)/bin/protoc-gen-go:
|
||||
GO111MODULE=off go get -v github.com/golang/protobuf/protoc-gen-go
|
||||
|
||||
$(GOPATH)/bin/protoc-gen-micro:
|
||||
GO111MODULE=on go get -v github.com/micro/protoc-gen-micro/v2
|
||||
|
||||
$(GOPATH)/bin/protoc-gen-microweb:
|
||||
GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb
|
||||
|
||||
$(GOPATH)/bin/protoc-gen-swagger:
|
||||
GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
||||
|
||||
$(PROTO_SRC)/accounts.pb.go: $(PROTO_SRC)/accounts.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=$(PROTO_SRC)/ \
|
||||
--go_out=. accounts.proto
|
||||
|
||||
$(PROTO_SRC)/accounts.pb.micro.go: $(PROTO_SRC)/accounts.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=$(PROTO_SRC)/ \
|
||||
--micro_out=. accounts.proto
|
||||
|
||||
$(PROTO_SRC)/accounts.pb.web.go: $(PROTO_SRC)/accounts.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=$(PROTO_SRC)/ \
|
||||
--microweb_out=. accounts.proto
|
||||
|
||||
$(PROTO_SRC)/accounts.swagger.json: $(PROTO_SRC)/accounts.proto
|
||||
# the other commands above respect the declared package in the .proto file for placement of the resulting file.
|
||||
# `swagger_out` doesn't, so we have to specify the output path as `$(PROTO_SRC)` instead of `.`
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=$(PROTO_SRC)/ \
|
||||
--swagger_out=$(PROTO_SRC) accounts.proto
|
||||
|
||||
.PHONY: protobuf
|
||||
protobuf: $(GOPATH)/bin/protoc-gen-go $(GOPATH)/bin/protoc-gen-micro $(GOPATH)/bin/protoc-gen-microweb $(GOPATH)/bin/protoc-gen-swagger \
|
||||
$(PROTO_SRC)/accounts.pb.go $(PROTO_SRC)/accounts.pb.micro.go $(PROTO_SRC)/accounts.pb.web.go $(PROTO_SRC)/accounts.swagger.json
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/go-micro/v2/api"
|
||||
client "github.com/micro/go-micro/v2/client"
|
||||
server "github.com/micro/go-micro/v2/server"
|
||||
)
|
||||
@@ -31,10 +32,51 @@ var _ = math.Inf
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for AccountsService service
|
||||
|
||||
func NewAccountsServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
&api.Endpoint{
|
||||
Name: "AccountsService.ListAccounts",
|
||||
Path: []string{"/v0/accounts"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "AccountsService.GetAccount",
|
||||
Path: []string{"/v0/accounts/{id=*}"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "AccountsService.CreateAccount",
|
||||
Path: []string{"/v0/accounts"},
|
||||
Method: []string{"POST"},
|
||||
Body: "account",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "AccountsService.UpdateAccount",
|
||||
Path: []string{"/v0/accounts/{account.id=*}"},
|
||||
Method: []string{"PATCH"},
|
||||
Body: "account",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "AccountsService.DeleteAccount",
|
||||
Path: []string{"/v0/accounts/{id=*}"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for AccountsService service
|
||||
|
||||
type AccountsService interface {
|
||||
@@ -139,6 +181,39 @@ func RegisterAccountsServiceHandler(s server.Server, hdlr AccountsServiceHandler
|
||||
accountsService
|
||||
}
|
||||
h := &accountsServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "AccountsService.ListAccounts",
|
||||
Path: []string{"/v0/accounts"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "AccountsService.GetAccount",
|
||||
Path: []string{"/v0/accounts/{id=*}"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "AccountsService.CreateAccount",
|
||||
Path: []string{"/v0/accounts"},
|
||||
Method: []string{"POST"},
|
||||
Body: "account",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "AccountsService.UpdateAccount",
|
||||
Path: []string{"/v0/accounts/{account.id=*}"},
|
||||
Method: []string{"PATCH"},
|
||||
Body: "account",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "AccountsService.DeleteAccount",
|
||||
Path: []string{"/v0/accounts/{id=*}"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&AccountsService{h}, opts...))
|
||||
}
|
||||
|
||||
@@ -166,6 +241,66 @@ func (h *accountsServiceHandler) DeleteAccount(ctx context.Context, in *DeleteAc
|
||||
return h.AccountsServiceHandler.DeleteAccount(ctx, in, out)
|
||||
}
|
||||
|
||||
// Api Endpoints for GroupsService service
|
||||
|
||||
func NewGroupsServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.ListGroups",
|
||||
Path: []string{"/v0/groups"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.GetGroup",
|
||||
Path: []string{"/v0/groups/{id=*}"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.CreateGroup",
|
||||
Path: []string{"/v0/groups"},
|
||||
Method: []string{"POST"},
|
||||
Body: "group",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.UpdateGroup",
|
||||
Path: []string{"/v0/groups/{group.id=*}"},
|
||||
Method: []string{"PATCH"},
|
||||
Body: "group",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.DeleteGroup",
|
||||
Path: []string{"/v0/groups/{id=*}"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.AddMember",
|
||||
Path: []string{"/v0/groups/{id=*}/members/$ref"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.RemoveMember",
|
||||
Path: []string{"/v0/groups/{id=*}/members/{account_id}/$ref"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "GroupsService.ListMembers",
|
||||
Path: []string{"/v0/groups/{id=*}/members/$ref"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for GroupsService service
|
||||
|
||||
type GroupsService interface {
|
||||
@@ -315,6 +450,59 @@ func RegisterGroupsServiceHandler(s server.Server, hdlr GroupsServiceHandler, op
|
||||
groupsService
|
||||
}
|
||||
h := &groupsServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.ListGroups",
|
||||
Path: []string{"/v0/groups"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.GetGroup",
|
||||
Path: []string{"/v0/groups/{id=*}"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.CreateGroup",
|
||||
Path: []string{"/v0/groups"},
|
||||
Method: []string{"POST"},
|
||||
Body: "group",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.UpdateGroup",
|
||||
Path: []string{"/v0/groups/{group.id=*}"},
|
||||
Method: []string{"PATCH"},
|
||||
Body: "group",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.DeleteGroup",
|
||||
Path: []string{"/v0/groups/{id=*}"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.AddMember",
|
||||
Path: []string{"/v0/groups/{id=*}/members/$ref"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.RemoveMember",
|
||||
Path: []string{"/v0/groups/{id=*}/members/{account_id}/$ref"},
|
||||
Method: []string{"DELETE"},
|
||||
Body: "",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "GroupsService.ListMembers",
|
||||
Path: []string{"/v0/groups/{id=*}/members/$ref"},
|
||||
Method: []string{"GET"},
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&GroupsService{h}, opts...))
|
||||
}
|
||||
|
||||
|
||||
1129
pkg/proto/v0/accounts.pb.web.go
Normal file
1129
pkg/proto/v0/accounts.pb.web.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,6 @@ service AccountsService {
|
||||
rpc GetAccount(GetAccountRequest) returns (Account) {
|
||||
option (google.api.http) = {
|
||||
get: "/v0/accounts/{id=*}"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
// Creates an account
|
||||
@@ -68,7 +67,6 @@ service GroupsService {
|
||||
rpc GetGroup(GetGroupRequest) returns (Group) {
|
||||
option (google.api.http) = {
|
||||
get: "/v0/groups/{id=*}"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
// Creates a group
|
||||
@@ -115,8 +113,7 @@ service GroupsService {
|
||||
rpc RemoveMember(RemoveMemberRequest) returns (Group) {
|
||||
// All request parameters go into body.
|
||||
option (google.api.http) = {
|
||||
delete: "/v0/groups/{id=*}/members/{account.id}/$ref"
|
||||
body: "*"
|
||||
delete: "/v0/groups/{id=*}/members/{account_id}/$ref"
|
||||
};
|
||||
}
|
||||
// group:listmembers https://docs.microsoft.com/en-us/graph/api/group-list-members?view=graph-rest-1.0
|
||||
@@ -476,9 +473,11 @@ message AddMemberRequest {
|
||||
}
|
||||
|
||||
message RemoveMemberRequest {
|
||||
// The account id to remove
|
||||
// TODO id in the body indt in the url? not necessary ... use empty?
|
||||
// The group id
|
||||
string id = 1;
|
||||
|
||||
// The account id to remove
|
||||
string account_id = 2;
|
||||
}
|
||||
|
||||
message ListMembersRequest {
|
||||
@@ -511,6 +510,9 @@ message ListMembersRequest {
|
||||
// * Query `display_name=\\"Test String\\"` returns groups with
|
||||
// display names that include both "Test" and "String"
|
||||
string query = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// The group id
|
||||
string id = 5;
|
||||
}
|
||||
|
||||
message ListMembersResponse {
|
||||
@@ -638,4 +640,4 @@ message OnPremisesProvisioningError {
|
||||
string property_causing_error = 3;
|
||||
// Value of the property causing the error.
|
||||
string value = 4;
|
||||
}
|
||||
}
|
||||
|
||||
953
pkg/proto/v0/accounts.swagger.json
Normal file
953
pkg/proto/v0/accounts.swagger.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user