Skip to content

Conversation

@danielkov
Copy link
Contributor

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 requested a review from a team as a code owner December 8, 2025 23:15
Copy link
Member

@TristanSpeakEasy TristanSpeakEasy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the CI pipeline passes

@danielkov danielkov merged commit c8a6018 into main Dec 8, 2025
10 checks passed
@danielkov danielkov deleted the danielkov/feat-implement-copy branch December 8, 2025 23:28
danielkov added a commit to speakeasy-api/speakeasy that referenced this pull request Dec 10, 2025
## `openapi`

- [Add support for 3.2.0 openapi
spec](speakeasy-api/openapi#54)
- [Overlay support copy
action](speakeasy-api/openapi#87)
- [Support overlay version
1.1.0](speakeasy-api/openapi#97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants