From 18aeeb06e20e2e604978c0883ee405e48d07f9da Mon Sep 17 00:00:00 2001 From: tosaken1116 Date: Sat, 6 Apr 2024 16:35:25 +0900 Subject: [PATCH] refactor: change schema architecture --- openapi/api_definition.swagger.yaml | 280 +++++------------- .../auth/discord-callback/callback.proto | 26 -- .../auth/discord-callback/rpc/callback.proto | 15 - proto/schema/auth/discord/discord.proto | 17 -- .../discord_callback/resource.proto} | 10 +- .../sign_up/resource.proto} | 4 +- .../token/resource.proto} | 2 +- proto/schema/auth/service.proto | 38 +++ proto/schema/auth/sign_up/signup.proto | 19 -- proto/schema/auth/token/token.proto | 17 -- .../tags.proto => model/model.proto} | 2 +- proto/schema/tags/rpc/tags.proto | 22 -- proto/schema/tags/schema/tags/resource.proto | 19 ++ proto/schema/tags/service.proto | 16 + proto/schema/tags/tags.proto | 35 --- proto/schema/users/me/me.proto | 28 -- .../resources/me.proto => model/model.proto} | 5 +- .../rpc/me.proto => schema/me/resource.proto} | 5 +- .../users/schema/user_id/resource.proto | 10 + .../schema/users/schema/users/resource.proto | 20 ++ proto/schema/users/service.proto | 36 +++ proto/schema/users/user_id/user_id.proto | 22 -- proto/schema/users/users.proto | 29 -- 23 files changed, 238 insertions(+), 439 deletions(-) delete mode 100644 proto/schema/auth/discord-callback/callback.proto delete mode 100644 proto/schema/auth/discord-callback/rpc/callback.proto delete mode 100644 proto/schema/auth/discord/discord.proto rename proto/schema/auth/{discord-callback/resources/callback.proto => schema/discord_callback/resource.proto} (67%) rename proto/schema/auth/{sign_up/resources/signup.proto => schema/sign_up/resource.proto} (67%) rename proto/schema/auth/{token/rpc/token.proto => schema/token/resource.proto} (85%) create mode 100644 proto/schema/auth/service.proto delete mode 100644 proto/schema/auth/sign_up/signup.proto delete mode 100644 proto/schema/auth/token/token.proto rename proto/schema/tags/{resources/tags.proto => model/model.proto} (90%) delete mode 100644 proto/schema/tags/rpc/tags.proto create mode 100644 proto/schema/tags/schema/tags/resource.proto create mode 100644 proto/schema/tags/service.proto delete mode 100644 proto/schema/tags/tags.proto delete mode 100644 proto/schema/users/me/me.proto rename proto/schema/users/{me/resources/me.proto => model/model.proto} (94%) rename proto/schema/users/{me/rpc/me.proto => schema/me/resource.proto} (89%) create mode 100644 proto/schema/users/schema/user_id/resource.proto create mode 100644 proto/schema/users/schema/users/resource.proto create mode 100644 proto/schema/users/service.proto delete mode 100644 proto/schema/users/user_id/user_id.proto delete mode 100644 proto/schema/users/users.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml index 8199694..11bf002 100644 --- a/openapi/api_definition.swagger.yaml +++ b/openapi/api_definition.swagger.yaml @@ -1,161 +1,90 @@ swagger: "2.0" info: - title: proto/schema/tags/tags.proto + title: proto/schema/auth/schema/token/resource.proto version: version not set tags: + - name: AuthService - name: TagsService - - name: TokenService - - name: DiscordService - - name: SignUpService - - name: DiscordCallbackService - - name: UserIdService - - name: UserService - - name: MeService + - name: UsersService consumes: - application/json produces: - application/json paths: /v1/auth/discord: - post: - operationId: DiscordService_GetDiscord + get: + operationId: AuthService_RedirectDiscord responses: "200": description: A successful response. schema: type: string - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string tags: - - DiscordService + - AuthService /v1/auth/discord/callback: get: - operationId: DiscordCallbackService_GetDiscordCallback + operationId: AuthService_DiscordCallBack responses: "200": description: A successful response. schema: - $ref: '#/definitions/resourcesDiscordToken' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + type: string parameters: - name: code in: query required: false type: string tags: - - DiscordCallbackService + - AuthService /v1/auth/sign_up: post: - operationId: SignUpService_PostSignUp + operationId: AuthService_SignUp responses: "200": description: A successful response. schema: - $ref: '#/definitions/resourcesAccount' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + $ref: '#/definitions/modelUser' parameters: - - name: name - in: query - required: false - type: string - - name: email - in: query - required: false - type: string - - name: password - in: query - required: false - type: string - - name: display_name - in: query - required: false - type: string - - name: avatar_url - in: query - required: false - type: string + - name: body + in: body + required: true + schema: + $ref: '#/definitions/sign_upSignUpRequest' tags: - - SignUpService + - AuthService /v1/auth/token: post: - operationId: TokenService_PostToken + operationId: AuthService_ExchangeToken responses: "200": description: A successful response. schema: - $ref: '#/definitions/rpcPostTokenResponse' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + $ref: '#/definitions/tokenPostTokenResponse' parameters: - - name: refresh_token - in: query - required: false - type: string + - name: body + in: body + required: true + schema: + $ref: '#/definitions/tokenPostTokenRequest' tags: - - TokenService + - AuthService /v1/tags: get: operationId: TagsService_GetTags responses: "200": - description: A successful response. + description: A successful response.(streaming responses) schema: - $ref: '#/definitions/rpcGetTagsResponse' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + type: object + properties: + result: + $ref: '#/definitions/tagsmodelTag' + title: Stream result of tagsmodelTag parameters: - name: limit in: query required: false - type: integer - format: int32 + type: string - name: smallest_tag_id in: query required: false @@ -172,23 +101,12 @@ paths: - TagsService /v1/users: get: - operationId: UserService_GetUsers + operationId: UsersService_GetUsers responses: "200": description: A successful response. schema: $ref: '#/definitions/usersGetUsersResponse' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string parameters: - name: limit description: 'Default value: 30' @@ -205,73 +123,40 @@ paths: required: false type: string tags: - - UserService + - UsersService /v1/users/@me: get: - operationId: MeService_GetMe + operationId: UsersService_GetMe responses: "200": description: A successful response. schema: - $ref: '#/definitions/resourcesAccount' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + $ref: '#/definitions/modelUser' tags: - - MeService + - UsersService put: - operationId: MeService_PutMe + operationId: UsersService_PutMe responses: "200": description: A successful response. schema: - $ref: '#/definitions/resourcesAccount' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + $ref: '#/definitions/modelUser' parameters: - name: body in: body required: true schema: - $ref: '#/definitions/rpcAccountPatcher' + $ref: '#/definitions/mePutMeRequest' tags: - - MeService + - UsersService /v1/users/{user_id}: get: - operationId: UserIdService_GetUser + operationId: UsersService_GetUser responses: "200": description: A successful response. schema: - $ref: '#/definitions/resourcesAccount' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string + $ref: '#/definitions/modelUser' parameters: - name: user_id description: Path parameter representing the user's ID @@ -279,9 +164,25 @@ paths: required: true type: string tags: - - UserIdService + - UsersService definitions: - resourcesAccount: + mePutMeRequest: + type: object + example: + display_name: string + github_id: string + profile: string + twitter_id: string + properties: + display_name: + type: string + profile: + type: string + twitter_id: + type: string + github_id: + type: string + modelUser: type: object example: avatar_url: https://example.com/ @@ -312,44 +213,38 @@ definitions: $ref: '#/definitions/typeDateTime' updated_at: $ref: '#/definitions/typeDateTime' - resourcesDiscordToken: + sign_upSignUpRequest: type: object - example: - access_token: token - expired_at: expire-time - refresh_token: refresh-token properties: - access_token: + name: type: string - refresh_token: + email: type: string - expired_at: + password: + type: string + display_name: + type: string + avatar_url: type: string - rpcAccountPatcher: + tagsmodelTag: type: object example: - display_name: string - github_id: string - profile: string - twitter_id: string + color: '#000000' + id: "1" + name: tag1 properties: - display_name: - type: string - profile: + id: type: string - twitter_id: + name: type: string - github_id: + color: type: string - rpcGetTagsResponse: + tokenPostTokenRequest: type: object properties: - tags: - type: array - items: - type: object - $ref: '#/definitions/tagsresourcesTag' - rpcPostTokenResponse: + refresh_token: + type: string + tokenPostTokenResponse: type: object properties: expired_at: @@ -358,19 +253,6 @@ definitions: type: string access_token: type: string - tagsresourcesTag: - type: object - example: - color: '#000000' - id: "1" - name: tag1 - properties: - id: - type: string - name: - type: string - color: - type: string typeDateTime: type: object properties: @@ -466,4 +348,4 @@ definitions: type: array items: type: object - $ref: '#/definitions/resourcesAccount' + $ref: '#/definitions/modelUser' diff --git a/proto/schema/auth/discord-callback/callback.proto b/proto/schema/auth/discord-callback/callback.proto deleted file mode 100644 index 5d2281e..0000000 --- a/proto/schema/auth/discord-callback/callback.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package proto.schema.auth.discord.callback; - -import "proto/schema/auth/discord-callback/rpc/callback.proto"; -import "proto/schema/auth/discord-callback/resources/callback.proto"; - -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -message ErrorResponse { - int32 status = 1; - string title = 2; - string detail = 3; -} - -service DiscordCallbackService { - rpc GetDiscordCallback( - proto.schema.auth.discord.callback.rpc.DiscordCallbackRequest) - returns (proto.schema.auth.discord.callback.resources.DiscordToken) { - option (google.api.http) = { - get : "/v1/auth/discord/callback" - }; - }; -} diff --git a/proto/schema/auth/discord-callback/rpc/callback.proto b/proto/schema/auth/discord-callback/rpc/callback.proto deleted file mode 100644 index d353ae5..0000000 --- a/proto/schema/auth/discord-callback/rpc/callback.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package proto.schema.auth.discord.callback.rpc; - -import "proto/third_party/grpc/openapiv2/options/annotations.proto"; - -option go_package = "./"; - -message DiscordCallbackRequest { - string code = 1; - - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { - example : "{\"code\": \"some-code\"}" - }; -} \ No newline at end of file diff --git a/proto/schema/auth/discord/discord.proto b/proto/schema/auth/discord/discord.proto deleted file mode 100644 index ce85a88..0000000 --- a/proto/schema/auth/discord/discord.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package proto.schema.auth.discord; - -import "proto/third_party/google/api/annotations.proto"; -import "proto/third_party/google/api/empty.proto"; -import "proto/third_party/google/api/wrappers.proto"; - -option go_package = "./"; - -service DiscordService { - rpc GetDiscord(google.protobuf.Empty) returns (google.protobuf.StringValue) { - option (google.api.http) = { - post : "/v1/auth/discord" - }; - }; -} diff --git a/proto/schema/auth/discord-callback/resources/callback.proto b/proto/schema/auth/schema/discord_callback/resource.proto similarity index 67% rename from proto/schema/auth/discord-callback/resources/callback.proto rename to proto/schema/auth/schema/discord_callback/resource.proto index cfebc3c..77f4ec9 100644 --- a/proto/schema/auth/discord-callback/resources/callback.proto +++ b/proto/schema/auth/schema/discord_callback/resource.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package proto.schema.auth.discord.callback.resources; +package auth.schema.discord_callback; import "proto/third_party/grpc/openapiv2/options/annotations.proto"; option go_package = "./"; @@ -14,4 +14,12 @@ message DiscordToken { example : "{ \"access_token\": \"token\", \"refresh_token\": " "\"refresh-token\", \"expired_at\": \"expire-time\" }" }; +} + +message DiscordCallbackRequest { + string code = 1; + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example : "{\"code\": \"some-code\"}" + }; } \ No newline at end of file diff --git a/proto/schema/auth/sign_up/resources/signup.proto b/proto/schema/auth/schema/sign_up/resource.proto similarity index 67% rename from proto/schema/auth/sign_up/resources/signup.proto rename to proto/schema/auth/schema/sign_up/resource.proto index 1e64106..059d397 100644 --- a/proto/schema/auth/sign_up/resources/signup.proto +++ b/proto/schema/auth/schema/sign_up/resource.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package proto.schema.auth.sign_up.resources; +package auth.schema.sign_up; option go_package = "./"; -message InitialAccountTemplate { +message SignUpRequest { string name = 1; string email = 2; string password = 3; diff --git a/proto/schema/auth/token/rpc/token.proto b/proto/schema/auth/schema/token/resource.proto similarity index 85% rename from proto/schema/auth/token/rpc/token.proto rename to proto/schema/auth/schema/token/resource.proto index e7e7774..7d096e7 100644 --- a/proto/schema/auth/token/rpc/token.proto +++ b/proto/schema/auth/schema/token/resource.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package proto.schema.auth.token.rpc; +package auth.schema.token; option go_package = "./"; diff --git a/proto/schema/auth/service.proto b/proto/schema/auth/service.proto new file mode 100644 index 0000000..6f2c2d3 --- /dev/null +++ b/proto/schema/auth/service.proto @@ -0,0 +1,38 @@ +// proto/schema/users/users.proto +syntax = "proto3"; + +package proto.schema.users; +import "proto/third_party/google/api/annotations.proto"; +import "proto/third_party/google/api/wrappers.proto"; +import "proto/schema/auth/schema/discord_callback/resource.proto"; +import "proto/schema/auth/schema/sign_up/resource.proto"; +import "proto/schema/auth/schema/token/resource.proto"; +import "proto/schema/users/model/model.proto"; +import "google/protobuf/empty.proto"; +option go_package = "./"; + + +service AuthService { + rpc DiscordCallBack(.auth.schema.discord_callback.DiscordCallbackRequest) returns (google.protobuf.StringValue) { + option (google.api.http) = { + get: "/v1/auth/discord/callback" + }; + } + rpc ExchangeToken(.auth.schema.token.PostTokenRequest)returns(.auth.schema.token.PostTokenResponse){ + option (google.api.http) = { + post: "/v1/auth/token" + body: "*" + }; + } + rpc RedirectDiscord(google.protobuf.Empty) returns (google.protobuf.StringValue) { + option (google.api.http) = { + get: "/v1/auth/discord" + }; + } + rpc SignUp(.auth.schema.sign_up.SignUpRequest) returns (proto.schema.users.model.User) { + option (google.api.http) = { + post: "/v1/auth/sign_up" + body: "*" + }; + } +} \ No newline at end of file diff --git a/proto/schema/auth/sign_up/signup.proto b/proto/schema/auth/sign_up/signup.proto deleted file mode 100644 index 02a0e3f..0000000 --- a/proto/schema/auth/sign_up/signup.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; - -package proto.schema.auth.sign_up; - -import "proto/schema/auth/sign_up/resources/signup.proto"; -import "proto/schema/users/me/resources/me.proto"; - -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -service SignUpService { - rpc PostSignUp(proto.schema.auth.sign_up.resources.InitialAccountTemplate) - returns (proto.schema.users.me.resources.Account) { - option (google.api.http) = { - post : "/v1/auth/sign_up" - }; - }; -} \ No newline at end of file diff --git a/proto/schema/auth/token/token.proto b/proto/schema/auth/token/token.proto deleted file mode 100644 index 9248a23..0000000 --- a/proto/schema/auth/token/token.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package proto.token; - -import "proto/schema/auth/token/rpc/token.proto"; -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -service TokenService { - rpc PostToken(proto.schema.auth.token.rpc.PostTokenRequest) - returns (proto.schema.auth.token.rpc.PostTokenResponse) { - option (google.api.http) = { - post : "/v1/auth/token" - }; - }; -} \ No newline at end of file diff --git a/proto/schema/tags/resources/tags.proto b/proto/schema/tags/model/model.proto similarity index 90% rename from proto/schema/tags/resources/tags.proto rename to proto/schema/tags/model/model.proto index 036065e..ab19069 100644 --- a/proto/schema/tags/resources/tags.proto +++ b/proto/schema/tags/model/model.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package proto.schema.tags.resources; +package proto.schema.tags.model; import "proto/third_party/grpc/openapiv2/options/annotations.proto"; option go_package = "./"; diff --git a/proto/schema/tags/rpc/tags.proto b/proto/schema/tags/rpc/tags.proto deleted file mode 100644 index dc7517d..0000000 --- a/proto/schema/tags/rpc/tags.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package proto.schema.tags.rpc; - -import "proto/schema/tags/resources/tags.proto"; -import "proto/third_party/grpc/openapiv2/options/annotations.proto"; - -option go_package = "./"; - -message GetTagsResponse { - repeated proto.schema.tags.resources.Tag tags = 1; -} - -message GetTagsRequest { - int32 limit = 1; - string smallest_tag_id = 2; - string biggest_tag_id = 3; - string w = 4; - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { - example:"{\"limit\": 10, \"smallest_tag_id\": \"\", \"biggest_tag_id\": \"\", \"w\": \"\"}" - }; -} \ No newline at end of file diff --git a/proto/schema/tags/schema/tags/resource.proto b/proto/schema/tags/schema/tags/resource.proto new file mode 100644 index 0000000..1182c65 --- /dev/null +++ b/proto/schema/tags/schema/tags/resource.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package tags.schema.tags; + +import "proto/third_party/grpc/openapiv2/options/annotations.proto"; +import "proto/third_party/google/api/field_behavior.proto"; + +option go_package = "./"; + +message GetTagsRequest { + string limit = 1 [(google.api.field_behavior) = OPTIONAL]; + string smallest_tag_id = 2 [(google.api.field_behavior) = OPTIONAL]; + string biggest_tag_id = 3 [(google.api.field_behavior) = OPTIONAL]; + string w = 4 [(google.api.field_behavior) = OPTIONAL]; + + option(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example: "{\"limit\": 100, \"smallest_tag_id\": \"\", \"biggest_tag_id\": \"\", \"w\": \"\"}" + }; +} \ No newline at end of file diff --git a/proto/schema/tags/service.proto b/proto/schema/tags/service.proto new file mode 100644 index 0000000..46151ef --- /dev/null +++ b/proto/schema/tags/service.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package proto.schema.users; +import "proto/schema/tags/schema/tags/resource.proto"; +import "proto/schema/tags/model/model.proto"; +import "proto/third_party/google/api/annotations.proto"; +option go_package = "./"; + +service TagsService { + rpc GetTags(.tags.schema.tags.GetTagsRequest) + returns (stream proto.schema.tags.model.Tag) { + option (google.api.http) = { + get : "/v1/tags" + }; + }; +} \ No newline at end of file diff --git a/proto/schema/tags/tags.proto b/proto/schema/tags/tags.proto deleted file mode 100644 index d76d49d..0000000 --- a/proto/schema/tags/tags.proto +++ /dev/null @@ -1,35 +0,0 @@ -syntax = "proto3"; - -package proto.schema.tags; - -import "proto/schema/tags/rpc/tags.proto"; -import "proto/third_party/google/api/annotations.proto"; -import "proto/third_party/grpc/openapiv2/options/annotations.proto"; -option go_package = "./"; - -option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { - responses: { - key: "422"; - value: { - description: "Validation Error" - examples: { - key: "application/json" - value: "{\"detail\":[{\"loc\":[\"string\",0],\"msg\":\"string\",\"type\":\"string\"}]}" - } - } - } -}; - -message ErrorResponse { - int32 status = 1; - string title = 2; - string detail = 3; -} -service TagsService { - rpc GetTags(proto.schema.tags.rpc.GetTagsRequest) - returns (proto.schema.tags.rpc.GetTagsResponse) { - option (google.api.http) = { - get : "/v1/tags" - }; - }; -} \ No newline at end of file diff --git a/proto/schema/users/me/me.proto b/proto/schema/users/me/me.proto deleted file mode 100644 index a6e70bc..0000000 --- a/proto/schema/users/me/me.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; - -package proto.schema.users.me; - -import "proto/schema/users/me/resources/me.proto"; -import "proto/schema/users/me/rpc/me.proto"; - -import "proto/third_party/google/api/empty.proto"; -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -service MeService { - rpc GetMe(google.protobuf.Empty) - returns (proto.schema.users.me.resources.Account) { - option (google.api.http) = { - get : "/v1/users/@me" - }; - }; - - rpc PutMe(proto.schema.users.me.rpc.AccountPatcher) - returns (proto.schema.users.me.resources.Account) { - option (google.api.http) = { - put : "/v1/users/@me" - body : "*" - }; - }; -} \ No newline at end of file diff --git a/proto/schema/users/me/resources/me.proto b/proto/schema/users/model/model.proto similarity index 94% rename from proto/schema/users/me/resources/me.proto rename to proto/schema/users/model/model.proto index 13e1e03..e111764 100644 --- a/proto/schema/users/me/resources/me.proto +++ b/proto/schema/users/model/model.proto @@ -1,12 +1,11 @@ syntax = "proto3"; -package proto.schema.users.me.resources; +package proto.schema.users.model; import "proto/third_party/grpc/openapiv2/options/annotations.proto"; import "proto/third_party/google/api/type/datetime.proto"; - option go_package = "./"; -message Account { +message User { string id = 1; string name = 2; string display_name = 3; diff --git a/proto/schema/users/me/rpc/me.proto b/proto/schema/users/schema/me/resource.proto similarity index 89% rename from proto/schema/users/me/rpc/me.proto rename to proto/schema/users/schema/me/resource.proto index cd53ecb..4e398e2 100644 --- a/proto/schema/users/me/rpc/me.proto +++ b/proto/schema/users/schema/me/resource.proto @@ -1,12 +1,13 @@ syntax = "proto3"; -package proto.schema.users.me.rpc; +package users.schema.me; import "proto/third_party/grpc/openapiv2/options/annotations.proto"; option go_package = "./"; -message AccountPatcher { + +message PutMeRequest { string display_name = 1; string profile = 2; string twitter_id = 3; diff --git a/proto/schema/users/schema/user_id/resource.proto b/proto/schema/users/schema/user_id/resource.proto new file mode 100644 index 0000000..65be732 --- /dev/null +++ b/proto/schema/users/schema/user_id/resource.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package users.schema.user_id; + +option go_package = "./"; + +// Request type for getting a user. +message GetUserRequest { + string user_id = 1; // Path parameter representing the user's ID +} \ No newline at end of file diff --git a/proto/schema/users/schema/users/resource.proto b/proto/schema/users/schema/users/resource.proto new file mode 100644 index 0000000..c41bae2 --- /dev/null +++ b/proto/schema/users/schema/users/resource.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package users.schema.users; + +import "proto/schema/users/model/model.proto"; +import "proto/third_party/google/api/wrappers.proto"; + +option go_package = "./"; + +message GetUsersRequest { + // Default value: 30 + google.protobuf.Int32Value limit = 1; + string oldest_user_id = 2; + string newest_user_id = 3; +} + +message GetUsersResponse { + repeated proto.schema.users.model.User users = 1; +} + diff --git a/proto/schema/users/service.proto b/proto/schema/users/service.proto new file mode 100644 index 0000000..0cf6b81 --- /dev/null +++ b/proto/schema/users/service.proto @@ -0,0 +1,36 @@ +// proto/schema/users/users.proto +syntax = "proto3"; + +package proto.schema.users; +import "proto/third_party/google/api/annotations.proto"; +import "proto/schema/users/schema/users/resource.proto"; +import "proto/schema/users/schema/user_id/resource.proto"; +import "proto/schema/users/schema/me/resource.proto"; +import "proto/schema/users/model/model.proto"; +import "google/protobuf/empty.proto"; +option go_package = "./"; + + +service UsersService { + rpc GetMe(google.protobuf.Empty) returns (proto.schema.users.model.User) { + option (google.api.http) = { + get : "/v1/users/@me" + }; + }; + rpc PutMe(.users.schema.me.PutMeRequest) returns (proto.schema.users.model.User) { + option (google.api.http) = { + put : "/v1/users/@me" + body : "*" + }; + }; + rpc GetUsers(.users.schema.users.GetUsersRequest) returns (.users.schema.users.GetUsersResponse) { + option (google.api.http) = { + get : "/v1/users" + }; + }; + rpc GetUser(.users.schema.user_id.GetUserRequest) returns (proto.schema.users.model.User) { + option (google.api.http) = { + get : "/v1/users/{user_id}" + }; + }; +} \ No newline at end of file diff --git a/proto/schema/users/user_id/user_id.proto b/proto/schema/users/user_id/user_id.proto deleted file mode 100644 index 8491669..0000000 --- a/proto/schema/users/user_id/user_id.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package proto.schema.users; - -import "proto/schema/users/me/resources/me.proto"; -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -service UserIdService { - rpc GetUser(GetUserRequest) - returns (proto.schema.users.me.resources.Account) { - option (google.api.http) = { - get : "/v1/users/{user_id}" - }; - }; -} - -// Request type for getting a user. -message GetUserRequest { - string user_id = 1; // Path parameter representing the user's ID -} \ No newline at end of file diff --git a/proto/schema/users/users.proto b/proto/schema/users/users.proto deleted file mode 100644 index 9c5cdc5..0000000 --- a/proto/schema/users/users.proto +++ /dev/null @@ -1,29 +0,0 @@ -// proto/schema/users/users.proto -syntax = "proto3"; - -package proto.schema.users; - -import "proto/schema/users/me/resources/me.proto"; -import "proto/third_party/google/api/wrappers.proto"; -import "proto/third_party/google/api/annotations.proto"; - -option go_package = "./"; - -message GetUsersRequest { - // Default value: 30 - google.protobuf.Int32Value limit = 1; - string oldest_user_id = 2; - string newest_user_id = 3; -} - -message GetUsersResponse { - repeated proto.schema.users.me.resources.Account users = 1; -} - -service UserService { - rpc GetUsers(GetUsersRequest) returns (GetUsersResponse) { - option (google.api.http) = { - get : "/v1/users" - }; - }; -} \ No newline at end of file