Skip to content

Cannot convert text/plain uuid in requestBody to string #1914

@codeout

Description

@codeout

Hello, oapi-codegen generates an invalid code when I define requestBody as text/plain uuid.

Image

I would appreciate it if you could advise me on how to fix this.

How to reproduce

$ cat > openapi.yaml <<EOS
openapi: 3.0.3
paths:
  /pet:
    post:
      requestBody:
        content:
          text/plain:
            schema:
              type: string
              format: uuid
EOS

$ go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest openapi.yaml > gen.go
$ go mod init openapi
$ go mod tidy

$ go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run

output:

gen.go:1: : # gen
./gen.go:135:40: cannot convert body (variable of array type PostPetTextRequestBody) to type string (typecheck)
// Package openapi provides primitives to interact with the openapi HTTP API.
exit status 1

Lastly, thank you for maintaining such a great tool. Really appreciate it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions