Skip to content

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

Closed

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

Activity

  1. changed the title [-]generated server code for chi is not working[/-] [+]bug: generated server code for chi is not working[/+] on Jun 29, 2023
  2. jamietanna commented on Jun 29, 2023

    @jamietanna
    Member

    Hey, can you please share a minimal example? This doesn't seem quite right - I can see a text/plain response of type: string, so am not sure where we're getting this struct generated from?

    It'd be super helpful to see whether this is a strict server or just chi.

  3. added
    question
    on Jun 29, 2023
  4. sarathsp06 commented on Jun 29, 2023

    @sarathsp06
    ContributorAuthor

    @jamietanna thanks for the message

    It is strict server for chi

  5. sarathsp06 commented on Jul 8, 2023

    @sarathsp06
    ContributorAuthor

    @jamietanna could you please check

  6. jamietanna commented on Jul 31, 2023

    @jamietanna
    Member

    Hey @sarathsp06 should this now be fixed due to #1132 being merged?

  7. sarathsp06 commented on Jul 31, 2023

    @sarathsp06
    ContributorAuthor

    @jamietanna yes , i shall close it as it is fixed. Tested and confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting replyquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions