From d4061131878c5157d678829552e5ad3375865863 Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Wed, 26 Mar 2025 12:48:41 +0100 Subject: [PATCH] Group service endpoints by OpenAPI tags --- _examples/Makefile | 2 +- _examples/openapi.gen.yaml | 8 ++++++++ main.go.tmpl | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/_examples/Makefile b/_examples/Makefile index 2ea37e5..f24c475 100644 --- a/_examples/Makefile +++ b/_examples/Makefile @@ -36,5 +36,5 @@ diff: git diff --color --ignore-all-space --ignore-blank-lines --exit-code . swagger: - echo "http://localhost:8088" + @echo "Swagger UI is available at http://localhost:8088" docker run -p 8088:8080 -v $$(pwd):/docs -e SWAGGER_JSON=/docs/openapi.gen.yaml swaggerapi/swagger-ui diff --git a/_examples/openapi.gen.yaml b/_examples/openapi.gen.yaml index 4e00da3..430ae6d 100644 --- a/_examples/openapi.gen.yaml +++ b/_examples/openapi.gen.yaml @@ -501,6 +501,7 @@ components: paths: /rpc/ExampleService/Ping: post: + tags: ["ExampleService"] summary: "Deprecated." deprecated: true requestBody: @@ -541,6 +542,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetUser: post: + tags: ["ExampleService"] summary: "Deprecated: Use GetUserV2 instead." deprecated: true security: @@ -583,6 +585,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetUserV2: post: + tags: ["ExampleService"] summary: "GetUserV2 returns user based on given userID." security: - JWT: [] @@ -626,6 +629,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/FindUser: post: + tags: ["ExampleService"] summary: "FindUser searches for a user using the given search filter." security: - JWT: [] @@ -672,6 +676,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/ListUsers: post: + tags: ["ExampleService"] summary: "ListUsers returns all users." security: - JWT: [] @@ -713,6 +718,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetComplex: post: + tags: ["ExampleService"] summary: "" requestBody: content: @@ -752,6 +758,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/ExampleService/GetAllOptional: post: + tags: ["ExampleService"] summary: "" requestBody: content: @@ -791,6 +798,7 @@ paths: - $ref: '#/components/schemas/ErrorDatabaseDown' /rpc/AdminService/ListUsers: post: + tags: ["AdminService"] summary: "" security: - JWT: [] diff --git a/main.go.tmpl b/main.go.tmpl index 1485571..7aa1939 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -134,6 +134,7 @@ paths: {{- $deprecated := index $method.Annotations "deprecated" }} /rpc/{{$service.Name}}/{{$method.Name}}: post: + tags: ["{{$service.Name}}"] summary: {{ if $deprecated }}{{ if $deprecated.Value }}{{printf "%q" (print "Deprecated: " $deprecated.Value)}}{{else}}"Deprecated."{{end}}{{else if gt (len $method.Comments) 0}}{{printf "%q" (index $method.Comments 0)}}{{else}}""{{end}} {{- if $deprecated }} deprecated: true