Skip to content

Commit

Permalink
test rendering out api method with all optional attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Mar 5, 2024
1 parent 3bf8af4 commit 7407f07
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 11 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install webrpc-gen
run: |
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.13.1/webrpc-gen.linux-amd64
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.14.2/webrpc-gen.linux-amd64
chmod +x ./webrpc-gen
echo $PWD >> $GITHUB_PATH
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: 1.19
# - name: Install webrpc-gen (development)
# run: git clone --single-branch https://github.com/webrpc/webrpc.git --branch master && cd webrpc && make install

- name: Regenerate example schema
run: cd _examples && make generate
- name: Git diff of regenerated files
Expand Down
132 changes: 130 additions & 2 deletions _examples/openapi.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# example v0.0.1 6be99be4827f3c6b11044637ff6c61e667d58643
# example v0.0.1 a690751537facece7a7d040de043a2b9c3a1ee94
# --
# Code generated by webrpc-gen@v0.13.1 with ../ generator; DO NOT EDIT
# Code generated by webrpc-gen@v0.14.2 with ../ generator; DO NOT EDIT
#
# webrpc-gen -schema=./proto.ridl -target=../ -out=./openapi.gen.yaml -title=Example webrpc API -apiVersion=v22.11.8 -serverUrl=https://api.example.com -serverDescription=Production
openapi: 3.0.0
Expand Down Expand Up @@ -188,6 +188,72 @@ components:
status:
type: number
example: 500
ErrorWebrpcClientDisconnected:
type: object
required:
- error
- code
- msg
- status
properties:
error:
type: string
example: "WebrpcClientDisconnected"
code:
type: number
example: -8
msg:
type: string
example: "client disconnected"
cause:
type: string
status:
type: number
example: 400
ErrorWebrpcStreamLost:
type: object
required:
- error
- code
- msg
- status
properties:
error:
type: string
example: "WebrpcStreamLost"
code:
type: number
example: -9
msg:
type: string
example: "stream lost"
cause:
type: string
status:
type: number
example: 400
ErrorWebrpcStreamFinished:
type: object
required:
- error
- code
- msg
- status
properties:
error:
type: string
example: "WebrpcStreamFinished"
code:
type: number
example: -10
msg:
type: string
example: "stream finished"
cause:
type: string
status:
type: number
example: 200
ErrorRateLimited:
type: object
required:
Expand Down Expand Up @@ -337,6 +403,13 @@ components:
$ref: '#/components/schemas/User'
user:
$ref: '#/components/schemas/User'
Optional:
type: object
properties:
name:
type: string
email:
type: string
ExampleService_GetUser_Request:
type: object
properties:
Expand All @@ -356,6 +429,8 @@ components:
type: object
ExampleService_GetComplex_Request:
type: object
ExampleService_GetAllOptional_Request:
type: object
ExampleService_GetUser_Response:
type: object
properties:
Expand Down Expand Up @@ -383,6 +458,11 @@ components:
properties:
complex:
$ref: '#/components/schemas/ComplexType'
ExampleService_GetAllOptional_Response:
type: object
properties:
optional:
$ref: '#/components/schemas/Optional'
ClonedService_ListUsers_Request:
type: object
ClonedService_ListUsers_Response:
Expand Down Expand Up @@ -420,6 +500,8 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
Expand Down Expand Up @@ -456,6 +538,8 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
Expand Down Expand Up @@ -492,6 +576,8 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
Expand Down Expand Up @@ -528,6 +614,46 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
- $ref: '#/components/schemas/ErrorDatabaseDown'
/rpc/ExampleService/GetAllOptional:
post:
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ExampleService_GetAllOptional_Request'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ExampleService_GetAllOptional_Response'
'4XX':
description: Client error
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ErrorWebrpcEndpoint'
- $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
Expand Down Expand Up @@ -564,6 +690,8 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcBadRoute'
- $ref: '#/components/schemas/ErrorWebrpcBadMethod'
- $ref: '#/components/schemas/ErrorWebrpcBadRequest'
- $ref: '#/components/schemas/ErrorWebrpcClientDisconnected'
- $ref: '#/components/schemas/ErrorWebrpcStreamLost'
- $ref: '#/components/schemas/ErrorRateLimited'
'5XX':
description: Server error
Expand Down
5 changes: 5 additions & 0 deletions _examples/proto.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ struct ComplexType
- mapOfUsers: map<string,User>
- user: User

struct Optional
- name?: string
- email?: string

service ExampleService
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)
- FindUser(s: SearchFilter) => (name: string, user: User)
- ListUsers() => (users: []User)
- GetComplex() => (complex: ComplexType)
- GetAllOptional() => (optional: Optional)

service ClonedService
- ListUsers() => (users: []User)
Expand Down

0 comments on commit 7407f07

Please sign in to comment.