Skill openapi-parser
Menganalisis spesifikasi OpenAPI yang kompleks untuk menghasilkan test case Drift yang mencakup polymorphic schema dan berbagai varian response.
- Bintang GitHub
- 7
- File
- 7
- Commit terakhir
- 11 Nov 2026
- Lisensi
- MIT
- Tool yang diizinkan
- —
Apa fungsi skill openapi-parser?
openapi-parser adalah agent skill. Menganalisis spesifikasi OpenAPI yang kompleks untuk menghasilkan test case Drift yang mencakup polymorphic schema dan berbagai varian response.
Ringkasan dibuat dari SKILL.md skill ini.
Tentang skill openapi-parser
Fungsi utama dari skill ini adalah menghasilkan test case Drift dari spesifikasi OpenAPI yang kompleks. Skill ini dirancang untuk developer yang perlu membuat kerangka test yang mencakup polymorphic schema, inheritance, dan berbagai varian response. Saat sebuah agent memuat skill ini, ia dapat menganalisis file OpenAPI 3.x untuk mengidentifikasi parameter path, query, dan header, serta request body dan response status code.
Prosesnya melibatkan resolusi rantai $ref secara rekursif dan interpretasi pola kompleks seperti anyOf, oneOf, allOf, dan discriminators. Skill ini menggunakan file referensi seperti schema-patterns.md dan drift-mapping.md untuk memastikan interpretasi logika schema dan pemetaan ke Drift YAML dilakukan dengan benar. Output yang dihasilkan mencakup analisis detail dari schema, blok operasi lengkap untuk Drift, dataset yang diperlukan, serta daftar kombinasi schema yang sengaja dikecualikan. Hal ini memungkinkan cakupan tinggi pada varian schema yang berbeda secara struktural tanpa menciptakan ledakan kombinatorial test yang tidak perlu.
Apa yang bisa dilakukan agent dengannya
- 1Scaffold test Drift dari sebuah specDeveloper dapat memberikan path file OpenAPI untuk menghasilkan set operasi Drift dan dataset yang lengkap secara otomatis.
- 2Test cabang polymorphic schemaAnda dapat menggunakan ini untuk memastikan setiap cabang dari schema oneOf atau anyOf tercakup oleh test case yang unik.
- 3Validasi nilai field yang kompleksAgent dapat membantu menentukan nilai spesifik mana yang valid untuk sebuah field yang didefinisikan oleh regex patterns atau enums yang kompleks.
- 4Menangani inheritance dan komposisiSkill ini dapat menggabungkan base fields dengan properti lokal untuk membuat satu payload tunggal untuk test komposisi allOf.
Ditulis dari SKILL.md milik skill tersebut. Setiap use case diverifikasi dengan kutipan darinya.
Cara install skill openapi-parser
Setiap perintah menyalin folder skill ke direktori skills client. Restart client atau mulai sesi baru untuk memuatnya.Install skill openapi-parser di Plugin
/plugin marketplace add pactflow/pactflow-agent-skills /plugin install swagger-contract-testing@swagger-contract-testing-agent-extensions
Install skill openapi-parser di Claude Code
~/.claude/skills/openapi-parser/SKILL.md
$ npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser ~/.claude/skills/openapi-parserInstall skill openapi-parser di Claude Code (project)
.claude/skills/openapi-parser/SKILL.md
$ npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser .claude/skills/openapi-parserInstall skill openapi-parser di Codex
~/.agents/skills/openapi-parser/SKILL.md
$ npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser ~/.agents/skills/openapi-parserInstall skill openapi-parser di Gemini CLI
~/.gemini/skills/openapi-parser/SKILL.md
$ npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser ~/.gemini/skills/openapi-parserInstall skill openapi-parser di Claude.ai
npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser openapi-parser && zip -r openapi-parser.zip openapi-parser # claude.ai → Customize → Skills → + → Create skill → Upload a skill → openapi-parser.zip
SKILL.md
Lihat di GitHubOpenAPI Parser Skill
Reference files
references/schema-patterns.md— how to interpret and enumerate every complex pattern (anyOf / oneOf / allOf / discriminator / $ref / enum / pattern / nullable / optional), with real examples from snyk, digitalocean, posthog, and front/core specsreferences/drift-mapping.md— how to map enumerated schema variants to Drift YAML, including datasets, expressions, lifecycle hooks for stateful cases, and expected response matchers for each pattern type
Workflow
OpenAPI version: This skill targets OpenAPI 3.x. Swagger 2.0 specs use the same structural patterns (
$ref,allOf,oneOf) but different envelope syntax — you may need to adapt field names manually. If working from thekonfig-sdks/openapi-examplescollection, seereferences/example-repos.mdfor navigation commands.
1. Locate the endpoint
Extract only what's needed:
# Find the line number of the endpoint (macOS/Linux/Git Bash/WSL)
grep -n "^ /path/to/endpoint" spec.yaml
# Read just that block (adjust line range as needed)
# Then follow each $ref to components/schemas
grep -n "SchemaName:" spec.yaml
# PowerShell equivalents (Windows)
Select-String -Path spec.yaml -Pattern "^ /path/to/endpoint" | Select-Object LineNumber, Line
Select-String -Path spec.yaml -Pattern "SchemaName:" | Select-Object LineNumber, Line
Extract: path/query/header parameters, request body schema, and each response status code's schema.
2. Resolve $refs recursively
- Grep for
Foo:in the spec to find its definition block - If Foo itself contains refs, resolve those too
- Stop at primitive types (
string,integer,boolean,array,object)
allOf: [$ref: Base, properties: {...}] is inheritance — merge Base fields with local
properties to get the full schema. See references/schema-patterns.md for all patterns.
3. Enumerate viable combinations
For each response status code, enumerate structurally distinct schema variants. Aim for minimum tests that maximise schema coverage — not a combinatorial explosion of optional field permutations.
| Pattern | Tests to generate |
|---|---|
oneOf / anyOf with N branches |
N tests — one per branch |
discriminator with N mapping values |
N tests — one per discriminator value |
allOf (composition / inheritance) |
1 test — merge all schemas into one payload |
enum |
1 test covers it; add boundary variants only if the value drives behaviour |
| Optional field cluster | 2 tests: one with all optional fields, one without |
nullable field |
Covered by happy path; add null variant only if it changes behaviour |
pattern (regex) |
1 valid example matching the pattern; 1 invalid for negative testing |
4. Generate Drift test cases
For each combination produce a Drift operation block. See references/drift-mapping.md
for full patterns. Key conventions:
- Name operations as
{operationId}_{variant}— e.g.getImage_byId,getImage_bySlug - For discriminated unions, set the discriminator property explicitly in the request body
- For
anyOfpath parameters, write one test per type variant - Use
datasetfor test data; use inlineparametersonly for static, non-variant values (e.g. a fixed enum query param liketype: user) - For 401 tests, strip global auth with
exclude: [auth]and pass an invalid bearer token explicitly - Add
ignore: { schema: true }to any operation that sends an intentionally invalid request body - Tag each test to indicate which schema branch it covers
- Omitting
bodyfromexpectedlets Drift validate the response against the OpenAPI schema automatically; add explicitbodymatchers only when asserting a specific field value (e.g. the discriminator property came back correctly)
5. Output format
Always produce:
- Analysis — number of status codes, which schemas are polymorphic, how many tests will be generated and why
- Drift operations YAML — the complete
operations:block, ready to paste - Dataset YAML (if needed) — the
datasets:block for any referenced test data - Gaps — schema combinations intentionally excluded, with the reason
Example
Given GET /v2/images/{image_id} where image_id: anyOf: [integer, string]:
operations:
getImage_byId:
target: source-oas:getImage
tags: [images, param-integer]
parameters:
path:
image_id: ${image-data:images.existing.id}
expected:
response:
statusCode: 200
getImage_bySlug:
target: source-oas:getImage
tags: [images, param-string]
parameters:
path:
image_id: ${image-data:images.existing.slug}
expected:
response:
statusCode: 200
getImage_notFound:
target: source-oas:getImage
parameters:
path:
image_id: ${image-data:notIn(images.*.id)}
expected:
response:
statusCode: 404
Berkas dalam skill ini
7Pertanyaan seputar skill openapi-parser
Bagaimana cara install skill openapi-parser di Claude Code?
Jalankan npx degit pactflow/pactflow-agent-skills/plugins/swagger-contract-testing/skills/openapi-parser ~/.claude/skills/openapi-parser. Claude Code memuat skill dari ~/.claude/skills (semua proyek) atau .claude/skills (satu proyek) dan menggunakan skill saat deskripsinya cocok dengan tugas.
Client mana saja yang bisa menggunakan skill openapi-parser?
Client apa pun yang membaca format Agent Skills: Claude Code, Codex, Gemini CLI, dan claude.ai (unggah sebagai ZIP). Script dalam skill hanya berjalan di client yang mengizinkan eksekusi kode.
Jenis schema OpenAPI kompleks apa saja yang bisa ditangani oleh skill ini?
Skill ini menangani anyOf, oneOf, allOf, discriminators, polymorphism, inheritance, rantai $ref, regex patterns, enums, dan field opsional.
Versi OpenAPI mana saja yang didukung?
Skill ini secara khusus menargetkan OpenAPI 3.x, meskipun spesifikasi Swagger 2.0 dapat digunakan dengan menyesuaikan nama field secara manual.
Bagaimana skill ini menangani pola oneOf atau anyOf saat membuat test?
Untuk pola oneOf atau anyOf dengan N cabang, skill ini akan menghasilkan N test, dengan menyediakan satu test untuk setiap cabang.