API ComparatorOpen test data generator

OpenAPI testing guide

How to generate JSON test data from an OpenAPI schema

Build a customer request fixture, inspect the generated values, and turn it into a small set of meaningful API tests. This walkthrough includes the entire schema and explains what the generator can and cannot enforce.

9 minute readUpdated September 16, 2026

Choose a request model, not just any schema

A reusable OpenAPI component may describe a request, a response, or an internal object. For a create-customer test, use the request model referenced by that operation’s request body. A response model may contain server-generated IDs or timestamps that clients must not send.

The example below is a schema-only OpenAPI 3.0.3 document with an empty paths object. It describes fixtures; it does not claim to provide a callable endpoint. Its CustomerCreate schema requires an email, an age from 18 to 75, an allowed status, one or two tags, and a nested address.

openapi: 3.0.3
info:
  title: Customer fixture example
  version: 1.0.0
paths: {}
components:
  schemas:
    CustomerCreate:
      type: object
      required: [email, age, status, tags, address]
      properties:
        email:
          type: string
          format: email
          example: maya.chen@example.com
        age:
          type: integer
          minimum: 18
          maximum: 75
        status:
          type: string
          enum: [active, pending]
        tags:
          type: array
          minItems: 1
          maxItems: 2
          items:
            type: string
            enum: [trial, newsletter]
        address:
          $ref: '#/components/schemas/Address'
    Address:
      type: object
      required: [city, countryCode]
      properties:
        city:
          type: string
          example: Bristol
        countryCode:
          type: string
          enum: [GB, IN, US]

The address references a second component in the same document. The quoted $ref value starts with #/; quoting is important in YAML because an unquoted hash can start a comment. All names and contact values are synthetic.

Generate your first payload

  1. Open the generator and choose OpenAPI.
  2. Replace the sample with the full YAML above. Equivalent JSON works too.
  3. Choose CustomerCreate in the Schema selector. Choosing Address would generate only the address object.
  4. Set Records to 1, then select Generate JSON.
  5. Inspect the result before selecting Copy or Download.

One possible result is shown below. The age, status, tags, and country vary between runs. The explicit email and city examples remain fixed. The tool has no random seed setting; save a generated fixture when you need a reproducible test.

{
  "email": "maya.chen@example.com",
  "age": 28,
  "status": "active",
  "tags": [
    "trial"
  ],
  "address": {
    "city": "Bristol",
    "countryCode": "GB"
  }
}

Check the structure, not an exact random value: age is a JSON number, tags is an array of one or two allowed strings, and address is an object rather than a literal reference path. A schema can allow combinations that your business rules reject; this example does not model whether a particular city belongs to a country.

Records set to 1 returns the schema’s value directly. A higher count wraps those values in an array. If your endpoint expects a single object, send one record at a time; a batch fixture is not proof that the endpoint accepts a batch request.

Convert one fixture into a test matrix

Generating twenty ordinary customers does not guarantee boundary coverage. Keep a copy of one valid fixture and change exactly one condition per test. For this fictional contract, use these cases:

Customer request cases
CaseChange to the payloadWhat to check
Normal requestUse the sample above.The documented success response and stored fields match.
Lower boundarySet age to 18.The inclusive lower limit is accepted.
Upper boundarySet age to 75.The inclusive upper limit is accepted.
Below the boundarySet age to 17.The API rejects it with its documented validation response.
Wrong typeSet age to the string "28".Validation does not silently accept a type the contract forbids.
Required field missingRemove email entirely.The response identifies the missing field.
Invalid enumSet status to archived.An unknown enum value is rejected.
Empty collectionSet tags to [].The minimum of one item is enforced.
Too many itemsUse three tags.The maximum of two items is enforced.
Nested requirementRemove address.countryCode.Nested validation reports the relevant field path.

A rejected request should not create a partial customer. Check both the response and the resulting state. The status might be 400 or 422 depending on your documented API contract; the generator does not choose that policy.

{
  "email": "maya.chen@example.com",
  "age": 17,
  "status": "active",
  "tags": [
    "trial"
  ],
  "address": {
    "city": "Bristol",
    "countryCode": "GB"
  }
}

This is an intentionally invalid age fixture, not a payload the generator should produce from the original schema. Start each negative test from a fresh valid copy so several defects do not hide which rule is being tested. See API error response design for useful validation messages.

Use field definitions when you do not have OpenAPI

email: email
age: integer(18, 75)
status: enum(active, pending)
isActive: boolean
createdAt: datetime
roles: array<string>

Select Field definitions and enter one field per line. Enums in this mode contain strings; use an OpenAPI schema for numeric or boolean enums. Array fields contain one to three generated values. The object and address types generate a sample address; they do not infer your domain model.

For names and common values, supported labels include firstName, lastName, name, phone, city, country, company, role, status, title, and description. Core types include string, uuid, email, date, datetime, uri, ipv4, integer, number, boolean, null, object, and array<type>. Unknown types, duplicate names, and reversed numeric ranges are errors. Comments can occupy a line starting with #.

Supported features and explicit limits

This is a fixture generator for common schema shapes, not a complete OpenAPI or JSON Schema validator. It does not call an API or prove a payload will be accepted.

How API Comparator handles schemas
FeatureCurrent behaviorWhat you should verify
Objects and propertiesGenerates every declared property, including optional ones.Remove optional fields to test omission. readOnly/writeOnly and required-only generation are not applied.
Example, examples, const, enumUses an explicit example first, then example lists, const, or enum values.Supplied values are used as-is, without validating other constraints. Defaults are not used.
NumbersInclusive minimum and maximum; integers use whole-number bounds.Set fixed boundaries explicitly for deterministic tests. Exclusive limits and multipleOf need a checked example.
ArraysHonors minItems and maxItems within a 20-item output cap per array; an unconstrained array may be empty.A minimum above 20 is rejected. Unique items and tuple constraints need explicit examples.
Strings and formatsLength limits for plain strings; email, uuid, date, date-time, uri/url, and ipv4 examples.Pattern rules and unknown formats need an example. Conflicting formatted-string lengths produce an error.
Local referencesResolves component references in the pasted document.Missing or external refs are errors. Recursive/deep schemas need a finite fixture.
Schema combinationsoneOf, anyOf, allOf, conditionals, and other complex constraints stop generation unless a covering example is supplied.Validate examples independently; the tool does not merge or solve those rules.
Open-ended objects and business rulesDoes not infer additional properties, cross-field dependencies, database uniqueness, or valid entity relationships.Model or test these separately in your application.

Input is limited to 200,000 characters, with a traversal limit for deeply nested output. These bounds keep generation usable in a browser. Reduce a large specification to the relevant components while retaining referenced schemas.

Fix common generation errors

“Could not parse the specification”: check indentation and duplicate keys in YAML, or missing commas and quotes in JSON. Broken JSON is not reinterpreted as a different YAML document.

“No schema found”: an operation’s request body wrapper is not itself a schema. Paste its schema object or a document with components.schemas.

“Reference not found”: include the referenced component and match its spelling and case. External files are not fetched.

“Cannot enforce”: review the named constraint. Use a validated example at that schema node, or simplify a copy of the schema specifically for fixture generation. Keep your original production contract unchanged.

After any input change or generation error, the previous output is cleared and export controls are disabled until a new run succeeds. This avoids accidentally copying an old payload for a new schema.

Use the fixture safely and keep the test repeatable

Download the chosen JSON fixture and commit it with your test code, using your normal repository review process. Record the schema revision and expected response beside it. Random generation is useful for variety; a saved fixture is what makes a regression reproducible.

Use a test environment with disposable records. A POST can create data; sending the same fixture to two environments can create two records. Compare status, body, and documented side effects, and clean up test data afterward. The API comparison walkthrough explains how to interpret differences without treating every timestamp as a regression.

Generation happens locally in your browser. Examples in this guide use reserved example.com addresses; generated identifiers are synthetic and do not grant access to real accounts. Do not paste credentials or customer data into a specification.

For the meaning of schema keywords and local references, consult the official OpenAPI 3.0.3 Schema Object documentation. The customer schema, payload, and test matrix here are original examples.

Build and inspect a fixture

Start with the customer example, generate one record, then save the boundary and invalid cases that matter to your API.

Open test data generator