Schema building
Schema building turns validation rules into a JSON schema that the UI uses for the body editor, live validation and auto fill. The same value objects describe response shapes.
Rules to schema
RulesetProduced by an extraction strategy.SchemaBuilderTurns paths such as user.name or tags.* into objects and arrays.RuleToSchemaMapperSmall processors handle enums, formats, lookups, conditions and rule objects.PropertyBuilderOne value object for each type.BinaryContentInferrerSchemaCarries hints and an optional extraction error.The processors live in Services/RulesMapper/Processors.
Labels from the attributes() method of a Form Request and keys added in prepareForValidation() are read by ReadFormRequestHooksAction. A merged key becomes optional.
Response shapes
The UI asks for the shape of a response through the response shape endpoint.
ResponseSchemaExtractorPaginatedResourceCollectionStrategyJsonResourceStrategySpatieDataObjectResponseStrategyRawJsonResponseStrategyThe resource strategies read the toArray() body through the AST. Where possible they guess the Eloquent model, from the docblock or the resource name, to take column types from the database.
When no strategy applies, InferSchemaFromArrayAction builds the schema from the real response body that the UI sends.
Adding a rule processor
- Add a class in
Services/RulesMapper/Processors. - Call it from
RuleToSchemaMapper. - Cover it with a functional test that feeds rules and asserts the mapped property.
Previous step is route extraction.