Skip to content

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

Closed

Description

@wndhydrnt

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

Activity

  1. wndhydrnt commented on Nov 27, 2025

    @wndhydrnt
    ContributorAuthor

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

    I found yaml/go-yaml#76 in the issue tracker of its successor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions