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

Modifying via overlay fails if an array item contains a field that starts with a newline

Open wndhydrnt opened this issue 3 months ago • 1 comments

How to reproduce:

Create the following files in a directory.

openapi.yaml
# openapi.yaml
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Generate models
paths:
  /client:
    get:
      operationId: getClient
      parameters:
        - description: "\nThis line causes the issue\n"
          name: example
          in: query
          schema:
            type: string
      responses:
        200:
          description: "This is fine"
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientType"
components:
  schemas:
    ClientType:
      type: object
      required:
        - name
      properties:
        name:
          type: string
oapi-codegen.yaml
# oapi-codegen.yaml
package: client
output: openapi.gen.go
generate:
  models: true
  client: true
output-options:
  overlay:
    path: overlay.yaml
overlay.yaml
# overlay.yaml
overlay: 1.0.0

info:
  title: Overlay
  version: 0.0.0

actions:
  - target: "$"
    update:
      info:
        x-overlay-applied: structured-overlay

Execute oapi-codegen:

oapi-codegen -config oapi-codegen.yaml openapi.yaml

Result:

error loading swagger spec in openapi.yaml
: failed to parse spec from "openapi.yaml": yaml: line 18: did not find expected key
exit status 1

wndhydrnt avatar Nov 27 '25 16:11 wndhydrnt

This is likely an issue in gopkg.in/yaml.v3. That library isn't maintained anymore.

I found https://github.com/yaml/go-yaml/issues/76 in the issue tracker of its successor.

wndhydrnt avatar Nov 27 '25 16:11 wndhydrnt