calcinai / gendarme
Application to generate constrained SKDs based on JSON schemas
Requires
- icanboogie/inflector: ^1.4
- justinrainbow/json-schema: ^3.0
- nikic/php-parser: ^2.1
- symfony/console: ^3.1
This package is auto-updated.
Last update: 2024-12-14 22:29:16 UTC
README
A tool for creating PHP data structures from JSON Schemas.
Setup
via composer
composer create-project calcinai/gendarme
Usage
From the project root:
./bin/gendarme generate --namespace [TARGET_NAMESPACE] --root-class [ROOT_CLASS] [SCHEMA_FILE].json [OUTPUT_DIR]
Output
All models will be PSR-4 compliant based on the arguments given at runtime. A typical output folder structure will be as follows:
- OUTPUT_DIR
- BaseSchema.php (the class all models extend)
- RootClass.php (the --root-class argument)
- Definitions
- ...
- ...
This project was started to generate the schema files for Strut, a Swagger/OAPI manipulation library. Although a very complex example, it shows the basic output structure that will be generated.
The generated models will include type-hinting to other models where possible, and non-hintable objects will be put in the doc blocks. At this point, many, but not all schema keywords are parsed. As more desired functionality is identified, more can be implemented.