jdomenechb/json-dereferencer

PHP class to replace JSON references by their targets

This package's canonical repository appears to be gone and the package has been frozen as a result.

v0.1 2019-03-15 13:29 UTC

This package is auto-updated.

Last update: 2023-01-26 21:58:40 UTC


README

This project provides an interface and an implementation of a PHP class to replace JSON references by their targets.

Features

For now, it only supports $ref paths starting with root element #.

Example

Input:

  {
    "responses": {
      "200": {
        "description": "The response",
        "schema": {
          "$ref": "#/components/schemas/user" 
        }
      }
    },
    "components": {
      "schemas": {
        "user": {
          "type": "string",
          "format": "email"
        }
      }
    }
  }

Output:

  {
    "responses": {
      "200": {
        "description": "The response",
        "schema": {
          "type": "string",
          "format": "email"
        }
      }
    },
    "components": {
      "schemas": {
        "user": {
          "type": "string",
          "format": "email"
        }
      }
    }
  }