Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ diff:
git diff --color --ignore-all-space --ignore-blank-lines --exit-code .

swagger:
@echo "Swagger UI is available at http://localhost:8088"
@echo "\nSwagger UI is available at http://localhost:8088\n"
docker run -p 8088:8080 -v $$(pwd):/docs -e SWAGGER_JSON=/docs/openapi.gen.yaml swaggerapi/swagger-ui:v5.31.0
4 changes: 1 addition & 3 deletions _examples/openapi.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,6 @@ components:
type: object
ExampleService_GetAllOptional_Request:
type: object
ExampleService_StreamUserNotifications_Request:
type: object
ExampleService_Ping_Response:
type: object
ExampleService_GetUser_Response:
Expand Down Expand Up @@ -897,7 +895,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/ExampleService_StreamUserNotifications_Request'
type: object
responses:
'200':
description: OK
Expand Down
20 changes: 13 additions & 7 deletions main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ components:
{{- end -}}
{{- range $_, $service := $services}}
{{- range $i, $method := $service.Methods}}
{{- $isSuccinctInput := and $method.Succinct (eq (len $method.Inputs) 1) -}}
{{- $isSuccinctInput := $method.Succinct -}}
{{- if not $isSuccinctInput }}
{{$service.Name}}_{{$method.Name}}_Request:
type: object
Expand All @@ -120,7 +120,7 @@ components:
{{- end -}}
{{- end -}}
{{- range $_, $method := .Methods}}
{{- $isSuccinctOutput := and $method.Succinct (eq (len $method.Outputs) 1) -}}
{{- $isSuccinctOutput := $method.Succinct -}}
{{- if not $isSuccinctOutput }}
{{$service.Name}}_{{$method.Name}}_Response:
type: object
Expand All @@ -138,8 +138,8 @@ components:
paths:
{{- range $_, $service := .Services -}}
{{- range $_, $method := .Methods}}
{{- $isSuccinctInput := and $method.Succinct (eq (len $method.Inputs) 1) -}}
{{- $isSuccinctOutput := and $method.Succinct (eq (len $method.Outputs) 1) -}}
{{- $isSuccinctInput := $method.Succinct -}}
{{- $isSuccinctOutput := $method.Succinct -}}
{{- $deprecated := index $method.Annotations "deprecated" }}
/rpc/{{$service.Name}}/{{$method.Name}}:
post:
Expand Down Expand Up @@ -170,8 +170,10 @@ paths:
content:
application/json:
schema:
{{- if $isSuccinctInput }}
{{- if and $isSuccinctInput (eq (len $method.Inputs) 1) }}
{{ template "fieldType" dict "Type" (index $method.Inputs 0).Type "TypeMap" $typeMap "Indent" " " }}
{{- else if $isSuccinctInput }}
type: object
{{- else }}
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Request'
{{- end }}
Expand All @@ -182,16 +184,20 @@ paths:
{{- if eq $method.StreamOutput false }}
application/json:
schema:
{{- if $isSuccinctOutput }}
{{- if and $isSuccinctOutput (eq (len $method.Outputs) 1) }}
{{ template "fieldType" dict "Type" (index $method.Outputs 0).Type "TypeMap" $typeMap "Indent" " " }}
{{- else if $isSuccinctOutput }}
type: object
{{- else }}
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Response'
{{- end }}
{{- else }}
application/x-ndjson:
schema:
{{- if $isSuccinctOutput }}
{{- if and $isSuccinctOutput (eq (len $method.Outputs) 1) }}
{{ template "fieldType" dict "Type" (index $method.Outputs 0).Type "TypeMap" $typeMap "Indent" " " }}
{{- else if $isSuccinctOutput }}
type: object
{{- else }}
$ref: '#/components/schemas/{{$service.Name}}_{{$method.Name}}_Response'
{{- end }}
Expand Down