Skip to content

Commit 44bc971

Browse files
authored
Escape quotes & improve endpoint summary/description (#23)
1 parent 04de19b commit 44bc971

3 files changed

Lines changed: 29 additions & 28 deletions

File tree

_examples/openapi.gen.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# example v0.0.1 ee5a444237d744dbda91bc77751f0b0d698e7502
1+
# example v0.0.1 9814b024890e4f9bf0fb6406686c29bcc402b24a
22
# --
33
# Code generated by webrpc-gen@v0.25.0 with ../ generator; DO NOT EDIT
44
#
@@ -587,7 +587,6 @@ paths:
587587
security:
588588
- JWT: []
589589
description: |
590-
591590
Replaces GetUser endpoint.
592591
requestBody:
593592
content:
@@ -633,6 +632,8 @@ paths:
633632
description: |
634633
635634
The filters are q (string) and active (bool).
635+
636+
The minimal length of the "q" filter is 3 characters.
636637
requestBody:
637638
content:
638639
application/json:

_examples/proto.ridl

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
webrpc = v1 # version of webrpc schema format (ridl or json)
1+
webrpc = v1 # version of webrpc schema format (ridl or json)
22

3-
name = example # name of your backend app
4-
version = v0.0.1 # version of your schema
3+
name = example # name of your backend app
4+
version = v0.0.1 # version of your schema
55

66
enum Kind: uint32
77
- USER
@@ -45,35 +45,37 @@ struct Optional
4545
- email?: string
4646

4747
service ExampleService
48-
@deprecated
48+
@deprecated
4949
- Ping()
50-
51-
@deprecated:"Use GetUserV2 instead."
52-
@auth:JWT
50+
51+
@deprecated:"Use GetUserV2 instead."
52+
@auth:JWT
5353
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)
54-
55-
# GetUserV2 returns user based on given userID.
56-
#
57-
# Replaces GetUser endpoint.
58-
@auth:JWT
54+
55+
# GetUserV2 returns user based on given userID.
56+
# Replaces GetUser endpoint.
57+
@auth:JWT
5958
- GetUserV2(header: map<string,string>, userID: uint64) => (code: uint32, user: User, profilePicture: string)
6059

61-
# FindUser searches for a user using the given search filter.
62-
#
63-
# The filters are q (string) and active (bool).
64-
@auth:JWT
60+
# FindUser searches for a user using the given search filter.
61+
#
62+
# The filters are q (string) and active (bool).
63+
#
64+
# The minimal length of the "q" filter is 3 characters.
65+
@auth:JWT
6566
- FindUser(s: SearchFilter) => (name: string, user: User)
6667

67-
# ListUsers returns all users.
68-
@auth:JWT
68+
# ListUsers returns all users.
69+
@auth:JWT
6970
- ListUsers() => (users: []User)
7071

71-
- GetComplex() => (complex: ComplexType)
72+
- GetComplex() => (complex: ComplexType)
7273
- GetAllOptional() => (optional: Optional)
7374

7475
service AdminService
75-
@auth:JWT
76+
@auth:JWT
7677
- ListUsers() => (users: []User)
7778

78-
error 100 RateLimited "too many requests" HTTP 429
79-
error 101 DatabaseDown "service outage" HTTP 503
79+
error 100 RateLimited "too many requests" HTTP 429
80+
error 101 DatabaseDown "service outage" HTTP 503
81+

main.go.tmpl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ paths:
134134
{{- $deprecated := index $method.Annotations "deprecated" }}
135135
/rpc/{{$service.Name}}/{{$method.Name}}:
136136
post:
137-
summary: "{{ if $deprecated }}{{ if $deprecated.Value }}Deprecated: {{$deprecated.Value}}{{else}}Deprecated.{{end}}{{else if gt (len $method.Comments) 0}}{{index $method.Comments 0}}{{end}}"
137+
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}}
138138
{{- if $deprecated }}
139139
deprecated: true
140140
{{- end }}
@@ -151,11 +151,9 @@ paths:
151151
{{- end }}
152152
{{- if gt (len $method.Comments) 1 }}
153153
description: |
154-
{{- range $i, $comment := $method.Comments }}
155-
{{- if gt $i 0 }}
154+
{{- range $i, $comment := (slice $method.Comments 1) }}
156155
{{$comment}}
157156
{{- end }}
158-
{{- end }}
159157
{{- end }}
160158
requestBody:
161159
content:

0 commit comments

Comments
 (0)