Skip to content
Nav

Example generation

composer require langsys/openapi-docs-generator
Packagist version Monthly downloads License PHP 8.1+ Laravel 10 / 11

When a property doesn’t have an explicit #[Example], the generator produces example values using Faker, in this order:

  1. Faker attribute mapper — substring patterns on the property name (_at → date(), phone → phoneNumber(), …)
  2. Custom functions — register your own (id, date, or app-specific)
  3. Direct Faker fallback — the property name itself as a Faker method (first_name → firstName())

Configure faker_attribute_mapper and custom_functions in config/openapi-docs.php. Custom functions receive the property type as their first argument.

See also #[Example] for explicit values and the :fakerMethod shorthand.

Feedback