Skip to content

Commit 524a764

Browse files
authored
Support the new RIDL "basepath" keyword (#30)
* Support the new RIDL "basepath" keyword * update webrpc
1 parent 0d3cf1e commit 524a764

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- name: Install webrpc-gen
1717
run: |
18-
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.31.0/webrpc-gen.linux-amd64
18+
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.32.3/webrpc-gen.linux-amd64
1919
chmod +x ./webrpc-gen
2020
echo $PWD >> $GITHUB_PATH
2121

_examples/api.ridl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
webrpc = v1 # version of webrpc schema format (ridl or json)
22

3-
name = example # name of your backend app
4-
version = v0.0.1 # version of your schema
3+
name = example # name of your backend app
4+
version = v1.0.0 # version of your schema
5+
basepath = /v1 # base path for the API routes
56

67
service ExampleService
78
@deprecated

_examples/openapi.gen.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# example v0.0.1 7fb0c7ec825a4b11489f18f6be64880a8b72ccee
1+
# example v1.0.0 78160f3365e4f91df80f171a445efde0a288026e
22
# --
3-
# Code generated by webrpc-gen@v0.31.0 with ../ generator; DO NOT EDIT
3+
# Code generated by webrpc-gen@v0.32.3 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
@@ -582,7 +582,7 @@ components:
582582
$ref: '#/components/schemas/User'
583583

584584
paths:
585-
/rpc/ExampleService/Ping:
585+
/v1/ExampleService/Ping:
586586
post:
587587
operationId: ExampleService-Ping
588588
tags: ["ExampleService"]
@@ -624,7 +624,7 @@ paths:
624624
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
625625
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
626626
- $ref: '#/components/schemas/ErrorDatabaseDown'
627-
/rpc/ExampleService/GetUser:
627+
/v1/ExampleService/GetUser:
628628
post:
629629
operationId: ExampleService-GetUser
630630
tags: ["ExampleService"]
@@ -668,7 +668,7 @@ paths:
668668
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
669669
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
670670
- $ref: '#/components/schemas/ErrorDatabaseDown'
671-
/rpc/ExampleService/GetUserV2:
671+
/v1/ExampleService/GetUserV2:
672672
post:
673673
operationId: ExampleService-GetUserV2
674674
tags: ["ExampleService"]
@@ -713,7 +713,7 @@ paths:
713713
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
714714
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
715715
- $ref: '#/components/schemas/ErrorDatabaseDown'
716-
/rpc/ExampleService/FindUser:
716+
/v1/ExampleService/FindUser:
717717
post:
718718
operationId: ExampleService-FindUser
719719
tags: ["ExampleService"]
@@ -761,7 +761,7 @@ paths:
761761
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
762762
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
763763
- $ref: '#/components/schemas/ErrorDatabaseDown'
764-
/rpc/ExampleService/ListUsers:
764+
/v1/ExampleService/ListUsers:
765765
post:
766766
operationId: ExampleService-ListUsers
767767
tags: ["ExampleService"]
@@ -804,7 +804,7 @@ paths:
804804
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
805805
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
806806
- $ref: '#/components/schemas/ErrorDatabaseDown'
807-
/rpc/ExampleService/GetComplex:
807+
/v1/ExampleService/GetComplex:
808808
post:
809809
operationId: ExampleService-GetComplex
810810
tags: ["ExampleService"]
@@ -845,7 +845,7 @@ paths:
845845
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
846846
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
847847
- $ref: '#/components/schemas/ErrorDatabaseDown'
848-
/rpc/ExampleService/GetAllOptional:
848+
/v1/ExampleService/GetAllOptional:
849849
post:
850850
operationId: ExampleService-GetAllOptional
851851
tags: ["ExampleService"]
@@ -886,7 +886,7 @@ paths:
886886
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
887887
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
888888
- $ref: '#/components/schemas/ErrorDatabaseDown'
889-
/rpc/ExampleService/StreamUserNotifications:
889+
/v1/ExampleService/StreamUserNotifications:
890890
post:
891891
operationId: ExampleService-StreamUserNotifications
892892
tags: ["ExampleService"]
@@ -930,7 +930,7 @@ paths:
930930
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
931931
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
932932
- $ref: '#/components/schemas/ErrorDatabaseDown'
933-
/rpc/ExampleService2/Ping:
933+
/v1/ExampleService2/Ping:
934934
post:
935935
operationId: ExampleService2-Ping
936936
tags: ["ExampleService2"]
@@ -972,7 +972,7 @@ paths:
972972
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
973973
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
974974
- $ref: '#/components/schemas/ErrorDatabaseDown'
975-
/rpc/ExampleService2/GetUserV2:
975+
/v1/ExampleService2/GetUserV2:
976976
post:
977977
operationId: ExampleService2-GetUserV2
978978
tags: ["ExampleService2"]
@@ -1015,7 +1015,7 @@ paths:
10151015
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
10161016
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
10171017
- $ref: '#/components/schemas/ErrorDatabaseDown'
1018-
/rpc/ExampleService2/FindUser:
1018+
/v1/ExampleService2/FindUser:
10191019
post:
10201020
operationId: ExampleService2-FindUser
10211021
tags: ["ExampleService2"]
@@ -1063,7 +1063,7 @@ paths:
10631063
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
10641064
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
10651065
- $ref: '#/components/schemas/ErrorDatabaseDown'
1066-
/rpc/ExampleService2/ListUsers:
1066+
/v1/ExampleService2/ListUsers:
10671067
post:
10681068
operationId: ExampleService2-ListUsers
10691069
tags: ["ExampleService2"]
@@ -1106,7 +1106,7 @@ paths:
11061106
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
11071107
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
11081108
- $ref: '#/components/schemas/ErrorDatabaseDown'
1109-
/rpc/ExampleService2/StreamUserNotifications:
1109+
/v1/ExampleService2/StreamUserNotifications:
11101110
post:
11111111
operationId: ExampleService2-StreamUserNotifications
11121112
tags: ["ExampleService2"]
@@ -1150,7 +1150,7 @@ paths:
11501150
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
11511151
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
11521152
- $ref: '#/components/schemas/ErrorDatabaseDown'
1153-
/rpc/AdminService/ListUsers:
1153+
/v1/AdminService/ListUsers:
11541154
post:
11551155
operationId: AdminService-ListUsers
11561156
tags: ["AdminService"]

main.go.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
{{- set $typeMap "[]" "array" -}}
6161

6262
{{- $types := .Types -}}
63+
{{- $basepath := .BasePath -}}
6364
{{- $services := .Services -}}
6465
{{- $webrpcErrors := .WebrpcErrors -}}
6566
{{- $schemaErrors := .Errors -}}
@@ -141,7 +142,7 @@ paths:
141142
{{- $isSuccinctInput := $method.Succinct -}}
142143
{{- $isSuccinctOutput := $method.Succinct -}}
143144
{{- $deprecated := index $method.Annotations "deprecated" }}
144-
/rpc/{{$service.Name}}/{{$method.Name}}:
145+
{{$basepath}}{{$service.Name}}/{{$method.Name}}:
145146
post:
146147
operationId: {{$service.Name}}-{{$method.Name}}
147148
tags: ["{{$service.Name}}"]

0 commit comments

Comments
 (0)