Skip to content

Commit 0d3cf1e

Browse files
authored
Remove unused definition of wrapper req/resp objects in succinct mode (#29)
1 parent bb95e0e commit 0d3cf1e

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

_examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ diff:
3636
git diff --color --ignore-all-space --ignore-blank-lines --exit-code .
3737

3838
swagger:
39-
@echo "Swagger UI is available at http://localhost:8088"
39+
@echo "\nSwagger UI is available at http://localhost:8088\n"
4040
docker run -p 8088:8080 -v $$(pwd):/docs -e SWAGGER_JSON=/docs/openapi.gen.yaml swaggerapi/swagger-ui:v5.31.0

_examples/openapi.gen.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,6 @@ components:
523523
type: object
524524
ExampleService_GetAllOptional_Request:
525525
type: object
526-
ExampleService_StreamUserNotifications_Request:
527-
type: object
528526
ExampleService_Ping_Response:
529527
type: object
530528
ExampleService_GetUser_Response:
@@ -897,7 +895,7 @@ paths:
897895
content:
898896
application/json:
899897
schema:
900-
$ref: '#/components/schemas/ExampleService_StreamUserNotifications_Request'
898+
type: object
901899
responses:
902900
'200':
903901
description: OK

main.go.tmpl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ components:
106106
{{- end -}}
107107
{{- range $_, $service := $services}}
108108
{{- range $i, $method := $service.Methods}}
109-
{{- $isSuccinctInput := and $method.Succinct (eq (len $method.Inputs) 1) -}}
109+
{{- $isSuccinctInput := $method.Succinct -}}
110110
{{- if not $isSuccinctInput }}
111111
{{$service.Name}}_{{$method.Name}}_Request:
112112
type: object
@@ -120,7 +120,7 @@ components:
120120
{{- end -}}
121121
{{- end -}}
122122
{{- range $_, $method := .Methods}}
123-
{{- $isSuccinctOutput := and $method.Succinct (eq (len $method.Outputs) 1) -}}
123+
{{- $isSuccinctOutput := $method.Succinct -}}
124124
{{- if not $isSuccinctOutput }}
125125
{{$service.Name}}_{{$method.Name}}_Response:
126126
type: object
@@ -138,8 +138,8 @@ components:
138138
paths:
139139
{{- range $_, $service := .Services -}}
140140
{{- range $_, $method := .Methods}}
141-
{{- $isSuccinctInput := and $method.Succinct (eq (len $method.Inputs) 1) -}}
142-
{{- $isSuccinctOutput := and $method.Succinct (eq (len $method.Outputs) 1) -}}
141+
{{- $isSuccinctInput := $method.Succinct -}}
142+
{{- $isSuccinctOutput := $method.Succinct -}}
143143
{{- $deprecated := index $method.Annotations "deprecated" }}
144144
/rpc/{{$service.Name}}/{{$method.Name}}:
145145
post:
@@ -170,8 +170,10 @@ paths:
170170
content:
171171
application/json:
172172
schema:
173-
{{- if $isSuccinctInput }}
173+
{{- if and $isSuccinctInput (eq (len $method.Inputs) 1) }}
174174
{{ template "fieldType" dict "Type" (index $method.Inputs 0).Type "TypeMap" $typeMap "Indent" " " }}
175+
{{- else if $isSuccinctInput }}
176+
type: object
175177
{{- else }}
176178
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Request'
177179
{{- end }}
@@ -182,16 +184,20 @@ paths:
182184
{{- if eq $method.StreamOutput false }}
183185
application/json:
184186
schema:
185-
{{- if $isSuccinctOutput }}
187+
{{- if and $isSuccinctOutput (eq (len $method.Outputs) 1) }}
186188
{{ template "fieldType" dict "Type" (index $method.Outputs 0).Type "TypeMap" $typeMap "Indent" " " }}
189+
{{- else if $isSuccinctOutput }}
190+
type: object
187191
{{- else }}
188192
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Response'
189193
{{- end }}
190194
{{- else }}
191195
application/x-ndjson:
192196
schema:
193-
{{- if $isSuccinctOutput }}
197+
{{- if and $isSuccinctOutput (eq (len $method.Outputs) 1) }}
194198
{{ template "fieldType" dict "Type" (index $method.Outputs 0).Type "TypeMap" $typeMap "Indent" " " }}
199+
{{- else if $isSuccinctOutput }}
200+
type: object
195201
{{- else }}
196202
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Response'
197203
{{- end }}

0 commit comments

Comments
 (0)