PHPackages                             mlambley/swagfaker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mlambley/swagfaker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mlambley/swagfaker
==================

Create fake data from a Swagger schema

1.0.1(5y ago)06.4k[3 PRs](https://github.com/mlambley/swagfaker/pulls)MITPHP

Since Aug 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mlambley/swagfaker)[ Packagist](https://packagist.org/packages/mlambley/swagfaker)[ RSS](/packages/mlambley-swagfaker/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (7)Used By (0)

Swagfaker
=========

[](#swagfaker)

Generates fake data which will validate against your Swagger 2.0 schema.

How to install
--------------

[](#how-to-install)

```
composer require mlambley/swagfaker:^1.0

```

What is Swagger?
----------------

[](#what-is-swagger)

Swagger 2.0 (aka Open API 2.0) defines the structure of your API, including end points and the structure of input and output data. See [their website](https://swagger.io/) for more information.

What is Swagfaker?
------------------

[](#what-is-swagfaker)

Swagfaker allows you to generate fake data based upon your existing Swagger 2.0 specification. You can use it to generate data to be sent to your API during acceptance testing.

Example
-------

[](#example)

Let's say your Swagger schema looks like this:

```
{
  "type": "object",
  "required": [
    "Name",
    "DateOfBirth",
    "Identifier",
    "VisitCount"
  ],
  "properties": {
    "Name": {
      "type": "string"
    },
    "DateOfBirth": {
      "type": "string",
      "format": "date"
    },
    "Identifier": {
      "type": "string",
      "pattern": "^[0-9]{3}-[0-9]{4}$"
    },
    "VisitCount": {
      "type": "integer",
      "minimum": 0
    }
  }
}
```

Then generate fake data using:

```
$values = (new \SwaggerFaker\Faker())->generate($schema);
```

Your values now might look like this:

```
object(stdClass) {
  "Name" => "Quod."
  "DateOfBirth" => "1971-08-20"
  "Identifier" => "037-1259"
  "VisitCount" => 1463093889
}

```

Issues?
-------

[](#issues)

Log a [github issue](https://github.com/mlambley/swagfaker/issues). Your assistance is appreciated.

Credit
------

[](#credit)

Give some love to [Leko](https://github.com/Leko) for their [JSON Schema Faker](https://github.com/Leko/php-json-schema-faker) which this library was originally copied from.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~403 days

Total

3

Last Release

2015d ago

Major Versions

0.0.1-alpha.1 → 1.02018-08-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/a42dca105f2bbfaa580a01156becfe7214b1b1a4f1f49cdbf4d2a6113029c24a?d=identicon)[mlambley](/maintainers/mlambley)

---

Top Contributors

[![mlambley](https://avatars.githubusercontent.com/u/17264636?v=4)](https://github.com/mlambley "mlambley (2 commits)")[![mark-lambley-simpro](https://avatars.githubusercontent.com/u/24515999?v=4)](https://github.com/mark-lambley-simpro "mark-lambley-simpro (1 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mlambley-swagfaker/health.svg)

```
[![Health](https://phpackages.com/badges/mlambley-swagfaker/health.svg)](https://phpackages.com/packages/mlambley-swagfaker)
```

###  Alternatives

[digilist/snakedumper

5045.5k](/packages/digilist-snakedumper)[cinghie/yii2-traits

Yii2 Traits

116.9k8](/packages/cinghie-yii2-traits)[emanueleminotto/faker-service-provider

Faker Service Provider for Silex

162.9k](/packages/emanueleminotto-faker-service-provider)[flowpack/nodegenerator

Random nodes generator for Neos CMS

122.1k](/packages/flowpack-nodegenerator)[prewk/xml-faker

Create random XML with the help of fzaniotto/Faker.

101.8k2](/packages/prewk-xml-faker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
