Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Conversation

@danielkov
Copy link

Copy action for Overlay Specification v1.1.0

Adds support for the copy action from Overlay Specification v1.1.0, enabling node duplication and move operations within OpenAPI documents.

Changes

  • New functionality: copy field in Action schema allows copying nodes via JSONPath source selector
  • Precedence: actions processed as remove > update > copy (copy ignored when remove=true or update exists)
  • Move pattern: combine copy + remove actions to move nodes
  • Validation: strict mode enforces single-match source selector and existing source/target paths
  • Deep copy: cloned nodes prevent reference issues; merges into existing targets

Example

overlay: 1.1.0
x-speakeasy-jsonpath: rfc9535
info:
  title: Version Header Overlay
  version: 1.0.0
actions:
  # First, add X-API-Version header to each operation response
  - target: $.paths.*.*.responses.*
    description: Add X-API-Version header to all responses
    update:
      headers:
        XAPIVersion:
          schema:
            type: string
            const: ""
  # Then, copy the spec version into each X-API-Version header value
  - target: $.paths.*.*.responses.*.headers.XAPIVersion.schema.const
    description: Copy spec version to X-API-Version header const value
    copy: $.info.version

Overlay

openapi: 3.1.0
info:
  title: Version Header Test API
  version: 2.5.0
  description: API for testing version header copy
paths:
  /users:
    get:
      operationId: getUsers
      summary: Get users
      responses:
        '200':
          description: Successful response
    post:
      operationId: createUser
      summary: Create user
      responses:
        '201':
          description: Created
  /orders:
    get:
      operationId: getOrders
      summary: Get orders
      responses:
        '200':
          description: Successful response

Spec

openapi: 3.1.0
info:
  title: Version Header Test API
  version: 2.5.0
  description: API for testing version header copy
paths:
  /users:
    get:
      operationId: getUsers
      summary: Get users
      responses:
        '200':
          description: Successful response
          headers:
            XAPIVersion:
              schema:
                type: string
                const: "2.5.0"
    post:
      operationId: createUser
      summary: Create user
      responses:
        '201':
          description: Created
          headers:
            XAPIVersion:
              schema:
                type: string
                const: "2.5.0"
  /orders:
    get:
      operationId: getOrders
      summary: Get orders
      responses:
        '200':
          description: Successful response
          headers:
            XAPIVersion:
              schema:
                type: string
                const: "2.5.0"

Result

@danielkov danielkov marked this pull request as ready for review December 8, 2025 22:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant