From 1e8929527b803352a56d45e39389bf57d7d022bb Mon Sep 17 00:00:00 2001 From: Lukas Jenicek Date: Mon, 18 Mar 2024 15:45:14 +0100 Subject: [PATCH] use method name as summary and comments as description --- _examples/openapi.gen.yaml | 8 +++++++- main.go.tmpl | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/_examples/openapi.gen.yaml b/_examples/openapi.gen.yaml index 1aa7c5b..36539c1 100644 --- a/_examples/openapi.gen.yaml +++ b/_examples/openapi.gen.yaml @@ -477,6 +477,7 @@ components: paths: /rpc/ExampleService/GetUser: post: + summary: GetUser requestBody: content: application/json: @@ -515,6 +516,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/FindUser: post: + summary: FindUser requestBody: content: application/json: @@ -553,6 +555,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/ListUsers: post: + summary: ListUsers requestBody: content: application/json: @@ -591,6 +594,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetComplex: post: + summary: GetComplex requestBody: content: application/json: @@ -629,6 +633,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetAllOptional: post: + summary: GetAllOptional requestBody: content: application/json: @@ -667,6 +672,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ClonedService/ListUsers: post: + summary: ListUsers requestBody: content: application/json: @@ -702,4 +708,4 @@ paths: - $ref: '#/components/schemas/ErrorWebrpcBadResponse' - $ref: '#/components/schemas/ErrorWebrpcServerPanic' - $ref: '#/components/schemas/ErrorWebrpcInternalError' - - $ref: '#/components/schemas/ErrorDatabaseDown' + - $ref: '#/components/schemas/ErrorDatabaseDown' \ No newline at end of file diff --git a/main.go.tmpl b/main.go.tmpl index 820764d..acd0d1c 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -128,8 +128,9 @@ paths: {{- range $_, $method := .Methods}} /rpc/{{$service.Name}}/{{$method.Name}}: post: + summary: {{$method.Name}} {{- if gt (len $method.Comments) 0 }} - summary: "{{ replaceAll (join $method.Comments "\n") "\"" "'" }}" + description: "{{ replaceAll (join $method.Comments "\n") "\"" "'" }}" {{- end }} requestBody: content: