From 428a8d2daa96aa6e44350d7cc0614e3c9809a274 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 07:52:15 +0000 Subject: [PATCH 01/12] feat: implement v1/auth/token --- openapi/api_definition.swagger.yaml | 36 +++++++++++++++++++++++++ proto/schema/auth/token/rpc/token.proto | 13 +++++++++ proto/schema/auth/token/token.proto | 17 ++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 proto/schema/auth/token/rpc/token.proto create mode 100644 proto/schema/auth/token/token.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml index b5a1066..beb99db 100644 --- a/openapi/api_definition.swagger.yaml +++ b/openapi/api_definition.swagger.yaml @@ -4,6 +4,7 @@ info: version: version not set tags: - name: DiscordCallbackService + - name: TokenService - name: TagsService consumes: - application/json @@ -36,6 +37,32 @@ paths: type: string tags: - DiscordCallbackService + /v1/auth/token: + post: + operationId: TokenService_PostToken + 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 + parameters: + - name: refresh_token + in: query + required: false + type: string + tags: + - TokenService /v1/tags: get: operationId: TagsService_GetTags @@ -97,6 +124,15 @@ definitions: items: type: object $ref: '#/definitions/tagsresourcesTag' + rpcPostTokenResponse: + type: object + properties: + expired_at: + type: string + refresh_token: + type: string + access_token: + type: string tagsresourcesTag: type: object example: diff --git a/proto/schema/auth/token/rpc/token.proto b/proto/schema/auth/token/rpc/token.proto new file mode 100644 index 0000000..e7e7774 --- /dev/null +++ b/proto/schema/auth/token/rpc/token.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package proto.schema.auth.token.rpc; + +option go_package = "./"; + +message PostTokenRequest { string refresh_token = 1; } + +message PostTokenResponse { + string expired_at = 1; + string refresh_token = 2; + string access_token = 3; +} \ No newline at end of file diff --git a/proto/schema/auth/token/token.proto b/proto/schema/auth/token/token.proto new file mode 100644 index 0000000..9248a23 --- /dev/null +++ b/proto/schema/auth/token/token.proto @@ -0,0 +1,17 @@ +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 From 8ea79a0ed7cac8a261d45d84705ad99f9b744bfb Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:09:59 +0000 Subject: [PATCH 02/12] feat: implement /api/v1/auth/sign_up --- openapi/api_definition.swagger.yaml | 88 +++++++++++++++++-- .../auth/sign_up/resources/signup.proto | 36 ++++++++ proto/schema/auth/sign_up/signup.proto | 17 ++++ 3 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 proto/schema/auth/sign_up/resources/signup.proto create mode 100644 proto/schema/auth/sign_up/signup.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml index b5a1066..4b29c14 100644 --- a/openapi/api_definition.swagger.yaml +++ b/openapi/api_definition.swagger.yaml @@ -1,9 +1,10 @@ -swagger: "2.0" +swagger: '2.0' info: title: proto/schema/auth/discord/callback/callback.proto version: version not set tags: - name: DiscordCallbackService + - name: SignUpService - name: TagsService consumes: - application/json @@ -14,11 +15,11 @@ paths: get: operationId: DiscordCallbackService_GetDiscordCallback responses: - "200": + '200': description: A successful response. schema: $ref: '#/definitions/resourcesDiscordToken' - "422": + '422': description: Validation Error schema: {} examples: @@ -36,15 +37,57 @@ paths: type: string tags: - DiscordCallbackService + /v1/auth/sign_up: + post: + operationId: SignUpService_PostSignUp + 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 + 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 + tags: + - SignUpService /v1/tags: get: operationId: TagsService_GetTags responses: - "200": + '200': description: A successful response. schema: $ref: '#/definitions/rpcGetTagsResponse' - "422": + '422': description: Validation Error schema: {} examples: @@ -76,6 +119,39 @@ paths: tags: - TagsService definitions: + resourcesAccount: + type: object + example: + avatar_url: https://example.com/ + created_at: '2024-01-11T07:56:02.206Z' + display_name: string + github_id: string + id: string + name: string + profile: string + twitter_id: string + updated_at: '2024-01-11T07:56:02.206Z' + properties: + id: + type: string + name: + type: string + display_name: + type: string + avatar_url: + type: string + profile: + type: string + twitter_id: + type: string + github_id: + type: string + created_at: + type: string + title: google.type.Date ? + updated_at: + type: string + title: google.type.Date ? resourcesDiscordToken: type: object example: @@ -101,7 +177,7 @@ definitions: type: object example: color: '#000000' - id: "1" + id: '1' name: tag1 properties: id: diff --git a/proto/schema/auth/sign_up/resources/signup.proto b/proto/schema/auth/sign_up/resources/signup.proto new file mode 100644 index 0000000..1726796 --- /dev/null +++ b/proto/schema/auth/sign_up/resources/signup.proto @@ -0,0 +1,36 @@ +syntax = "proto3"; + +package proto.schema.auth.sign_up.resources; +import "proto/third_party/grpc/openapiv2/options/annotations.proto"; + +option go_package = "./"; + +message InitialAccountTemplate { + string name = 1; + string email = 2; + string password = 3; + string display_name = 4; + string avatar_url = 5; +} + +message Account { + string id = 1; + string name = 2; + string display_name = 3; + string avatar_url = 4; + string profile = 5; + string twitter_id = 6; + string github_id = 7; + string created_at = 8; // google.type.Date ? + string updated_at = 9; // google.type.Date ? + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example : "{\"id\": \"string\",\"name\": \"string\",\"display_name\": " + "\"string\",\"avatar_url\": " + "\"https://example.com/\",\"profile\": " + "\"string\",\"twitter_id\": \"string\",\"github_id\": " + "\"string\",\"created_at\": " + "\"2024-01-11T07:56:02.206Z\",\"updated_at\": " + "\"2024-01-11T07:56:02.206Z\"}" + }; +} \ No newline at end of file diff --git a/proto/schema/auth/sign_up/signup.proto b/proto/schema/auth/sign_up/signup.proto new file mode 100644 index 0000000..1e17ef2 --- /dev/null +++ b/proto/schema/auth/sign_up/signup.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package proto.schema.auth.sign_up; + +import "proto/schema/auth/sign_up/resources/signup.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.auth.sign_up.resources.Account) { + option (google.api.http) = { + post : "/v1/auth/sign_up" + }; + }; +} \ No newline at end of file From 871323d629c7af401b7195a2cc6bd72d632abbbe Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:14:19 +0000 Subject: [PATCH 03/12] refactor: rename directory for auth/discord/callback --- .../auth/{discord/callback => discord-callback}/callback.proto | 0 .../callback => discord-callback}/resources/callback.proto | 0 .../{discord/callback => discord-callback}/rpc/callback.proto | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename proto/schema/auth/{discord/callback => discord-callback}/callback.proto (100%) rename proto/schema/auth/{discord/callback => discord-callback}/resources/callback.proto (100%) rename proto/schema/auth/{discord/callback => discord-callback}/rpc/callback.proto (100%) diff --git a/proto/schema/auth/discord/callback/callback.proto b/proto/schema/auth/discord-callback/callback.proto similarity index 100% rename from proto/schema/auth/discord/callback/callback.proto rename to proto/schema/auth/discord-callback/callback.proto diff --git a/proto/schema/auth/discord/callback/resources/callback.proto b/proto/schema/auth/discord-callback/resources/callback.proto similarity index 100% rename from proto/schema/auth/discord/callback/resources/callback.proto rename to proto/schema/auth/discord-callback/resources/callback.proto diff --git a/proto/schema/auth/discord/callback/rpc/callback.proto b/proto/schema/auth/discord-callback/rpc/callback.proto similarity index 100% rename from proto/schema/auth/discord/callback/rpc/callback.proto rename to proto/schema/auth/discord-callback/rpc/callback.proto From c917cae194fa69d76c413b28dbaeb710c9d65f86 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:20:01 +0000 Subject: [PATCH 04/12] wip --- proto/schema/auth/discord/discord.proto | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 proto/schema/auth/discord/discord.proto diff --git a/proto/schema/auth/discord/discord.proto b/proto/schema/auth/discord/discord.proto new file mode 100644 index 0000000..5a5de32 --- /dev/null +++ b/proto/schema/auth/discord/discord.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package proto.discord; + +import "proto/Discord/rpc/Discord.proto"; +import "proto/third_party/google/api/annotations.proto"; + +option go_package = "./"; + +service DiscordService { + rpc GetDiscord(google.protobuf.Empty) returns (string) { + option (google.api.http) = { + post : "/v1/auth/discord" + }; + }; +} From d79196d7befe1d5fab49a1f6f293c0dc522ed7a0 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:39:17 +0000 Subject: [PATCH 05/12] feat: implement users/me --- openapi/api_definition.swagger.yaml | 112 ----------------------- proto/schema/users/me/me.proto | 26 ++++++ proto/schema/users/me/resources/me.proto | 32 +++++++ proto/schema/users/me/rpc/me.proto | 23 +++++ 4 files changed, 81 insertions(+), 112 deletions(-) delete mode 100644 openapi/api_definition.swagger.yaml create mode 100644 proto/schema/users/me/me.proto create mode 100644 proto/schema/users/me/resources/me.proto create mode 100644 proto/schema/users/me/rpc/me.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml deleted file mode 100644 index b5a1066..0000000 --- a/openapi/api_definition.swagger.yaml +++ /dev/null @@ -1,112 +0,0 @@ -swagger: "2.0" -info: - title: proto/schema/auth/discord/callback/callback.proto - version: version not set -tags: - - name: DiscordCallbackService - - name: TagsService -consumes: - - application/json -produces: - - application/json -paths: - /v1/auth/discord/callback: - get: - operationId: DiscordCallbackService_GetDiscordCallback - 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 - parameters: - - name: code - in: query - required: false - type: string - tags: - - DiscordCallbackService - /v1/tags: - get: - operationId: TagsService_GetTags - responses: - "200": - description: A successful response. - schema: - $ref: '#/definitions/rpcGetTagsResponse' - "422": - description: Validation Error - schema: {} - examples: - application/json: - detail: - - loc: - - string - - 0 - msg: string - type: string - parameters: - - name: limit - in: query - required: false - type: integer - format: int32 - - name: smallest_tag_id - in: query - required: false - type: string - - name: biggest_tag_id - in: query - required: false - type: string - - name: w - in: query - required: false - type: string - tags: - - TagsService -definitions: - resourcesDiscordToken: - type: object - example: - access_token: token - expired_at: expire-time - refresh_token: refresh-token - properties: - access_token: - type: string - refresh_token: - type: string - expired_at: - type: string - rpcGetTagsResponse: - type: object - properties: - tags: - type: array - items: - type: object - $ref: '#/definitions/tagsresourcesTag' - tagsresourcesTag: - type: object - example: - color: '#000000' - id: "1" - name: tag1 - properties: - id: - type: string - name: - type: string - color: - type: string diff --git a/proto/schema/users/me/me.proto b/proto/schema/users/me/me.proto new file mode 100644 index 0000000..5a3f90e --- /dev/null +++ b/proto/schema/users/me/me.proto @@ -0,0 +1,26 @@ +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/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" + }; + }; +} \ No newline at end of file diff --git a/proto/schema/users/me/resources/me.proto b/proto/schema/users/me/resources/me.proto new file mode 100644 index 0000000..8f8eac6 --- /dev/null +++ b/proto/schema/users/me/resources/me.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package proto.schema.users.me.resources; +import "proto/third_party/grpc/openapiv2/options/annotations.proto"; + +option go_package = "./"; + +message Account { + string id = 1; + string name = 2; + string display_name = 3; + string avatar_url = 4; + string profile = 5; + string twitter_id = 6; + string github_id = 7; + string created_at = 8; // google.type.Date ? + string updated_at = 9; // google.type.Date ? + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example : "{" + "\"id\": \"string\"," + "\"name\": \"string\"," + "\"display_name\": \"string\"," + "\"avatar_url\": \"https://example.com/\"," + "\"profile\": \"string\"," + "\"twitter_id\": \"string\"," + "\"github_id\": \"string\"," + "\"created_at\": \"2024-01-11T07:56:02.206Z\"," + "\"updated_at\": \"2024-01-11T07:56:02.206Z\"" + "}" + }; +} \ No newline at end of file diff --git a/proto/schema/users/me/rpc/me.proto b/proto/schema/users/me/rpc/me.proto new file mode 100644 index 0000000..cd53ecb --- /dev/null +++ b/proto/schema/users/me/rpc/me.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package proto.schema.users.me.rpc; + +import "proto/third_party/grpc/openapiv2/options/annotations.proto"; + +option go_package = "./"; + +message AccountPatcher { + string display_name = 1; + string profile = 2; + string twitter_id = 3; + string github_id = 4; + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example : "{" + "\"display_name\": \"string\"," + "\"profile\": \"string\"," + "\"twitter_id\": \"string\"," + "\"github_id\": \"string\"" + "}" + }; +} \ No newline at end of file From 2239895baa8e06bf7b14552c96b7c530fd2bb004 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:43:47 +0000 Subject: [PATCH 06/12] feat: add empty from google.protobuf --- proto/schema/users/me/me.proto | 1 + proto/third_party/google/api/empty.proto | 51 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 proto/third_party/google/api/empty.proto diff --git a/proto/schema/users/me/me.proto b/proto/schema/users/me/me.proto index 5a3f90e..c5dc864 100644 --- a/proto/schema/users/me/me.proto +++ b/proto/schema/users/me/me.proto @@ -5,6 +5,7 @@ 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 = "./"; diff --git a/proto/third_party/google/api/empty.proto b/proto/third_party/google/api/empty.proto new file mode 100644 index 0000000..2211524 --- /dev/null +++ b/proto/third_party/google/api/empty.proto @@ -0,0 +1,51 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/known/emptypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "EmptyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; + +// A generic empty message that you can re-use to avoid defining duplicated +// empty messages in your APIs. A typical example is to use it as the request +// or the response type of an API method. For instance: +// +// service Foo { +// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +// } +// +message Empty {} \ No newline at end of file From a7025ced6f6f7a8eea2c9746ba9a9cf9aa528306 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:50:53 +0000 Subject: [PATCH 07/12] feat: implement auth/discord --- openapi/api_definition.swagger.yaml | 226 ++++++++++++++++++++ proto/schema/auth/discord/discord.proto | 7 +- proto/third_party/google/api/wrappers.proto | 123 +++++++++++ 3 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 openapi/api_definition.swagger.yaml create mode 100644 proto/third_party/google/api/wrappers.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml new file mode 100644 index 0000000..11c0c07 --- /dev/null +++ b/openapi/api_definition.swagger.yaml @@ -0,0 +1,226 @@ +swagger: "2.0" +info: + title: proto/schema/tags/tags.proto + version: version not set +tags: + - name: TagsService + - name: DiscordService + - name: DiscordCallbackService + - name: MeService +consumes: + - application/json +produces: + - application/json +paths: + /v1/auth/discord: + post: + operationId: DiscordService_GetDiscord + 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 + /v1/auth/discord/callback: + get: + operationId: DiscordCallbackService_GetDiscordCallback + 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 + parameters: + - name: code + in: query + required: false + type: string + tags: + - DiscordCallbackService + /v1/tags: + get: + operationId: TagsService_GetTags + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/rpcGetTagsResponse' + "422": + description: Validation Error + schema: {} + examples: + application/json: + detail: + - loc: + - string + - 0 + msg: string + type: string + parameters: + - name: limit + in: query + required: false + type: integer + format: int32 + - name: smallest_tag_id + in: query + required: false + type: string + - name: biggest_tag_id + in: query + required: false + type: string + - name: w + in: query + required: false + type: string + tags: + - TagsService + /v1/users/@me: + get: + operationId: MeService_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 + tags: + - MeService + put: + operationId: MeService_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 + parameters: + - name: display_name + in: query + required: false + type: string + - name: profile + in: query + required: false + type: string + - name: twitter_id + in: query + required: false + type: string + - name: github_id + in: query + required: false + type: string + tags: + - MeService +definitions: + resourcesAccount: + type: object + example: + avatar_url: https://example.com/ + created_at: "2024-01-11T07:56:02.206Z" + display_name: string + github_id: string + id: string + name: string + profile: string + twitter_id: string + updated_at: "2024-01-11T07:56:02.206Z" + properties: + id: + type: string + name: + type: string + display_name: + type: string + avatar_url: + type: string + profile: + type: string + twitter_id: + type: string + github_id: + type: string + created_at: + type: string + title: google.type.Date ? + updated_at: + type: string + title: google.type.Date ? + resourcesDiscordToken: + type: object + example: + access_token: token + expired_at: expire-time + refresh_token: refresh-token + properties: + access_token: + type: string + refresh_token: + type: string + expired_at: + type: string + rpcGetTagsResponse: + type: object + properties: + tags: + type: array + items: + type: object + $ref: '#/definitions/tagsresourcesTag' + tagsresourcesTag: + type: object + example: + color: '#000000' + id: "1" + name: tag1 + properties: + id: + type: string + name: + type: string + color: + type: string diff --git a/proto/schema/auth/discord/discord.proto b/proto/schema/auth/discord/discord.proto index 5a5de32..ce85a88 100644 --- a/proto/schema/auth/discord/discord.proto +++ b/proto/schema/auth/discord/discord.proto @@ -1,14 +1,15 @@ syntax = "proto3"; -package proto.discord; +package proto.schema.auth.discord; -import "proto/Discord/rpc/Discord.proto"; 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 (string) { + rpc GetDiscord(google.protobuf.Empty) returns (google.protobuf.StringValue) { option (google.api.http) = { post : "/v1/auth/discord" }; diff --git a/proto/third_party/google/api/wrappers.proto b/proto/third_party/google/api/wrappers.proto new file mode 100644 index 0000000..6c4b5ac --- /dev/null +++ b/proto/third_party/google/api/wrappers.proto @@ -0,0 +1,123 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Wrappers for primitive (non-message) types. These types are useful +// for embedding primitives in the `google.protobuf.Any` type and for places +// where we need to distinguish between the absence of a primitive +// typed field and its default value. +// +// These wrappers have no meaningful use within repeated fields as they lack +// the ability to detect presence on individual elements. +// These wrappers have no meaningful use within a map or a oneof since +// individual entries of a map or fields of a oneof can already detect presence. + +syntax = "proto3"; + +package google.protobuf; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "WrappersProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// Wrapper message for `double`. +// +// The JSON representation for `DoubleValue` is JSON number. +message DoubleValue { + // The double value. + double value = 1; +} + +// Wrapper message for `float`. +// +// The JSON representation for `FloatValue` is JSON number. +message FloatValue { + // The float value. + float value = 1; +} + +// Wrapper message for `int64`. +// +// The JSON representation for `Int64Value` is JSON string. +message Int64Value { + // The int64 value. + int64 value = 1; +} + +// Wrapper message for `uint64`. +// +// The JSON representation for `UInt64Value` is JSON string. +message UInt64Value { + // The uint64 value. + uint64 value = 1; +} + +// Wrapper message for `int32`. +// +// The JSON representation for `Int32Value` is JSON number. +message Int32Value { + // The int32 value. + int32 value = 1; +} + +// Wrapper message for `uint32`. +// +// The JSON representation for `UInt32Value` is JSON number. +message UInt32Value { + // The uint32 value. + uint32 value = 1; +} + +// Wrapper message for `bool`. +// +// The JSON representation for `BoolValue` is JSON `true` and `false`. +message BoolValue { + // The bool value. + bool value = 1; +} + +// Wrapper message for `string`. +// +// The JSON representation for `StringValue` is JSON string. +message StringValue { + // The string value. + string value = 1; +} + +// Wrapper message for `bytes`. +// +// The JSON representation for `BytesValue` is JSON string. +message BytesValue { + // The bytes value. + bytes value = 1; +} \ No newline at end of file From 3395c581adb965480e1323e662961ab593b706c9 Mon Sep 17 00:00:00 2001 From: siloneco Date: Thu, 11 Jan 2024 08:51:04 +0000 Subject: [PATCH 08/12] fix: compile error due to directory renaming --- .../auth/discord-callback/callback.proto | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/proto/schema/auth/discord-callback/callback.proto b/proto/schema/auth/discord-callback/callback.proto index 2f96f24..5d2281e 100644 --- a/proto/schema/auth/discord-callback/callback.proto +++ b/proto/schema/auth/discord-callback/callback.proto @@ -2,25 +2,12 @@ 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/schema/auth/discord-callback/rpc/callback.proto"; +import "proto/schema/auth/discord-callback/resources/callback.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\"}]}" - } -} -} -} -; +option go_package = "./"; message ErrorResponse { int32 status = 1; From 0425429be712ba2e01e4a7a9e10ae72bbedc55ae Mon Sep 17 00:00:00 2001 From: siloneco Date: Fri, 23 Feb 2024 12:25:30 +0000 Subject: [PATCH 09/12] use /users/me Account message --- .../auth/sign_up/resources/signup.proto | 23 ---- proto/schema/auth/sign_up/signup.proto | 4 +- proto/schema/users/me/resources/me.proto | 33 ++++++ .../google/api/type/datetime.proto | 104 ++++++++++++++++++ 4 files changed, 140 insertions(+), 24 deletions(-) create mode 100644 proto/schema/users/me/resources/me.proto create mode 100644 proto/third_party/google/api/type/datetime.proto diff --git a/proto/schema/auth/sign_up/resources/signup.proto b/proto/schema/auth/sign_up/resources/signup.proto index 1726796..1e64106 100644 --- a/proto/schema/auth/sign_up/resources/signup.proto +++ b/proto/schema/auth/sign_up/resources/signup.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package proto.schema.auth.sign_up.resources; -import "proto/third_party/grpc/openapiv2/options/annotations.proto"; option go_package = "./"; @@ -12,25 +11,3 @@ message InitialAccountTemplate { string display_name = 4; string avatar_url = 5; } - -message Account { - string id = 1; - string name = 2; - string display_name = 3; - string avatar_url = 4; - string profile = 5; - string twitter_id = 6; - string github_id = 7; - string created_at = 8; // google.type.Date ? - string updated_at = 9; // google.type.Date ? - - option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { - example : "{\"id\": \"string\",\"name\": \"string\",\"display_name\": " - "\"string\",\"avatar_url\": " - "\"https://example.com/\",\"profile\": " - "\"string\",\"twitter_id\": \"string\",\"github_id\": " - "\"string\",\"created_at\": " - "\"2024-01-11T07:56:02.206Z\",\"updated_at\": " - "\"2024-01-11T07:56:02.206Z\"}" - }; -} \ No newline at end of file diff --git a/proto/schema/auth/sign_up/signup.proto b/proto/schema/auth/sign_up/signup.proto index 1e17ef2..02a0e3f 100644 --- a/proto/schema/auth/sign_up/signup.proto +++ b/proto/schema/auth/sign_up/signup.proto @@ -3,13 +3,15 @@ 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.auth.sign_up.resources.Account) { + returns (proto.schema.users.me.resources.Account) { option (google.api.http) = { post : "/v1/auth/sign_up" }; diff --git a/proto/schema/users/me/resources/me.proto b/proto/schema/users/me/resources/me.proto new file mode 100644 index 0000000..13e1e03 --- /dev/null +++ b/proto/schema/users/me/resources/me.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package proto.schema.users.me.resources; +import "proto/third_party/grpc/openapiv2/options/annotations.proto"; +import "proto/third_party/google/api/type/datetime.proto"; + +option go_package = "./"; + +message Account { + string id = 1; + string name = 2; + string display_name = 3; + string avatar_url = 4; + string profile = 5; + string twitter_id = 6; + string github_id = 7; + google.type.DateTime created_at = 8; + google.type.DateTime updated_at = 9; + + option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { + example : "{" + "\"id\": \"string\"," + "\"name\": \"string\"," + "\"display_name\": \"string\"," + "\"avatar_url\": \"https://example.com/\"," + "\"profile\": \"string\"," + "\"twitter_id\": \"string\"," + "\"github_id\": \"string\"," + "\"created_at\": \"2024-01-11T07:56:02.206Z\"," + "\"updated_at\": \"2024-01-11T07:56:02.206Z\"" + "}" + }; +} diff --git a/proto/third_party/google/api/type/datetime.proto b/proto/third_party/google/api/type/datetime.proto new file mode 100644 index 0000000..86f98c9 --- /dev/null +++ b/proto/third_party/google/api/type/datetime.proto @@ -0,0 +1,104 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +import "google/protobuf/duration.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; +option java_multiple_files = true; +option java_outer_classname = "DateTimeProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents civil time (or occasionally physical time). +// +// This type can represent a civil time in one of a few possible ways: +// +// * When utc_offset is set and time_zone is unset: a civil time on a calendar +// day with a particular offset from UTC. +// * When time_zone is set and utc_offset is unset: a civil time on a calendar +// day in a particular time zone. +// * When neither time_zone nor utc_offset is set: a civil time on a calendar +// day in local time. +// +// The date is relative to the Proleptic Gregorian Calendar. +// +// If year is 0, the DateTime is considered not to have a specific year. month +// and day must have valid, non-zero values. +// +// This type may also be used to represent a physical time if all the date and +// time fields are set and either case of the `time_offset` oneof is set. +// Consider using `Timestamp` message for physical time instead. If your use +// case also would like to store the user's timezone, that can be done in +// another field. +// +// This type is more flexible than some applications may want. Make sure to +// document and validate your application's limitations. +message DateTime { + // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + // datetime without a year. + int32 year = 1; + + // Required. Month of year. Must be from 1 to 12. + int32 month = 2; + + // Required. Day of month. Must be from 1 to 31 and valid for the year and + // month. + int32 day = 3; + + // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + // may choose to allow the value "24:00:00" for scenarios like business + // closing time. + int32 hours = 4; + + // Required. Minutes of hour of day. Must be from 0 to 59. + int32 minutes = 5; + + // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + // API may allow the value 60 if it allows leap-seconds. + int32 seconds = 6; + + // Required. Fractions of seconds in nanoseconds. Must be from 0 to + // 999,999,999. + int32 nanos = 7; + + // Optional. Specifies either the UTC offset or the time zone of the DateTime. + // Choose carefully between them, considering that time zone data may change + // in the future (for example, a country modifies their DST start/end dates, + // and future DateTimes in the affected range had already been stored). + // If omitted, the DateTime is considered to be in local time. + oneof time_offset { + // UTC offset. Must be whole seconds, between -18 hours and +18 hours. + // For example, a UTC offset of -4:00 would be represented as + // { seconds: -14400 }. + google.protobuf.Duration utc_offset = 8; + + // Time zone. + TimeZone time_zone = 9; + } +} + +// Represents a time zone from the +// [IANA Time Zone Database](https://www.iana.org/time-zones). +message TimeZone { + // IANA Time Zone Database time zone, e.g. "America/New_York". + string id = 1; + + // Optional. IANA Time Zone Database version number, e.g. "2019a". + string version = 2; +} \ No newline at end of file From bdb2c043016812e13159331403c2a4443093184d Mon Sep 17 00:00:00 2001 From: siloneco Date: Fri, 23 Feb 2024 12:28:01 +0000 Subject: [PATCH 10/12] update swagger file --- openapi/api_definition.swagger.yaml | 114 ++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 14 deletions(-) diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml index 4b29c14..a6eca2a 100644 --- a/openapi/api_definition.swagger.yaml +++ b/openapi/api_definition.swagger.yaml @@ -1,4 +1,4 @@ -swagger: '2.0' +swagger: "2.0" info: title: proto/schema/auth/discord/callback/callback.proto version: version not set @@ -15,11 +15,11 @@ paths: get: operationId: DiscordCallbackService_GetDiscordCallback responses: - '200': + "200": description: A successful response. schema: $ref: '#/definitions/resourcesDiscordToken' - '422': + "422": description: Validation Error schema: {} examples: @@ -41,11 +41,11 @@ paths: post: operationId: SignUpService_PostSignUp responses: - '200': + "200": description: A successful response. schema: $ref: '#/definitions/resourcesAccount' - '422': + "422": description: Validation Error schema: {} examples: @@ -83,11 +83,11 @@ paths: get: operationId: TagsService_GetTags responses: - '200': + "200": description: A successful response. schema: $ref: '#/definitions/rpcGetTagsResponse' - '422': + "422": description: Validation Error schema: {} examples: @@ -123,14 +123,14 @@ definitions: type: object example: avatar_url: https://example.com/ - created_at: '2024-01-11T07:56:02.206Z' + created_at: "2024-01-11T07:56:02.206Z" display_name: string github_id: string id: string name: string profile: string twitter_id: string - updated_at: '2024-01-11T07:56:02.206Z' + updated_at: "2024-01-11T07:56:02.206Z" properties: id: type: string @@ -147,11 +147,9 @@ definitions: github_id: type: string created_at: - type: string - title: google.type.Date ? + $ref: '#/definitions/typeDateTime' updated_at: - type: string - title: google.type.Date ? + $ref: '#/definitions/typeDateTime' resourcesDiscordToken: type: object example: @@ -177,7 +175,7 @@ definitions: type: object example: color: '#000000' - id: '1' + id: "1" name: tag1 properties: id: @@ -186,3 +184,91 @@ definitions: type: string color: type: string + typeDateTime: + type: object + properties: + year: + type: integer + format: int32 + description: |- + Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + datetime without a year. + month: + type: integer + format: int32 + description: Required. Month of year. Must be from 1 to 12. + day: + type: integer + format: int32 + description: |- + Required. Day of month. Must be from 1 to 31 and valid for the year and + month. + hours: + type: integer + format: int32 + description: |- + Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + may choose to allow the value "24:00:00" for scenarios like business + closing time. + minutes: + type: integer + format: int32 + description: Required. Minutes of hour of day. Must be from 0 to 59. + seconds: + type: integer + format: int32 + description: |- + Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + API may allow the value 60 if it allows leap-seconds. + nanos: + type: integer + format: int32 + description: |- + Required. Fractions of seconds in nanoseconds. Must be from 0 to + 999,999,999. + utc_offset: + type: string + description: |- + UTC offset. Must be whole seconds, between -18 hours and +18 hours. + For example, a UTC offset of -4:00 would be represented as + { seconds: -14400 }. + time_zone: + $ref: '#/definitions/typeTimeZone' + description: Time zone. + description: |- + Represents civil time (or occasionally physical time). + + This type can represent a civil time in one of a few possible ways: + + * When utc_offset is set and time_zone is unset: a civil time on a calendar + day with a particular offset from UTC. + * When time_zone is set and utc_offset is unset: a civil time on a calendar + day in a particular time zone. + * When neither time_zone nor utc_offset is set: a civil time on a calendar + day in local time. + + The date is relative to the Proleptic Gregorian Calendar. + + If year is 0, the DateTime is considered not to have a specific year. month + and day must have valid, non-zero values. + + This type may also be used to represent a physical time if all the date and + time fields are set and either case of the `time_offset` oneof is set. + Consider using `Timestamp` message for physical time instead. If your use + case also would like to store the user's timezone, that can be done in + another field. + + This type is more flexible than some applications may want. Make sure to + document and validate your application's limitations. + typeTimeZone: + type: object + properties: + id: + type: string + description: IANA Time Zone Database time zone, e.g. "America/New_York". + version: + type: string + description: Optional. IANA Time Zone Database version number, e.g. "2019a". + description: |- + Represents a time zone from the + [IANA Time Zone Database](https://www.iana.org/time-zones). From 905d4cf8de7e2915275eefe60c428af634836ebf Mon Sep 17 00:00:00 2001 From: siloneco Date: Fri, 23 Feb 2024 12:46:17 +0000 Subject: [PATCH 11/12] fix: not query param, its req body --- openapi/api_definition.swagger.yaml | 295 ++++++++++++++++++ proto/schema/users/me/me.proto | 1 + proto/schema/users/me/resources/me.proto | 5 +- .../google/api/type/datetime.proto | 104 ++++++ 4 files changed, 403 insertions(+), 2 deletions(-) create mode 100644 openapi/api_definition.swagger.yaml create mode 100644 proto/third_party/google/api/type/datetime.proto diff --git a/openapi/api_definition.swagger.yaml b/openapi/api_definition.swagger.yaml new file mode 100644 index 0000000..f7e4aec --- /dev/null +++ b/openapi/api_definition.swagger.yaml @@ -0,0 +1,295 @@ +swagger: "2.0" +info: + title: proto/schema/auth/discord/callback/callback.proto + version: version not set +tags: + - name: DiscordCallbackService + - name: MeService + - name: TagsService +consumes: + - application/json +produces: + - application/json +paths: + /v1/auth/discord/callback: + get: + operationId: DiscordCallbackService_GetDiscordCallback + 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 + parameters: + - name: code + in: query + required: false + type: string + tags: + - DiscordCallbackService + /v1/tags: + get: + operationId: TagsService_GetTags + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/rpcGetTagsResponse' + "422": + description: Validation Error + schema: {} + examples: + application/json: + detail: + - loc: + - string + - 0 + msg: string + type: string + parameters: + - name: limit + in: query + required: false + type: integer + format: int32 + - name: smallest_tag_id + in: query + required: false + type: string + - name: biggest_tag_id + in: query + required: false + type: string + - name: w + in: query + required: false + type: string + tags: + - TagsService + /v1/users/@me: + get: + operationId: MeService_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 + tags: + - MeService + put: + operationId: MeService_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 + parameters: + - name: body + in: body + required: true + schema: + $ref: '#/definitions/rpcAccountPatcher' + tags: + - MeService +definitions: + resourcesAccount: + type: object + example: + avatar_url: https://example.com/ + created_at: "2024-01-11T07:56:02.206Z" + display_name: string + github_id: string + id: string + name: string + profile: string + twitter_id: string + updated_at: "2024-01-11T07:56:02.206Z" + properties: + id: + type: string + name: + type: string + display_name: + type: string + avatar_url: + type: string + profile: + type: string + twitter_id: + type: string + github_id: + type: string + created_at: + $ref: '#/definitions/typeDateTime' + updated_at: + $ref: '#/definitions/typeDateTime' + resourcesDiscordToken: + type: object + example: + access_token: token + expired_at: expire-time + refresh_token: refresh-token + properties: + access_token: + type: string + refresh_token: + type: string + expired_at: + type: string + rpcAccountPatcher: + 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 + rpcGetTagsResponse: + type: object + properties: + tags: + type: array + items: + type: object + $ref: '#/definitions/tagsresourcesTag' + tagsresourcesTag: + type: object + example: + color: '#000000' + id: "1" + name: tag1 + properties: + id: + type: string + name: + type: string + color: + type: string + typeDateTime: + type: object + properties: + year: + type: integer + format: int32 + description: |- + Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + datetime without a year. + month: + type: integer + format: int32 + description: Required. Month of year. Must be from 1 to 12. + day: + type: integer + format: int32 + description: |- + Required. Day of month. Must be from 1 to 31 and valid for the year and + month. + hours: + type: integer + format: int32 + description: |- + Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + may choose to allow the value "24:00:00" for scenarios like business + closing time. + minutes: + type: integer + format: int32 + description: Required. Minutes of hour of day. Must be from 0 to 59. + seconds: + type: integer + format: int32 + description: |- + Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + API may allow the value 60 if it allows leap-seconds. + nanos: + type: integer + format: int32 + description: |- + Required. Fractions of seconds in nanoseconds. Must be from 0 to + 999,999,999. + utc_offset: + type: string + description: |- + UTC offset. Must be whole seconds, between -18 hours and +18 hours. + For example, a UTC offset of -4:00 would be represented as + { seconds: -14400 }. + time_zone: + $ref: '#/definitions/typeTimeZone' + description: Time zone. + description: |- + Represents civil time (or occasionally physical time). + + This type can represent a civil time in one of a few possible ways: + + * When utc_offset is set and time_zone is unset: a civil time on a calendar + day with a particular offset from UTC. + * When time_zone is set and utc_offset is unset: a civil time on a calendar + day in a particular time zone. + * When neither time_zone nor utc_offset is set: a civil time on a calendar + day in local time. + + The date is relative to the Proleptic Gregorian Calendar. + + If year is 0, the DateTime is considered not to have a specific year. month + and day must have valid, non-zero values. + + This type may also be used to represent a physical time if all the date and + time fields are set and either case of the `time_offset` oneof is set. + Consider using `Timestamp` message for physical time instead. If your use + case also would like to store the user's timezone, that can be done in + another field. + + This type is more flexible than some applications may want. Make sure to + document and validate your application's limitations. + typeTimeZone: + type: object + properties: + id: + type: string + description: IANA Time Zone Database time zone, e.g. "America/New_York". + version: + type: string + description: Optional. IANA Time Zone Database version number, e.g. "2019a". + description: |- + Represents a time zone from the + [IANA Time Zone Database](https://www.iana.org/time-zones). diff --git a/proto/schema/users/me/me.proto b/proto/schema/users/me/me.proto index c5dc864..a6e70bc 100644 --- a/proto/schema/users/me/me.proto +++ b/proto/schema/users/me/me.proto @@ -22,6 +22,7 @@ service MeService { 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/me/resources/me.proto index 8f8eac6..45a96f3 100644 --- a/proto/schema/users/me/resources/me.proto +++ b/proto/schema/users/me/resources/me.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package proto.schema.users.me.resources; import "proto/third_party/grpc/openapiv2/options/annotations.proto"; +import "proto/third_party/google/api/type/datetime.proto"; option go_package = "./"; @@ -13,8 +14,8 @@ message Account { string profile = 5; string twitter_id = 6; string github_id = 7; - string created_at = 8; // google.type.Date ? - string updated_at = 9; // google.type.Date ? + google.type.DateTime created_at = 8; + google.type.DateTime updated_at = 9; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = { example : "{" diff --git a/proto/third_party/google/api/type/datetime.proto b/proto/third_party/google/api/type/datetime.proto new file mode 100644 index 0000000..86f98c9 --- /dev/null +++ b/proto/third_party/google/api/type/datetime.proto @@ -0,0 +1,104 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +import "google/protobuf/duration.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; +option java_multiple_files = true; +option java_outer_classname = "DateTimeProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents civil time (or occasionally physical time). +// +// This type can represent a civil time in one of a few possible ways: +// +// * When utc_offset is set and time_zone is unset: a civil time on a calendar +// day with a particular offset from UTC. +// * When time_zone is set and utc_offset is unset: a civil time on a calendar +// day in a particular time zone. +// * When neither time_zone nor utc_offset is set: a civil time on a calendar +// day in local time. +// +// The date is relative to the Proleptic Gregorian Calendar. +// +// If year is 0, the DateTime is considered not to have a specific year. month +// and day must have valid, non-zero values. +// +// This type may also be used to represent a physical time if all the date and +// time fields are set and either case of the `time_offset` oneof is set. +// Consider using `Timestamp` message for physical time instead. If your use +// case also would like to store the user's timezone, that can be done in +// another field. +// +// This type is more flexible than some applications may want. Make sure to +// document and validate your application's limitations. +message DateTime { + // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + // datetime without a year. + int32 year = 1; + + // Required. Month of year. Must be from 1 to 12. + int32 month = 2; + + // Required. Day of month. Must be from 1 to 31 and valid for the year and + // month. + int32 day = 3; + + // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + // may choose to allow the value "24:00:00" for scenarios like business + // closing time. + int32 hours = 4; + + // Required. Minutes of hour of day. Must be from 0 to 59. + int32 minutes = 5; + + // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + // API may allow the value 60 if it allows leap-seconds. + int32 seconds = 6; + + // Required. Fractions of seconds in nanoseconds. Must be from 0 to + // 999,999,999. + int32 nanos = 7; + + // Optional. Specifies either the UTC offset or the time zone of the DateTime. + // Choose carefully between them, considering that time zone data may change + // in the future (for example, a country modifies their DST start/end dates, + // and future DateTimes in the affected range had already been stored). + // If omitted, the DateTime is considered to be in local time. + oneof time_offset { + // UTC offset. Must be whole seconds, between -18 hours and +18 hours. + // For example, a UTC offset of -4:00 would be represented as + // { seconds: -14400 }. + google.protobuf.Duration utc_offset = 8; + + // Time zone. + TimeZone time_zone = 9; + } +} + +// Represents a time zone from the +// [IANA Time Zone Database](https://www.iana.org/time-zones). +message TimeZone { + // IANA Time Zone Database time zone, e.g. "America/New_York". + string id = 1; + + // Optional. IANA Time Zone Database version number, e.g. "2019a". + string version = 2; +} \ No newline at end of file From 9045f9e992bbfdbb77e02017db1bdb19b3ef1436 Mon Sep 17 00:00:00 2001 From: tosaken1116 Date: Sat, 6 Apr 2024 14:49:14 +0900 Subject: [PATCH 12/12] chore: add conflict openapi yaml resolve actions --- .github/workflows/resolve.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/resolve.yaml diff --git a/.github/workflows/resolve.yaml b/.github/workflows/resolve.yaml new file mode 100644 index 0000000..82f99da --- /dev/null +++ b/.github/workflows/resolve.yaml @@ -0,0 +1,25 @@ +name: rebase and rebuild openapi + +on: + workflow_dispatch: + +jobs: + rebase_and_rebuild_openapi: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + - name: Rebase + run: git rebase main + - name: Rebuild OpenAPI + run: | + make build + - name: Commit and push + run: | + git config --global user.name "GitHub Actions Bot" + git config --global user.email "" + git add . + git commit -m "Rebuild OpenAPI" + git push