# Openapi operation extract

`openapi-operation-extract` · version 1.0.0 · Developer tools · free, no key needed

Extract one OpenAPI operation, merge inherited parameters, and return its local component-reference closure.

**Use when you need to: extract OpenAPI operation · select endpoint by path and method · get one OpenAPI endpoint.**

## Decide before calling

Read the [versioned contract](/v1/tools/openapi-operation-extract/versions/1.0.0) and the supported scope below. Reuse `openapi-operation-extract@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `openapi-operation-extract@1.0.0` for extract OpenAPI operation. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- extract OpenAPI operation
- select endpoint by path and method
- get one OpenAPI endpoint
- merge OpenAPI path parameters
- collect operation component references
- compact an OpenAPI operation

## Not supported

- resolve remote references over a network
- bundle an entire OpenAPI document
- validate all OpenAPI semantic requirements

## Behavior

- Accepts OpenAPI 3.0.x and 3.1.x JSON values supplied as an object; it performs bounded structural extraction, not full specification validation.
- Path-level parameters are inherited; an operation parameter with the same exact name and in value replaces the path-level parameter.
- Only local RFC 6901 fragment references are followed; a nested component pointer includes its complete owning component entry. Remote references, missing pointers, and reference cycles are invalid_input.
- Object keys are recursively sorted in the output; array order and the inherited parameter position are deterministic.

## Input

- `document` (any JSON value, required)
- `path` (string, required): min length 1; max length 2048
- `method` (one of "get", "put", "post", "delete", "options", "head", "patch", "trace", required)

## Output

- `path` (string, required)
- `method` (one of "get", "put", "post", "delete", "options", "head", "patch", "trace", required)
- `operation` (object, required)
- `components` (object, required)

## Limits

- max input bytes: 262144
- max output bytes: 262144
- max depth: 32
- max refs: 128
- max parameters: 128
- max path bytes: 2048

## Example

Request input:

```json
{
  "document": {
    "openapi": "3.1.0",
    "paths": {
      "/pets": {
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "get": {
          "operationId": "listPets",
          "responses": {
            "200": {
              "description": "ok"
            }
          }
        }
      }
    }
  },
  "path": "/pets",
  "method": "get"
}
```

Response:

```json
{
  "result": {
    "components": {},
    "method": "get",
    "operation": {
      "operationId": "listPets",
      "parameters": [
        {
          "in": "query",
          "name": "limit",
          "schema": {
            "type": "integer"
          }
        }
      ],
      "responses": {
        "200": {
          "description": "ok"
        }
      }
    },
    "path": "/pets"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "openapi-operation-extract",
  "version": "1.0.0",
  "input": {
    "document": {
      "openapi": "3.1.0",
      "paths": {
        "/pets": {
          "parameters": [
            {
              "name": "limit",
              "in": "query",
              "schema": {
                "type": "integer"
              }
            }
          ],
          "get": {
            "operationId": "listPets",
            "responses": {
              "200": {
                "description": "ok"
              }
            }
          }
        }
      }
    },
    "path": "/pets",
    "method": "get"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/openapi-operation-extract/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"document":{"openapi":"3.1.0","paths":{"/pets":{"parameters":[{"name":"limit","in":"query","schema":{"type":"integer"}}],"get":{"operationId":"listPets","responses":{"200":{"description":"ok"}}}}}},"path":"/pets","method":"get"}'
```

The machine-readable contract is at [/v1/tools/openapi-operation-extract/versions/1.0.0](/v1/tools/openapi-operation-extract/versions/1.0.0).

### CLI

```sh
node cli.mjs run openapi-operation-extract 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Commit conventional parse](/tools/commit-conventional-parse): Parse one Conventional Commits 1.0.0 message into its header, body, footers, and breaking-change status.
- [Tap output parse](/tools/tap-output-parse): Parse TAP version 13 text into ordered assertions, plan validity, diagnostics, directives, and bailout state.
- [Editorconfig resolve](/tools/editorconfig-resolve): Resolve EditorConfig properties for one normalized relative POSIX path from caller-supplied file contents.
- [Sql statements split](/tools/sql-statements-split): Split SQL text into exact statement spans with explicit PostgreSQL, MySQL, or SQLite lexical rules.
- [Chmod mode convert](/tools/chmod-mode-convert): Convert a Unix permission mode and apply explicit chmod symbolic clauses, returning canonical octal and symbolic forms.
- [Shell argv quote](/tools/shell-argv-quote): Quote inert argv strings for POSIX sh or PowerShell 7, returning a command and its per-argument fragments.
