Skip to content

Broken code is generated when HTTP Response Header starts with digit #732

@masu-mi

Description

@masu-mi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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