0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

カスタムGPTのActionsは移行されない:終了前にOpenAPIスキーマを棚卸しするPythonスクリプト

0
Posted at

カスタムGPTは、OpenAIの公式FAQで 2026年12月11日に終了予定 です(FedRAMPと、条件を満たして延期が承認されたEnterpriseワークスペースは2027年2月28日。2026年11月29日確認)。移行先のプラグインには指示・知識ファイル・接続アプリが引き継がれますが、カスタムアクションは移行されません。対応アプリで代替するか、カスタムMCPサーバーなどで作り直し、テストする必要があります。

作り直しの前に要るのは「今のActionsが何をしていたか」の一覧です。そこで、ActionsのOpenAPIスキーマから操作を表にするPythonスクリプトを用意しました。

移行で引き継がれるものと、そのままは移らないものの比較図

前提と限界

  • GPTの編集画面に入力しているActionsのスキーマを、自分でファイル(JSONまたはYAML)に保存して使います。APIキーなどの秘密の値は貼り付けないでください
  • 通信はしません。ファイルを読んで表示するだけです
  • 下の自作サンプルで動作を確認しました。実際のGPTからの移行や、MCPサーバーの構築は試していません
  • $ref で参照される path 項目、webhooks、引数やレスポンスの中身は展開しません

コード

actions_inventory.py
"""カスタムGPTのActions(OpenAPIスキーマ)を棚卸しする。通信はしない。"""
import json
import sys

METHODS = ("get", "put", "post", "delete", "patch", "head", "options", "trace")


def load(path):
    with open(path, encoding="utf-8-sig") as f:
        text = f.read()
    try:
        return json.loads(text)
    except json.JSONDecodeError:
        import yaml  # YAMLの場合だけ必要: pip install pyyaml
        return yaml.safe_load(text)


def inventory(spec):
    if not isinstance(spec, dict) or not isinstance(spec.get("paths"), dict):
        raise ValueError("OpenAPIの paths がありません")
    rows = []
    for path, item in spec["paths"].items():
        if not isinstance(item, dict):
            continue
        for method, op in item.items():
            if method.lower() not in METHODS or not isinstance(op, dict):
                continue
            # 操作側の security は、全体の security を上書きする([]は認証指定なし)
            security = op.get("security", spec.get("security", []))
            auth = sorted({name for req in security for name in req})
            rows.append({
                "method": method.upper(),
                "path": path,
                "id": op.get("operationId", "(operationIdなし)"),
                "kind": "参照系?" if method.lower() in ("get", "head", "options") else "変更系?",
                "auth": ",".join(auth) or "指定なし",
            })
    return rows


def main(path):
    spec = load(path)
    rows = inventory(spec)
    hosts = [s.get("url", "") for s in spec.get("servers", [])]
    print("接続先:", ", ".join(hosts) or "記載なし")
    print()
    print("| method | path | operationId | 分類 | 認証名 | 代替手段 | テスト |")
    print("|---|---|---|---|---|---|---|")
    for r in rows:
        cells = [r["method"], r["path"], r["id"], r["kind"], r["auth"]]
        cells = [str(c).replace("|", "\\|") for c in cells]
        print("| " + " | ".join(cells) + " | 未定 | 未 |")
    changes = sum(r["kind"] == "変更系?" for r in rows)
    print(f"\n合計 {len(rows)} 操作(うち変更系? {changes})")


if __name__ == "__main__":
    if len(sys.argv) != 2:
        sys.exit("使い方: python actions_inventory.py openapi.yaml")
    main(sys.argv[1])

実行(YAMLを読む場合は pip install pyyaml):

python actions_inventory.py sample.yaml

サンプル

sample.yaml
openapi: 3.1.0
info:
  title: Sample Task API
  version: "1.0.0"
servers:
  - url: https://api.example.com
security:
  - apiKey: []
paths:
  /tasks:
    get:
      operationId: listTasks
      responses: {"200": {description: ok}}
    post:
      operationId: createTask
      responses: {"201": {description: created}}
  /health:
    get:
      operationId: health
      security: []
      responses: {"200": {description: ok}}
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key

出力:

接続先: https://api.example.com

| method | path | operationId | 分類 | 認証名 | 代替手段 | テスト |
|---|---|---|---|---|---|---|
| GET | /tasks | listTasks | 参照系? | apiKey | 未定 | 未 |
| POST | /tasks | createTask | 変更系? | apiKey | 未定 | 未 |
| GET | /health | health | 参照系? | 指定なし | 未定 | 未 |

合計 3 操作(うち変更系? 1)

表の読み方:3つの確認

1. 分類の「?」は消してから使う。 HTTPメソッドから機械的に分けているだけです。GETでも副作用のあるAPIや、POSTでも検索しかしないAPIがあります。API提供元の仕様で確かめてください。

2. 認証は名前だけを拾う。 security は操作側の指定が全体の指定を上書きします。[] なら「指定なし」と表示しますが、APIが本当に認証不要という保証ではありません。認証方式の詳細は components.securitySchemes を確認してください。

3. 代替手段とテストの列を埋める。 公式FAQは、利用できるアプリが必要な操作に対応するかを先に確認し、作り直した連携は元のActionと同じ機能があると仮定せずテストするよう案内しています。変更系の操作は、本番データではなくテスト用の環境で確かめるのが安全です。

終了前にやる棚卸し・移行・テストの3ステップ図

移行そのものの注意

  • 移行に使われるのは公開済みの最新版です。下書きは移りません
  • 移行後の元のGPTは読み取り専用になります。スキーマの控えは移行前に保存します
  • 組み込みの移行には Upload plugins などの権限は不要ですが、連携の作り直しには別の権限が必要になる場合があります

出典(2026年11月29日確認)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?