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

fiber-server generate incorrect type for header value

Open turbo-nyasha opened this issue 1 year ago • 1 comments

Hi!👋🏻 Current template for fiber-server has incorrect type for header values, because HTTP Spec allow sending multiple http headers with the same name, like Set-Cookie header.

Need to change template for generate correct compiled code.

Generated code by template:

headers := c.GetReqHeaders() //map[string][]string type
...
if value, found := headers[http.CanonicalHeaderKey("x-app-version")]; found { // value has []string type
		var XAppVersion ApplicationVersion
                // value bust be string
		err = runtime.BindStyledParameterWithOptions("simple", "x-app-version", value, &XAppVersion, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: true})
		if err != nil {
			return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter x-app-version: %w", err).Error())
		}

		params.XAppVersion = XAppVersion

	} else {
		err = fmt.Errorf("Header parameter x-app-version is required, but not found: %w", err)
		return fiber.NewError(fiber.StatusBadRequest, err.Error())
	}

turbo-nyasha avatar Oct 18 '24 08:10 turbo-nyasha

This problem appeared after fiber release 2.50.0 when API for GetRequestHeaders() was changed. Please merge my changes for hassle-free quick start using oapi with latest fiber version. Thanks!

turbo-nyasha avatar Oct 18 '24 14:10 turbo-nyasha

Waiting for that too!

Tualua avatar Oct 24 '24 04:10 Tualua

Looks like dead repository...

turbo-nyasha avatar Oct 28 '24 19:10 turbo-nyasha

Waiting for that too!!!!

lNikazzzl avatar Dec 04 '24 23:12 lNikazzzl

+1

erendogan51 avatar Jan 13 '25 09:01 erendogan51

Any news?

Tualua avatar Feb 09 '25 13:02 Tualua

Hey @turbo-nyasha is this "completed" because it's been fixed through some other means?

jamietanna avatar May 19 '25 19:05 jamietanna

@jamietanna I assume that it was closed because the author was just tired of waiting for news, and that there is another, similar problem that is already being solved. Please pay attention on it https://github.com/oapi-codegen/oapi-codegen/pull/1639

seth2810 avatar May 23 '25 07:05 seth2810