json-schema-to-php-docstring

Convert JSON Schema to PHP Array Shapes Docstring simplifies the process of generating PHP documentation from JSON Schema, streamlining development workflows and enhancing code maintainability.

MIT License

Stars
0
Committers
1

JSON Schema to PHP Array Shapes Docstring Converter

This project provides a simple tool to convert JSON Schema into PHP array shapes docstring. It helps developers easily generate PHP documentation for their JSON Schema.

How to Use

  1. Input JSON Data: Paste your JSON data into Quicktype (a tool for generating data types and converters from JSON to various programming languages).

  2. Set Language to JSON Schema: In Quicktype, ensure that you select "JSON Schema" as the output language.

  3. Adjust Settings: In the "Other" tab of Quicktype, ensure that all options are checked. This ensures the most comprehensive conversion. If you encounter a "RangeError: Maximum call stack size exceeded" error after clicking "Convert" on converter website, go back to Quicktype and uncheck "Merge similar classes" in the "Other" tab.

  4. Copy JSON Schema: Copy the generated JSON Schema from Quicktype.

  5. Access the Converter: Visit website.

  6. Paste JSON Schema: Paste the copied JSON Schema into the designated area on the website.

  7. Convert: Click on the "Convert" button to initiate the conversion process.

  8. Result: The converted PHP array shapes docstring will be displayed on the website. You can copy this docstring and use it in your PHP documentation.

Example

Here's a simple example to illustrate the process:

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "type": "array",
    "items": {
        "$ref": "#/definitions/RootElement"
    },
    "definitions": {
        "RootElement": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "name": {
                    "type": "string"
                },
                "age": {
                    "type": "integer"
                }
            },
            "required": [
                "name"
            ],
            "title": "RootElement"
        }
    }
}

This JSON Schema will be converted into the following PHP array shapes docstring:

array{
    name: string,
    age?: int,
}

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.