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

Broken code is generated when HTTP Response Header starts with digit

Open masu-mi opened this issue 3 years ago • 2 comments

I'm in trouble to generate code with following conditions.

  • HTTP response schema defined via reference($ref)
  • HTTP response has HTTP header starts with digits.

According to RFC7230, HTTP header can start with digit. ref. https://www.rfc-editor.org/rfc/rfc7230.html#section-3.2.6

reproduce example

go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --config=config.yaml spec.yaml
## spec.yaml
openapi: 3.0.2
info:
  version: "0.0.1"
paths:
  /foo:
    get:
      responses:
        200:
          $ref: "#/components/responses/200"
components:
  responses:
    "200":
      headers:
        "000-foo":
          schema:
            type: string
## config.yaml
package: head_digit_of_httpheader
generate:
  strict-server: true
output: issue.gen.go
output-options:
  skip-prune: true

masu-mi avatar Aug 29 '22 12:08 masu-mi

TIL this is a valid option - thanks for the fix! We'll try and get to reviewing the PRs you've raised shortly

jamietanna avatar Aug 30 '22 09:08 jamietanna

Thank you. I've confirmed resolved this.

masu-mi avatar Sep 12 '22 12:09 masu-mi