Skip to content
Closed
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
6 changes: 6 additions & 0 deletions internal/test/issues/issue-1914/cfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# yaml-language-server: $schema=../../../../configuration-schema.json
package: issue1914
output: client.gen.go
generate:
client: true
models: true
263 changes: 263 additions & 0 deletions internal/test/issues/issue-1914/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions internal/test/issues/issue-1914/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package issue1914

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=cfg.yaml spec.yaml
11 changes: 11 additions & 0 deletions internal/test/issues/issue-1914/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
openapi: 3.0.3
paths:
/pet:
post:
description: Ensure that the `text/plain` format correctly handles coercing a UUID type to a string.
requestBody:
content:
text/plain:
schema:
type: string
format: uuid
2 changes: 2 additions & 0 deletions pkg/codegen/templates/client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ func New{{$opid}}Request{{.Suffix}}(server string{{genParamArgs $pathParams}}{{i
return nil, err
}
bodyReader = strings.NewReader(bodyStr.Encode())
{{else if and (eq .NameTag "Text") (eq .Schema.OAPISchema.Format "uuid") -}}
bodyReader = strings.NewReader(body.String())
{{else if eq .NameTag "Text" -}}
bodyReader = strings.NewReader(string(body))
{{end -}}
Expand Down