oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Strict server generates error for text/plain response types

Open mtandersson opened this issue 4 months ago • 0 comments

When generating strict server using version 2.5.0 and respons type of text/plain the generated code looks something like this (for echo):

type InternalServerErrorTextResponse string

type DeleteRequest500TextResponse struct {
	InternalServerErrorTextResponse
}

func (response DeleteRequest500TextResponse) VisitDeleteRequestResponse(w http.ResponseWriter) error {
	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(500)

	_, err := w.Write([]byte(response))
	return err
}

This does not compile with an error cannot convert response (variable of struct type DeleteRequest500TextResponse) to type []byte

mtandersson avatar Sep 04 '25 09:09 mtandersson