Skip to content

Commit

Permalink
mark endpoint deprecated if there is such annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasJenicek committed Oct 7, 2024
1 parent 359a1b3 commit fa15abc
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
63 changes: 61 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 2b7f54ec87d95d472145c1e137844eb76a239e1f
# example v0.0.1 ebe5209e9238f02a045c540943d0298b747f5f03
# --
# Code generated by webrpc-gen@v0.15.1 with ../ generator; DO NOT EDIT
# Code generated by webrpc-gen@v0.20.1 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 @@ -420,6 +420,16 @@ components:
type: string
userID:
type: number
ExampleService_GetUserV2_Request:
type: object
properties:
header:
type: object
description: 'map<string,string>'
additionalProperties:
type: string
userID:
type: number
ExampleService_FindUser_Request:
type: object
properties:
Expand All @@ -438,6 +448,15 @@ components:
type: number
user:
$ref: '#/components/schemas/User'
ExampleService_GetUserV2_Response:
type: object
properties:
code:
type: number
user:
$ref: '#/components/schemas/User'
profilePicture:
type: string
ExampleService_FindUser_Response:
type: object
properties:
Expand Down Expand Up @@ -478,6 +497,7 @@ paths:
/rpc/ExampleService/GetUser:
post:
summary: GetUser
deprecated: true
requestBody:
content:
application/json:
Expand Down Expand Up @@ -514,6 +534,45 @@ paths:
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
- $ref: '#/components/schemas/ErrorDatabaseDown'
/rpc/ExampleService/GetUserV2:
post:
summary: GetUserV2
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ExampleService_GetUserV2_Request'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ExampleService_GetUserV2_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
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ErrorWebrpcBadResponse'
- $ref: '#/components/schemas/ErrorWebrpcServerPanic'
- $ref: '#/components/schemas/ErrorWebrpcInternalError'
- $ref: '#/components/schemas/ErrorDatabaseDown'
/rpc/ExampleService/FindUser:
post:
summary: FindUser
Expand Down
2 changes: 2 additions & 0 deletions _examples/proto.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ struct Optional
- email?: string

service ExampleService
@deprecated:GetUserV2
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)
- GetUserV2(header: map<string,string>, userID: uint64) => (code: uint32, user: User, profilePicture: string)
- FindUser(s: SearchFilter) => (name: string, user: User)
- ListUsers() => (users: []User)
- GetComplex() => (complex: ComplexType)
Expand Down
5 changes: 4 additions & 1 deletion main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ paths:
/rpc/{{$service.Name}}/{{$method.Name}}:
post:
summary: {{$method.Name}}
{{- if gt (len $method.Comments) 0 }}
{{- if (index $method.Annotations "deprecated") }}
deprecated: true
{{- end }}
{{- if gt (len $method.Comments) 0 }}
description: "{{ replaceAll (join $method.Comments "\n") "\"" "'" }}"
{{- end }}
requestBody:
Expand Down

0 comments on commit fa15abc

Please sign in to comment.