Getting started
Installation
Require the package, and add the optional packages for YAML output and schema validation.
Require the package
Terminal
composer require ark4ne/openapi-writerIt needs PHP 8.2 or later and ext-json, nothing else.
Add the optional packages
Terminal
composer require --dev opis/json-schema # validation against the official schemas
composer require symfony/yaml # YAML output
Install them only if you use what they bring:
| Package | Needed for |
|---|---|
opis/json-schema | OpisJsonSchemaValidator, the validation against the official OpenAPI schemas. Recommended in tests. |
symfony/yaml | toYaml() |
Without them, the rest of the library works; calling toYaml() or new OpisJsonSchemaValidator() throws a
MissingDependencyException that names the package to install.
Check it works
check.php
<?php
require __DIR__ . '/vendor/autoload.php';
use Ark4ne\OpenApiWriter\Objects\Schema;
echo Schema::string()->nullable()->toJson();
// {"type":["string","null"]}
Terminal
php check.php
Coding agents
The package ships an agent skill in vendor/ark4ne/openapi-writer/skills/openapi-writer/: the rules that avoid the
usual mistakes, the full API reference, tested recipes and the version matrix. Its examples run in the library's test
suite, so it matches the installed version.
With Claude Code, link it into the project that uses the library:
Terminal
mkdir -p .claude/skills
ln -s ../../vendor/ark4ne/openapi-writer/skills/openapi-writer \
.claude/skills/openapi-writer
With another agent, point its instructions file (AGENTS.md…) to
vendor/ark4ne/openapi-writer/skills/openapi-writer/SKILL.md.