calcinai/gendarme

Application to generate constrained SKDs based on JSON schemas

v0.1.2 2016-12-01 16:00 UTC

This package is auto-updated.

Last update: 2024-04-14 20:51:11 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.