feat(tester, user): migrate from gRPC to REST
This commit is contained in:
parent
11644adc88
commit
b7ea2e6cc7
10 changed files with 638 additions and 1458 deletions
295
user/v1/openapi.yaml
Normal file
295
user/v1/openapi.yaml
Normal file
|
@ -0,0 +1,295 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: UserService API
|
||||
version: 0.0.1
|
||||
paths:
|
||||
/sessions/complete-logout:
|
||||
post:
|
||||
operationId: CompleteLogout
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
/sessions/login:
|
||||
post:
|
||||
operationId: Login
|
||||
security:
|
||||
- BasicAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
"404":
|
||||
description: Not Found
|
||||
content: { }
|
||||
/sessions/logout:
|
||||
post:
|
||||
operationId: Logout
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
/sessions/refresh:
|
||||
post:
|
||||
operationId: Refresh
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
/sessions/verify:
|
||||
get:
|
||||
operationId: Verify
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
/sessions:
|
||||
get:
|
||||
operationId: ListSessions
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ListSessionsResponse'
|
||||
/users:
|
||||
post:
|
||||
operationId: CreateUser
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateUserRequest'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateUserResponse'
|
||||
get:
|
||||
operationId: ListUsers
|
||||
parameters:
|
||||
- name: page
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
- name: pageSize
|
||||
in: query
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ListUsersResponse'
|
||||
/users/me:
|
||||
get:
|
||||
operationId: GetMe
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetUserResponse'
|
||||
/users/{id}:
|
||||
get:
|
||||
operationId: GetUser
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GetUserResponse'
|
||||
delete:
|
||||
operationId: DeleteUser
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
patch:
|
||||
operationId: UpdateUser
|
||||
security:
|
||||
- bearerAuth: [ ]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UpdateUserRequest'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content: { }
|
||||
components:
|
||||
schemas:
|
||||
CreateUserRequest:
|
||||
type: object
|
||||
required:
|
||||
- username
|
||||
- password
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
CreateUserResponse:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int32
|
||||
GetUserResponse:
|
||||
type: object
|
||||
required:
|
||||
- user
|
||||
properties:
|
||||
user:
|
||||
$ref: '#/components/schemas/User'
|
||||
UpdateUserRequest:
|
||||
type: object
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
role:
|
||||
type: integer
|
||||
format: int32
|
||||
User:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- username
|
||||
- createdAt
|
||||
- modifiedAt
|
||||
- role
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int32
|
||||
username:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
format: date-time
|
||||
modifiedAt:
|
||||
type: string
|
||||
format: date-time
|
||||
role:
|
||||
type: integer
|
||||
format: int32
|
||||
Session:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- userId
|
||||
- role
|
||||
- createdAt
|
||||
- expiresAt
|
||||
- userAgent
|
||||
- ip
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
userId:
|
||||
type: integer
|
||||
format: int32
|
||||
role:
|
||||
type: integer
|
||||
format: int32
|
||||
createdAt:
|
||||
type: string
|
||||
format: date-time
|
||||
expiresAt:
|
||||
type: string
|
||||
format: date-time
|
||||
userAgent:
|
||||
type: string
|
||||
ip:
|
||||
type: string
|
||||
ListSessionsResponse:
|
||||
type: object
|
||||
required:
|
||||
- sessions
|
||||
properties:
|
||||
sessions:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Session'
|
||||
ListUsersResponse:
|
||||
type: object
|
||||
required:
|
||||
- users
|
||||
- page
|
||||
- max_page
|
||||
properties:
|
||||
users:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
page:
|
||||
type: integer
|
||||
format: int32
|
||||
max_page:
|
||||
type: integer
|
||||
format: int32
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
BasicAuth:
|
||||
type: http
|
||||
scheme: basic
|
|
@ -1,116 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package user.v1;
|
||||
option go_package = "/user/v1;userv1";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
service UserService {
|
||||
rpc Login(LoginRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/session/login"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc Logout(google.protobuf.Empty) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/session/logout"
|
||||
};
|
||||
}
|
||||
|
||||
rpc Refresh(google.protobuf.Empty) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post: "/session/refresh"
|
||||
};
|
||||
}
|
||||
|
||||
rpc Verify(google.protobuf.Empty) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
get: "/session/verify"
|
||||
};
|
||||
}
|
||||
|
||||
rpc CompleteLogout(google.protobuf.Empty) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
post : "/session/complete-logout"
|
||||
};
|
||||
}
|
||||
|
||||
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/users"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc GetUser(GetUserRequest) returns (GetUserResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/users/{id}"
|
||||
};
|
||||
}
|
||||
|
||||
rpc UpdateUser(UpdateUserRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
patch: "/users/{id}"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {
|
||||
delete: "/users/{id}"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
enum Role {
|
||||
ROLE_PARTICIPANT_UNSPECIFIED = 0;
|
||||
ROLE_MODERATOR = 1;
|
||||
ROLE_ADMIN = 2;
|
||||
}
|
||||
|
||||
message User {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
reserved 3;
|
||||
google.protobuf.Timestamp created_at = 4;
|
||||
google.protobuf.Timestamp modified_at = 5;
|
||||
Role role = 6;
|
||||
}
|
||||
|
||||
message LoginRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
message CreateUserRequest {
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
|
||||
message CreateUserResponse {
|
||||
int32 id = 1;
|
||||
}
|
||||
|
||||
message GetUserRequest {
|
||||
int32 id = 1;
|
||||
bool me = 2;
|
||||
}
|
||||
|
||||
message GetUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message UpdateUserRequest {
|
||||
int32 id = 1;
|
||||
string username = 2;
|
||||
reserved 3;
|
||||
Role role = 4;
|
||||
}
|
||||
|
||||
message DeleteUserRequest {
|
||||
int32 id = 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue