Skip to content

Commit 84efc58

Browse files
committed
generate operation id
- operationId: combination of service name and method name to make it unique
1 parent 9e4d5e4 commit 84efc58

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

_examples/openapi.gen.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,10 @@ components:
497497
description: '[]User'
498498
items:
499499
$ref: '#/components/schemas/User'
500-
501500
paths:
502501
/rpc/ExampleService/Ping:
503502
post:
503+
operationId: ExampleServicePing
504504
tags: ["ExampleService"]
505505
summary: "Deprecated."
506506
deprecated: true
@@ -542,6 +542,7 @@ paths:
542542
- $ref: '#/components/schemas/ErrorDatabaseDown'
543543
/rpc/ExampleService/GetUser:
544544
post:
545+
operationId: ExampleServiceGetUser
545546
tags: ["ExampleService"]
546547
summary: "Deprecated: Use GetUserV2 instead."
547548
deprecated: true
@@ -585,6 +586,7 @@ paths:
585586
- $ref: '#/components/schemas/ErrorDatabaseDown'
586587
/rpc/ExampleService/GetUserV2:
587588
post:
589+
operationId: ExampleServiceGetUserV2
588590
tags: ["ExampleService"]
589591
summary: "GetUserV2 returns user based on given userID."
590592
security:
@@ -629,6 +631,7 @@ paths:
629631
- $ref: '#/components/schemas/ErrorDatabaseDown'
630632
/rpc/ExampleService/FindUser:
631633
post:
634+
operationId: ExampleServiceFindUser
632635
tags: ["ExampleService"]
633636
summary: "FindUser searches for a user using the given search filter."
634637
security:
@@ -676,6 +679,7 @@ paths:
676679
- $ref: '#/components/schemas/ErrorDatabaseDown'
677680
/rpc/ExampleService/ListUsers:
678681
post:
682+
operationId: ExampleServiceListUsers
679683
tags: ["ExampleService"]
680684
summary: "ListUsers returns all users."
681685
security:
@@ -718,6 +722,7 @@ paths:
718722
- $ref: '#/components/schemas/ErrorDatabaseDown'
719723
/rpc/ExampleService/GetComplex:
720724
post:
725+
operationId: ExampleServiceGetComplex
721726
tags: ["ExampleService"]
722727
summary: ""
723728
requestBody:
@@ -758,6 +763,7 @@ paths:
758763
- $ref: '#/components/schemas/ErrorDatabaseDown'
759764
/rpc/ExampleService/GetAllOptional:
760765
post:
766+
operationId: ExampleServiceGetAllOptional
761767
tags: ["ExampleService"]
762768
summary: ""
763769
requestBody:
@@ -798,6 +804,7 @@ paths:
798804
- $ref: '#/components/schemas/ErrorDatabaseDown'
799805
/rpc/AdminService/ListUsers:
800806
post:
807+
operationId: AdminServiceListUsers
801808
tags: ["AdminService"]
802809
summary: ""
803810
security:

main.go.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ paths:
134134
{{- $deprecated := index $method.Annotations "deprecated" }}
135135
/rpc/{{$service.Name}}/{{$method.Name}}:
136136
post:
137+
operationId: {{$service.Name}}{{$method.Name}}
137138
tags: ["{{$service.Name}}"]
138139
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}}
139140
{{- if $deprecated }}

0 commit comments

Comments
 (0)