Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/plong-wasin/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.
https://github.com/plong-wasin/json-schema-to-php-docstring

docstring documentation json-schema php php-docblock php-document php-documentation phpstan

Last synced: 8 days ago
JSON representation

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.

Awesome Lists containing this project

README

        

# 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](https://app.quicktype.io?l=schema) (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](https://plong-wasin.github.io/json-schema-to-php-docstring/).

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:

```json
{
"$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:

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

## License

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