diff --git a/_examples/openapi.gen.yaml b/_examples/openapi.gen.yaml index 36539c1..7d1eaf9 100644 --- a/_examples/openapi.gen.yaml +++ b/_examples/openapi.gen.yaml @@ -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 @@ -420,6 +420,16 @@ components: type: string userID: type: number + ExampleService_GetUserV2_Request: + type: object + properties: + header: + type: object + description: 'map' + additionalProperties: + type: string + userID: + type: number ExampleService_FindUser_Request: type: object properties: @@ -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: @@ -478,6 +497,7 @@ paths: /rpc/ExampleService/GetUser: post: summary: GetUser + deprecated: true requestBody: content: application/json: @@ -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 diff --git a/_examples/proto.ridl b/_examples/proto.ridl index d26a1fe..1862913 100644 --- a/_examples/proto.ridl +++ b/_examples/proto.ridl @@ -45,7 +45,9 @@ struct Optional - email?: string service ExampleService + @deprecated:GetUserV2 - GetUser(header: map, userID: uint64) => (code: uint32, user: User) + - GetUserV2(header: map, userID: uint64) => (code: uint32, user: User, profilePicture: string) - FindUser(s: SearchFilter) => (name: string, user: User) - ListUsers() => (users: []User) - GetComplex() => (complex: ComplexType) diff --git a/main.go.tmpl b/main.go.tmpl index acd0d1c..aa84e82 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -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: