/
schema_paths.go
35 lines (27 loc) · 1022 Bytes
/
schema_paths.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package converter
import (
"fmt"
"strings"
)
func urlPath(microServiceName, protoServiceName, methodName string) string {
return fmt.Sprintf("/%s/%s/%s", microServiceName, protoServiceName, methodName)
}
func protoServiceName(inputType string) string {
protoServiceNameComponents := strings.Split(inputType, ".")
return protoServiceNameComponents[len(protoServiceNameComponents)-1]
}
func messageSchemaPath(schemaName string) string {
return fmt.Sprintf("#/components/schemas/%s", schemaName)
}
func requestBodyName(serviceName, methodName string) string {
return fmt.Sprintf("%s%sRequest", serviceName, methodName)
}
func requestBodySchemaPath(requestBodyName string) string {
return fmt.Sprintf("#/components/requestBodies/%s", requestBodyName)
}
func responseBodyName(serviceName, methodName string) string {
return fmt.Sprintf("%s%sResponse", serviceName, methodName)
}
func responseBodySchemaPath(responseBodyName string) string {
return fmt.Sprintf("#/components/responses/%s", responseBodyName)
}