diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 959e0c8..0d3a432 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v3 - name: Install webrpc-gen run: | - curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.31.0/webrpc-gen.linux-amd64 + curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.32.3/webrpc-gen.linux-amd64 chmod +x ./webrpc-gen echo $PWD >> $GITHUB_PATH diff --git a/_examples/api.ridl b/_examples/api.ridl index 05dde05..0ce6a61 100644 --- a/_examples/api.ridl +++ b/_examples/api.ridl @@ -1,7 +1,8 @@ webrpc = v1 # version of webrpc schema format (ridl or json) -name = example # name of your backend app -version = v0.0.1 # version of your schema +name = example # name of your backend app +version = v1.0.0 # version of your schema +basepath = /v1 # base path for the API routes service ExampleService @deprecated diff --git a/_examples/openapi.gen.yaml b/_examples/openapi.gen.yaml index 36d3559..88e5fec 100644 --- a/_examples/openapi.gen.yaml +++ b/_examples/openapi.gen.yaml @@ -1,6 +1,6 @@ -# example v0.0.1 7fb0c7ec825a4b11489f18f6be64880a8b72ccee +# example v1.0.0 78160f3365e4f91df80f171a445efde0a288026e # -- -# Code generated by webrpc-gen@v0.31.0 with ../ generator; DO NOT EDIT +# Code generated by webrpc-gen@v0.32.3 with ../ generator; DO NOT EDIT # # 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' } } openapi: 3.0.0 @@ -582,7 +582,7 @@ components: $ref: '#/components/schemas/User' paths: - /rpc/ExampleService/Ping: + /v1/ExampleService/Ping: post: operationId: ExampleService-Ping tags: ["ExampleService"] @@ -624,7 +624,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/GetUser: + /v1/ExampleService/GetUser: post: operationId: ExampleService-GetUser tags: ["ExampleService"] @@ -668,7 +668,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/GetUserV2: + /v1/ExampleService/GetUserV2: post: operationId: ExampleService-GetUserV2 tags: ["ExampleService"] @@ -713,7 +713,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/FindUser: + /v1/ExampleService/FindUser: post: operationId: ExampleService-FindUser tags: ["ExampleService"] @@ -761,7 +761,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/ListUsers: + /v1/ExampleService/ListUsers: post: operationId: ExampleService-ListUsers tags: ["ExampleService"] @@ -804,7 +804,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/GetComplex: + /v1/ExampleService/GetComplex: post: operationId: ExampleService-GetComplex tags: ["ExampleService"] @@ -845,7 +845,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/GetAllOptional: + /v1/ExampleService/GetAllOptional: post: operationId: ExampleService-GetAllOptional tags: ["ExampleService"] @@ -886,7 +886,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService/StreamUserNotifications: + /v1/ExampleService/StreamUserNotifications: post: operationId: ExampleService-StreamUserNotifications tags: ["ExampleService"] @@ -930,7 +930,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService2/Ping: + /v1/ExampleService2/Ping: post: operationId: ExampleService2-Ping tags: ["ExampleService2"] @@ -972,7 +972,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService2/GetUserV2: + /v1/ExampleService2/GetUserV2: post: operationId: ExampleService2-GetUserV2 tags: ["ExampleService2"] @@ -1015,7 +1015,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService2/FindUser: + /v1/ExampleService2/FindUser: post: operationId: ExampleService2-FindUser tags: ["ExampleService2"] @@ -1063,7 +1063,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService2/ListUsers: + /v1/ExampleService2/ListUsers: post: operationId: ExampleService2-ListUsers tags: ["ExampleService2"] @@ -1106,7 +1106,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/ExampleService2/StreamUserNotifications: + /v1/ExampleService2/StreamUserNotifications: post: operationId: ExampleService2-StreamUserNotifications tags: ["ExampleService2"] @@ -1150,7 +1150,7 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - $ref: '#/components/schemas/ErrorDatabaseDown' - /rpc/AdminService/ListUsers: + /v1/AdminService/ListUsers: post: operationId: AdminService-ListUsers tags: ["AdminService"] diff --git a/main.go.tmpl b/main.go.tmpl index cdcaf26..7972833 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -60,6 +60,7 @@ {{- set $typeMap "[]" "array" -}} {{- $types := .Types -}} +{{- $basepath := .BasePath -}} {{- $services := .Services -}} {{- $webrpcErrors := .WebrpcErrors -}} {{- $schemaErrors := .Errors -}} @@ -141,7 +142,7 @@ paths: {{- $isSuccinctInput := $method.Succinct -}} {{- $isSuccinctOutput := $method.Succinct -}} {{- $deprecated := index $method.Annotations "deprecated" }} - /rpc/{{$service.Name}}/{{$method.Name}}: + {{$basepath}}{{$service.Name}}/{{$method.Name}}: post: operationId: {{$service.Name}}-{{$method.Name}} tags: ["{{$service.Name}}"]