diff --git a/Taskfile.yaml b/Taskfile.yaml index 115c8d9..64c277d 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -13,8 +13,8 @@ tasks: - | go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.8 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 - go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.27.1 - go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.27.2 + go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.27.3 + go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.27.3 go install github.com/envoyproxy/protoc-gen-validate@v1.2.1 go install github.com/pressly/goose/v3/cmd/goose@v3.25.0 build: diff --git a/docker-compose.yaml b/docker-compose.yaml index 5030f5a..ce603f7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -117,7 +117,7 @@ services: container_name: gateway environment: ENV: dev - OPEN_API: swagger/auth/v1/ + OPEN_API: swagger/ HTTP_PORT: 8080 AUTH_ADDRESS: auth:50051 TELEMETRY_TRACE: otel-collector:4317 diff --git a/gateway/internal/openapi/openapi.go b/gateway/internal/openapi/openapi.go index cebeb47..229b135 100644 --- a/gateway/internal/openapi/openapi.go +++ b/gateway/internal/openapi/openapi.go @@ -17,14 +17,14 @@ func RegisteraOpenAPIEndpoint(mux *runtime.ServeMux, dir string) error { } _ = openAPIdata - mux.HandlePath(http.MethodGet, "/swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { + mux.HandlePath(http.MethodGet, "/api.swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { w.Header().Set("Content-Type", "application/json") w.Write(openAPIdata) w.WriteHeader(http.StatusOK) }) swaggerHandler := httpSwagger.Handler( - httpSwagger.URL("/swagger.json"), + httpSwagger.URL("/api.swagger.json"), ) err = mux.HandlePath(http.MethodGet, "/swagger/*", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) { swaggerHandler(w, r) diff --git a/protos/Taskfile.yaml b/protos/Taskfile.yaml index 7d4c471..f88c731 100644 --- a/protos/Taskfile.yaml +++ b/protos/Taskfile.yaml @@ -42,7 +42,7 @@ tasks: --go_out={{.OUT_DIR}}/go --go_opt=paths=source_relative \ --go-grpc_out={{.OUT_DIR}}/go --go-grpc_opt=paths=source_relative \ --grpc-gateway_out={{.OUT_DIR}}/go --grpc-gateway_opt=paths=source_relative \ - --openapiv2_out={{.OUT_DIR}}/swagger \ + --openapiv2_out=allow_merge=true,merge_file_name=api:{{.OUT_DIR}}/swagger \ ${FILES} clear: diff --git a/protos/gen/swagger/auth/v1/auth.swagger.json b/protos/gen/swagger/api.swagger.json similarity index 72% rename from protos/gen/swagger/auth/v1/auth.swagger.json rename to protos/gen/swagger/api.swagger.json index 845d9d3..c166946 100644 --- a/protos/gen/swagger/auth/v1/auth.swagger.json +++ b/protos/gen/swagger/api.swagger.json @@ -7,6 +7,9 @@ "tags": [ { "name": "Auth" + }, + { + "name": "Profiles" } ], "consumes": [ @@ -79,9 +82,62 @@ "Auth" ] } + }, + "/v1/profiles/me": { + "get": { + "operationId": "Profiles_GetMe", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/authGetMeResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "tags": [ + "Profiles" + ] + } } }, "definitions": { + "authCreateResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + } + } + }, + "authGetMeResponse": { + "type": "object", + "properties": { + "porfile": { + "$ref": "#/definitions/authProfile" + } + } + }, + "authProfile": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "avatar": { + "type": "string", + "format": "byte" + } + } + }, "authSignInRequest": { "type": "object", "properties": {