Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.32.3/webrpc-gen.linux-amd64
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.37.0/webrpc-gen.linux-amd64
chmod +x ./webrpc-gen
echo $PWD >> $GITHUB_PATH

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/notify-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Notify main repo

on:
push:
tags:
- "v*"

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Dispatch to webrpc/webrpc
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GH_TOKEN_GIT_COMMIT }}
repository: webrpc/webrpc
event-type: generator-updated
client-payload: '{"generator": "gen-openapi", "version": "${{ github.ref_name }}"}'
5 changes: 3 additions & 2 deletions _examples/api.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ service ExampleService
- GetComplex() => (complex: ComplexType)
- GetAllOptional() => (optional: Optional)

- StreamUserNotifications() => stream (StreamNotificationsResponse)

service ExampleService2
@deprecated
- Ping()
Expand Down Expand Up @@ -64,6 +62,9 @@ error 100 RateLimited "too many requests" HTTP 429
error 101 DatabaseDown "service outage" HTTP 503


type Username: string
type Age: uint32

enum Kind: uint32
- USER
- ADMIN
Expand Down
54 changes: 8 additions & 46 deletions _examples/openapi.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# example v1.0.0 78160f3365e4f91df80f171a445efde0a288026e
# example v1.0.0 ceb35c0c54325918ffdd24bf625bb6c8c941f75e
# --
# Code generated by webrpc-gen@v0.32.3 with ../ generator; DO NOT EDIT
# Code generated by webrpc-gen@v0.37.0 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
Expand Down Expand Up @@ -299,6 +299,12 @@ components:
status:
type: number
example: 503
Username:
type: string

Age:
type: number

Kind:
type: string
description: Represented as uint32 on the server side
Expand Down Expand Up @@ -886,50 +892,6 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
- $ref: '#/components/schemas/ErrorDatabaseDown'
/v1/ExampleService/StreamUserNotifications:
post:
operationId: ExampleService-StreamUserNotifications
tags: ["ExampleService"]
summary: ""
requestBody:
content:
application/json:
schema:
type: object
responses:
'200':
description: OK
content:
application/x-ndjson:
schema:
$ref: '#/components/schemas/StreamNotificationsResponse'
# OpenAPI 3.2.0 streaming (itemSchema) is not supported by 3.1.0 tooling:
# itemSchema:
# $ref: '#/components/schemas/ExampleService_StreamUserNotifications_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/ErrorWebrpcClientAborted'
- $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'
/v1/ExampleService2/Ping:
post:
operationId: ExampleService2-Ping
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/webrpc/gen-openapi

go 1.16
go 1.23.12
Empty file added go.sum
Empty file.
2 changes: 2 additions & 0 deletions type.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
{{- range $type.Fields}}
- {{.Name}}
{{- end -}}
{{- else if isAliasType $type}}
{{ template "fieldType" dict "Type" $type.Type "TypeMap" $typeMap "Indent" " " }}
{{else}}
type: object
{{- if gt (len $type.Fields) 0}}
Expand Down
Loading