On Thu, Jul 24, 2025, at 1:51 AM, Alexandre Daubois wrote:
> Hi Jakub,
>
> Le mer. 23 juil. 2025 à 17:41, Jakub Zelenka <bu...@php.net> a écrit :
>> In addition it could be useful to create it from array or from class (sort 
>> of auto generate schema)
>
> Writing schema by hand is painful, so that would be amazing to see
> this feature land one day.

I've done a little class <--> schema translation work in the past; this is much 
harder than it sounds. :-)  JSON Schema is considerably more complex/robust 
than PHP classes, so translating between the two is a challenge.  (Maybe set 
hooks could cover some cases now? Hm.)  Class->schema would be easier, but in 
that case I think it would be better to either leave to user-space (it would 
just be a bit of reflection work) or if it's in the core API to make it a 
separate operation from schema validation.  It's simple enough for a user to 
plug those two operations together themselves when appropriate.

--Larry Garfield

Reply via email to