Skip to content

bug: generated server code for chi is not working #1130

@sarathsp06

Description

@sarathsp06

When the response is of type text/plain generated server code is trying to convert to []byte while the response object is a struct

ForbiddenError:
      description: Access token is valid but does not have the required scope
      content:
        text/plain:
          schema:
            type: string
            example: Forbidden

generated code

type GetAccounts403TextResponse struct{ ForbiddenErrorTextResponse }

func (response GetAccounts403TextResponse) VisitGetAccountsResponse(w http.ResponseWriter) error {
	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(403)

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

_, err := w.Write([]byte(response)) fails at compile time

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions