Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Interact with code generation events - inject custom rules #859

@GeorgII-web

Description

@GeorgII-web

Is your feature request related to a problem? Please describe.
How to get event when JSON schema property

   "id": {
      "type": "integer",
      "minimum": 1,
      "description": "The unique identifier for a user"
    },

converted to a PHP class property

    /**
     * The unique identifier for a user
     *
     * @var int
     */
    protected int $id;

to customize the code.
In this case expected minimum: 1 should be @var positive-int but @var int given

Describe the solution you'd like
Some event listener, in which, will be possible to get:

  • JSON schema property
  • Generated PHP class entities related to schema
  • Manipulate it on the fly

Additional context
positive-int is just a simple example, in general, to have a tool to customize generated code and to make Jane more powerful.

For example:

  • adding a validation: we have JSON schema and related data, why not validate it using existing packages
  • add some psalm rules and tags
  • some strict types in doc-block like int<10,100>, non-empty-string
  • adding a custom methods
  • interact with namespaces, traits, extending class
  • etc.

The only way found for this moment is: to modify classes after generation, but it needs an additional step to read JSON schema again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions