PHPackages                             dsuurlant/response2schema - 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. [API Development](/categories/api)
4. /
5. dsuurlant/response2schema

ActiveLibrary[API Development](/categories/api)

dsuurlant/response2schema
=========================

Generate an OpenAPI schema definition for an object based on a JSON response.

1.0.5(1y ago)9153.5k↓16.7%5MITPHPPHP ^7.4|^8.0CI failing

Since May 25Pushed 1y ago3 watchersCompare

[ Source](https://github.com/dsuurlant/response2schema)[ Packagist](https://packagist.org/packages/dsuurlant/response2schema)[ RSS](/packages/dsuurlant-response2schema/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (7)Used By (0)

Response2Schema
===============

[](#response2schema)

A quick 'n easy way to generate your OpenAPI spec based on a JSON object. Useful for bootstrapping your component schemas. This is intended to be a starting point for writing your specification, as the tool cannot infer types such as enum, oneOf, maximum/minimum, and so on. It also does not support generating endpoints or error responses. All it does is take your JSON object and turns it into an OpenAPI schema object, along with a simple example spec that you can expand on.

Supports generating an OpenAPI spec in `JSON` or `yaml`.

Installation
============

[](#installation)

`composer require dsuurlant/response2schema`

Or download the phar from the [Releases page](https://github.com/dsuurlant/response2schema/releases).

Usage
=====

[](#usage)

Just point Response2Schema to your input json file, and tell it where to put the output OpenAPI spec.

It will automatically format it to json or yaml based on the extension of the output path.

`./vendor/bin/response2schema response.json openapi.yaml`

Or when using the phar:

`./response2schema.phar response.json openapi.yaml`

Example
=======

[](#example)

Given a very simple response:

```
{
    "id": 1,
    "name": "Example Response"
}
```

Response2Schema generates the following spec:

```
openapi: 3.0.0
info:
  title: 'OpenAPI specification automatically generated by Response2Schema.'
  description: 'Please adapt this specification to your own needs.'
  version: 1.0.0
paths:
  /resource:
    get:
      description: 'Description of the endpoint'
      operationId: getResource
      responses:
        '200':
          description: 'Description of this response.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Resource'
components:
  schemas:
    Resource:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
```

It will always generate the example endpoint and a schema named 'Resource'.

The best way to use this tool is to take this as a starting point, or copy-paste the schema definition to your own OpenAPI spec.

Credits
=======

[](#credits)

Built and maintained by [Daniëlle Suurlant](https://github.com/dsuurlant).

Relies heavily on the awesome PHP OpenAPI library [cebe/php-openapi](https://github.com/cebe/php-openapi).

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 85.2% 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 ~329 days

Recently: every ~411 days

Total

6

Last Release

538d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.0.3PHP ^7.4|^8.0

### Community

Maintainers

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

---

Top Contributors

[![dsuurlant](https://avatars.githubusercontent.com/u/4609379?v=4)](https://github.com/dsuurlant "dsuurlant (23 commits)")[![dsuurlant-AlisQI](https://avatars.githubusercontent.com/u/214467357?v=4)](https://github.com/dsuurlant-AlisQI "dsuurlant-AlisQI (4 commits)")

---

Tags

openapi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dsuurlant-response2schema/health.svg)

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

###  Alternatives

[swagger-api/swagger-ui

 Swagger UI is a collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

28.7k45.4M99](/packages/swagger-api-swagger-ui)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M57](/packages/dedoc-scramble)[cebe/php-openapi

Read and write OpenAPI yaml/json files and make the content accessable in PHP objects.

49815.4M86](/packages/cebe-php-openapi)[jolicode/slack-php-api

An up to date PHP client for Slack's API

2534.4M12](/packages/jolicode-slack-php-api)[darkaonline/swagger-lume

OpenApi or Swagger integration to Lumen

3372.3M3](/packages/darkaonline-swagger-lume)

PHPackages © 2026

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