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-writer

It 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:

PackageNeeded for
opis/json-schemaOpisJsonSchemaValidator, the validation against the official OpenAPI schemas. Recommended in tests.
symfony/yamltoYaml()

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.