Title: Cannot use 'value' (type []string) as the type string · Issue #2103 · oapi-codegen/oapi-codegen · GitHub
Open Graph Title: Cannot use 'value' (type []string) as the type string · Issue #2103 · oapi-codegen/oapi-codegen
X Title: Cannot use 'value' (type []string) as the type string · Issue #2103 · oapi-codegen/oapi-codegen
Description: Error: Cannot use 'value' (type []string) as the type string The Problem is that the generated code line: if value, found := headers[http.CanonicalHeaderKey("Authorization")]; found { The value is the wrong type. yml: /upload: post: summ...
Open Graph Description: Error: Cannot use 'value' (type []string) as the type string The Problem is that the generated code line: if value, found := headers[http.CanonicalHeaderKey("Authorization")]; found { The value is ...
X Description: Error: Cannot use 'value' (type []string) as the type string The Problem is that the generated code line: if value, found := headers[http.CanonicalHeaderKey("Authorization")]; fou...
Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/2103
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot use 'value' (type []string) as the type string","articleBody":"Error:\nCannot use 'value' (type []string) as the type string\n\nThe Problem is that the generated code line:\n\n`if value, found := headers[http.CanonicalHeaderKey(\"Authorization\")]; found {`\n\nThe value is the **wrong type**.\n\n\n**yml:**\n\n``` \n/upload:\n post:\n summary: Direct storage upload\n description: \u003e-\n Uploads an image.\n operationId: postDirectUpload\n tags:\n - Upload\n servers:\n - url: http://localhost:8080/api/internal\n description: Internal storage upload server (development)\n security:\n - UploadTokenAuth: []\n parameters:\n - name: Authorization\n in: header\n description: \"Bearer \u003cUPLOAD_TOKEN\u003e. Alternative: submit as multipart field 'token'\"\n required: false\n schema:\n type: string\n requestBody:\n required: true\n content:\n multipart/form-data:\n schema:\n type: object\n properties:\n file:\n type: string\n format: binary\n token:\n type: string\n description: \"Alternative to Authorization header: pass upload token as multipart field\"\n required: [file]\n responses:\n '200':\n description: Upload accepted\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/StorageUploadResponse'\n '400': { $ref: '#/components/responses/BadRequest' }\n '401': { $ref: '#/components/responses/Unauthorized' }\n '413': { $ref: '#/components/responses/PayloadTooLarge' }\n '415': { $ref: '#/components/responses/UnsupportedMediaType' }\n '429': { $ref: '#/components/responses/TooManyRequests' }\n '500': { $ref: '#/components/responses/InternalError' }\n\n```\n\n**Generated Code:**\n\n`// PostDirectUpload operation middleware\nfunc (siw *ServerInterfaceWrapper) PostDirectUpload(c *fiber.Ctx) error {\n\n\tvar err error\n\n\tc.Context().SetUserValue(UploadTokenAuthScopes, []string{})\n\n\t// Parameter object where we will unmarshal all parameters from the context\n\tvar params PostDirectUploadParams\n\n\theaders := c.GetReqHeaders()\n\n\t// ------------- Optional header parameter \"Authorization\" -------------\n\tif value, found := headers[http.CanonicalHeaderKey(\"Authorization\")]; found {\n\t\tvar Authorization string\n\n\t\terr = runtime.BindStyledParameterWithOptions(\"simple\", \"Authorization\", value, \u0026Authorization, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false})\n\t\tif err != nil {\n\t\t\treturn fiber.NewError(fiber.StatusBadRequest, fmt.Errorf(\"Invalid format for parameter Authorization: %w\", err).Error())\n\t\t}\n\n\t\tparams.Authorization = \u0026Authorization\n\n\t}\n\n\treturn siw.Handler.PostDirectUpload(c, params)\n}`","author":{"url":"https://github.com/ManuelReschke","@type":"Person","name":"ManuelReschke"},"datePublished":"2025-09-27T09:38:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2103/oapi-codegen/issues/2103"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c2ae6fcb-0ca9-ef92-e6b6-78bb8c3471c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C6A8:66920:201F46C:2B752C3:6992F130 |
| html-safe-nonce | c638ecb195b9367ebe0befb2ec62e226e6216bdfc702835d797ecabe68001c11 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkE4OjY2OTIwOjIwMUY0NkM6MkI3NTJDMzo2OTkyRjEzMCIsInZpc2l0b3JfaWQiOiI4NDgyMDk1OTQwNzIyOTQ2MzUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9eec688d78db2485a7e8518f0e999ef1d20141b202fe1518f27d4475c397e798 |
| hovercard-subject-tag | issue:3460051430 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/oapi-codegen/oapi-codegen/2103/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dedbfba1b734b787f8a754a5410fcaf9b6a819f8ce3425ca1238c4aae889a697/oapi-codegen/oapi-codegen/issues/2103 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dedbfba1b734b787f8a754a5410fcaf9b6a819f8ce3425ca1238c4aae889a697/oapi-codegen/oapi-codegen/issues/2103 |
| og:image:alt | Error: Cannot use 'value' (type []string) as the type string The Problem is that the generated code line: if value, found := headers[http.CanonicalHeaderKey("Authorization")]; found { The value is ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ManuelReschke |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01ab16879a3159e6f0717ab948b9b562e162a6aafd1f4393b786b07b747df244 |
| turbo-cache-control | no-preview |
| go-import | github.com/oapi-codegen/oapi-codegen git https://github.com/oapi-codegen/oapi-codegen.git |
| octolytics-dimension-user_id | 142752710 |
| octolytics-dimension-user_login | oapi-codegen |
| octolytics-dimension-repository_id | 173009358 |
| octolytics-dimension-repository_nwo | oapi-codegen/oapi-codegen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 173009358 |
| octolytics-dimension-repository_network_root_nwo | oapi-codegen/oapi-codegen |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b1570f3928bef80fa5fc7890ce0942e9b696ad9d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width