Skip to content

Commit 4f42bae

Browse files
committed
Support succinct RIDL syntax
1 parent 4a33644 commit 4f42bae

3 files changed

Lines changed: 350 additions & 10 deletions

File tree

_examples/api.ridl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ service ExampleService
3131
- GetComplex() => (complex: ComplexType)
3232
- GetAllOptional() => (optional: Optional)
3333

34+
- StreamUserNotifications() => stream (StreamNotificationsResponse)
35+
36+
service ExampleService2
37+
@deprecated
38+
- Ping()
39+
40+
# GetUserV2 returns user based on given userID.
41+
@auth:JWT
42+
- GetUserV2(GetUserRequest) => (GetUserResponse)
43+
44+
# FindUser searches for a user using the given search filter.
45+
#
46+
# The filters are q (string) and active (bool).
47+
#
48+
# The minimal length of the "q" filter is 3 characters.
49+
@auth:JWT
50+
- FindUser(FindUserRequest) => (FindUserResponse)
51+
52+
# ListUsers returns all users.
53+
@auth:JWT
54+
- ListUsers(ListUsersRequest) => (ListUsersResponse)
55+
3456
- StreamUserNotifications(StreamNotificationsRequest) => stream (StreamNotificationsResponse)
3557

3658
service AdminService
@@ -90,3 +112,25 @@ struct StreamNotificationsResponse
90112
struct Notification
91113
- message: string
92114
- timestamp: timestamp
115+
116+
struct GetUserRequest
117+
- header: map<string,string>
118+
- userID: uint64
119+
120+
struct GetUserResponse
121+
- code: uint32
122+
- user: User
123+
124+
struct FindUserRequest
125+
- s: SearchFilter
126+
127+
struct FindUserResponse
128+
- name: string
129+
- user: User
130+
131+
struct ListUsersRequest
132+
- header: map<string,string>
133+
134+
struct ListUsersResponse
135+
- users: []User
136+

_examples/openapi.gen.yaml

Lines changed: 286 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# example v0.0.1 55eeccc8db95e08d65f0da63acfdcbd92cc1e6fa
1+
# example v0.0.1 7fb0c7ec825a4b11489f18f6be64880a8b72ccee
22
# --
3-
# Code generated by webrpc-gen@v0.31.0 with ../ generator; DO NOT EDIT
3+
# Code generated by webrpc-gen@v0.32.0-2-g2ee7176 with ../ generator; DO NOT EDIT
44
#
55
# webrpc-gen -schema=./api.ridl -target=../ -out=./openapi.gen.yaml -title=Example webrpc API -apiVersion=v22.11.8 -serverUrl=https://api.example.com -serverDescription=Production -securityAnnotation=@auth -securitySchemes={ 'ApiKeyAuth': { 'type': 'apiKey', 'in': 'header', 'description': 'Project access key for authenticating requests', 'name': 'X-Access-Key' }, 'ServiceAuth': { 'type': 'apiKey', 'in': 'header', 'description': 'Project access key for authenticating requests', 'name': 'X-Access-Key' } }
66
openapi: 3.0.0
@@ -430,6 +430,66 @@ components:
430430
type: string
431431
timestamp:
432432
type: string
433+
GetUserRequest:
434+
type: object
435+
required:
436+
- header
437+
- userID
438+
properties:
439+
header:
440+
type: object
441+
description: 'map<string,string>'
442+
additionalProperties:
443+
type: string
444+
userID:
445+
type: number
446+
GetUserResponse:
447+
type: object
448+
required:
449+
- code
450+
- user
451+
properties:
452+
code:
453+
type: number
454+
user:
455+
$ref: '#/components/schemas/User'
456+
FindUserRequest:
457+
type: object
458+
required:
459+
- s
460+
properties:
461+
s:
462+
$ref: '#/components/schemas/SearchFilter'
463+
FindUserResponse:
464+
type: object
465+
required:
466+
- name
467+
- user
468+
properties:
469+
name:
470+
type: string
471+
user:
472+
$ref: '#/components/schemas/User'
473+
ListUsersRequest:
474+
type: object
475+
required:
476+
- header
477+
properties:
478+
header:
479+
type: object
480+
description: 'map<string,string>'
481+
additionalProperties:
482+
type: string
483+
ListUsersResponse:
484+
type: object
485+
required:
486+
- users
487+
properties:
488+
users:
489+
type: array
490+
description: '[]User'
491+
items:
492+
$ref: '#/components/schemas/User'
433493
ExampleService_Ping_Request:
434494
type: object
435495
ExampleService_GetUser_Request:
@@ -465,9 +525,6 @@ components:
465525
type: object
466526
ExampleService_StreamUserNotifications_Request:
467527
type: object
468-
properties:
469-
streamNotificationsRequest:
470-
$ref: '#/components/schemas/StreamNotificationsRequest'
471528
ExampleService_Ping_Response:
472529
type: object
473530
ExampleService_GetUser_Response:
@@ -511,11 +568,10 @@ components:
511568
properties:
512569
optional:
513570
$ref: '#/components/schemas/Optional'
514-
ExampleService_StreamUserNotifications_Response:
571+
ExampleService2_Ping_Request:
572+
type: object
573+
ExampleService2_Ping_Response:
515574
type: object
516-
properties:
517-
streamNotificationsResponse:
518-
$ref: '#/components/schemas/StreamNotificationsResponse'
519575
AdminService_ListUsers_Request:
520576
type: object
521577
AdminService_ListUsers_Response:
@@ -848,7 +904,7 @@ paths:
848904
content:
849905
application/x-ndjson:
850906
schema:
851-
$ref: '#/components/schemas/ExampleService_StreamUserNotifications_Response'
907+
$ref: '#/components/schemas/StreamNotificationsResponse'
852908
# OpenAPI 3.2.0 streaming (itemSchema) is not supported by 3.1.0 tooling:
853909
# itemSchema:
854910
# $ref: '#/components/schemas/ExampleService_StreamUserNotifications_Response'
@@ -876,6 +932,226 @@ paths:
876932
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
877933
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
878934
- $ref: '#/components/schemas/ErrorDatabaseDown'
935+
/rpc/ExampleService2/Ping:
936+
post:
937+
operationId: ExampleService2-Ping
938+
tags: ["ExampleService2"]
939+
summary: "Deprecated."
940+
deprecated: true
941+
requestBody:
942+
content:
943+
application/json:
944+
schema:
945+
$ref: '#/components/schemas/ExampleService2_Ping_Request'
946+
responses:
947+
'200':
948+
description: OK
949+
content:
950+
application/json:
951+
schema:
952+
$ref: '#/components/schemas/ExampleService2_Ping_Response'
953+
'4XX':
954+
description: Client error
955+
content:
956+
application/json:
957+
schema:
958+
oneOf:
959+
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
960+
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
961+
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
962+
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
963+
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
964+
- $ref: '#/components/schemas/ErrorWebrpcClientAborted'
965+
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
966+
- $ref: '#/components/schemas/ErrorRateLimited'
967+
'5XX':
968+
description: Server error
969+
content:
970+
application/json:
971+
schema:
972+
oneOf:
973+
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
974+
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
975+
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
976+
- $ref: '#/components/schemas/ErrorDatabaseDown'
977+
/rpc/ExampleService2/GetUserV2:
978+
post:
979+
operationId: ExampleService2-GetUserV2
980+
tags: ["ExampleService2"]
981+
summary: "GetUserV2 returns user based on given userID."
982+
security:
983+
- JWT: []
984+
requestBody:
985+
content:
986+
application/json:
987+
schema:
988+
$ref: '#/components/schemas/GetUserRequest'
989+
responses:
990+
'200':
991+
description: OK
992+
content:
993+
application/json:
994+
schema:
995+
$ref: '#/components/schemas/GetUserResponse'
996+
'4XX':
997+
description: Client error
998+
content:
999+
application/json:
1000+
schema:
1001+
oneOf:
1002+
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
1003+
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
1004+
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
1005+
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
1006+
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
1007+
- $ref: '#/components/schemas/ErrorWebrpcClientAborted'
1008+
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
1009+
- $ref: '#/components/schemas/ErrorRateLimited'
1010+
'5XX':
1011+
description: Server error
1012+
content:
1013+
application/json:
1014+
schema:
1015+
oneOf:
1016+
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
1017+
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
1018+
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
1019+
- $ref: '#/components/schemas/ErrorDatabaseDown'
1020+
/rpc/ExampleService2/FindUser:
1021+
post:
1022+
operationId: ExampleService2-FindUser
1023+
tags: ["ExampleService2"]
1024+
summary: "FindUser searches for a user using the given search filter."
1025+
security:
1026+
- JWT: []
1027+
description: |
1028+
1029+
The filters are q (string) and active (bool).
1030+
1031+
The minimal length of the "q" filter is 3 characters.
1032+
requestBody:
1033+
content:
1034+
application/json:
1035+
schema:
1036+
$ref: '#/components/schemas/FindUserRequest'
1037+
responses:
1038+
'200':
1039+
description: OK
1040+
content:
1041+
application/json:
1042+
schema:
1043+
$ref: '#/components/schemas/FindUserResponse'
1044+
'4XX':
1045+
description: Client error
1046+
content:
1047+
application/json:
1048+
schema:
1049+
oneOf:
1050+
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
1051+
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
1052+
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
1053+
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
1054+
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
1055+
- $ref: '#/components/schemas/ErrorWebrpcClientAborted'
1056+
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
1057+
- $ref: '#/components/schemas/ErrorRateLimited'
1058+
'5XX':
1059+
description: Server error
1060+
content:
1061+
application/json:
1062+
schema:
1063+
oneOf:
1064+
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
1065+
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
1066+
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
1067+
- $ref: '#/components/schemas/ErrorDatabaseDown'
1068+
/rpc/ExampleService2/ListUsers:
1069+
post:
1070+
operationId: ExampleService2-ListUsers
1071+
tags: ["ExampleService2"]
1072+
summary: "ListUsers returns all users."
1073+
security:
1074+
- JWT: []
1075+
requestBody:
1076+
content:
1077+
application/json:
1078+
schema:
1079+
$ref: '#/components/schemas/ListUsersRequest'
1080+
responses:
1081+
'200':
1082+
description: OK
1083+
content:
1084+
application/json:
1085+
schema:
1086+
$ref: '#/components/schemas/ListUsersResponse'
1087+
'4XX':
1088+
description: Client error
1089+
content:
1090+
application/json:
1091+
schema:
1092+
oneOf:
1093+
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
1094+
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
1095+
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
1096+
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
1097+
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
1098+
- $ref: '#/components/schemas/ErrorWebrpcClientAborted'
1099+
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
1100+
- $ref: '#/components/schemas/ErrorRateLimited'
1101+
'5XX':
1102+
description: Server error
1103+
content:
1104+
application/json:
1105+
schema:
1106+
oneOf:
1107+
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
1108+
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
1109+
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
1110+
- $ref: '#/components/schemas/ErrorDatabaseDown'
1111+
/rpc/ExampleService2/StreamUserNotifications:
1112+
post:
1113+
operationId: ExampleService2-StreamUserNotifications
1114+
tags: ["ExampleService2"]
1115+
summary: ""
1116+
requestBody:
1117+
content:
1118+
application/json:
1119+
schema:
1120+
$ref: '#/components/schemas/StreamNotificationsRequest'
1121+
responses:
1122+
'200':
1123+
description: OK
1124+
content:
1125+
application/x-ndjson:
1126+
schema:
1127+
$ref: '#/components/schemas/StreamNotificationsResponse'
1128+
# OpenAPI 3.2.0 streaming (itemSchema) is not supported by 3.1.0 tooling:
1129+
# itemSchema:
1130+
# $ref: '#/components/schemas/ExampleService2_StreamUserNotifications_Response'
1131+
'4XX':
1132+
description: Client error
1133+
content:
1134+
application/json:
1135+
schema:
1136+
oneOf:
1137+
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
1138+
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
1139+
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
1140+
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
1141+
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
1142+
- $ref: '#/components/schemas/ErrorWebrpcClientAborted'
1143+
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
1144+
- $ref: '#/components/schemas/ErrorRateLimited'
1145+
'5XX':
1146+
description: Server error
1147+
content:
1148+
application/json:
1149+
schema:
1150+
oneOf:
1151+
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
1152+
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
1153+
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
1154+
- $ref: '#/components/schemas/ErrorDatabaseDown'
8791155
/rpc/AdminService/ListUsers:
8801156
post:
8811157
operationId: AdminService-ListUsers

0 commit comments

Comments
 (0)