Skip to content

Commit de1742d

Browse files
authored
generate operation id (#25)
* generate operation id - operationId: combination of service name and method name to make it unique * use dash as separator between service and method name
1 parent 9e4d5e4 commit de1742d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

_examples/openapi.gen.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ components:
501501
paths:
502502
/rpc/ExampleService/Ping:
503503
post:
504+
operationId: ExampleService-Ping
504505
tags: ["ExampleService"]
505506
summary: "Deprecated."
506507
deprecated: true
@@ -542,6 +543,7 @@ paths:
542543
- $ref: '#/components/schemas/ErrorDatabaseDown'
543544
/rpc/ExampleService/GetUser:
544545
post:
546+
operationId: ExampleService-GetUser
545547
tags: ["ExampleService"]
546548
summary: "Deprecated: Use GetUserV2 instead."
547549
deprecated: true
@@ -585,6 +587,7 @@ paths:
585587
- $ref: '#/components/schemas/ErrorDatabaseDown'
586588
/rpc/ExampleService/GetUserV2:
587589
post:
590+
operationId: ExampleService-GetUserV2
588591
tags: ["ExampleService"]
589592
summary: "GetUserV2 returns user based on given userID."
590593
security:
@@ -629,6 +632,7 @@ paths:
629632
- $ref: '#/components/schemas/ErrorDatabaseDown'
630633
/rpc/ExampleService/FindUser:
631634
post:
635+
operationId: ExampleService-FindUser
632636
tags: ["ExampleService"]
633637
summary: "FindUser searches for a user using the given search filter."
634638
security:
@@ -676,6 +680,7 @@ paths:
676680
- $ref: '#/components/schemas/ErrorDatabaseDown'
677681
/rpc/ExampleService/ListUsers:
678682
post:
683+
operationId: ExampleService-ListUsers
679684
tags: ["ExampleService"]
680685
summary: "ListUsers returns all users."
681686
security:
@@ -718,6 +723,7 @@ paths:
718723
- $ref: '#/components/schemas/ErrorDatabaseDown'
719724
/rpc/ExampleService/GetComplex:
720725
post:
726+
operationId: ExampleService-GetComplex
721727
tags: ["ExampleService"]
722728
summary: ""
723729
requestBody:
@@ -758,6 +764,7 @@ paths:
758764
- $ref: '#/components/schemas/ErrorDatabaseDown'
759765
/rpc/ExampleService/GetAllOptional:
760766
post:
767+
operationId: ExampleService-GetAllOptional
761768
tags: ["ExampleService"]
762769
summary: ""
763770
requestBody:
@@ -798,6 +805,7 @@ paths:
798805
- $ref: '#/components/schemas/ErrorDatabaseDown'
799806
/rpc/AdminService/ListUsers:
800807
post:
808+
operationId: AdminService-ListUsers
801809
tags: ["AdminService"]
802810
summary: ""
803811
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)