You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Json Schema is very powerful tool to verify JSON responses. But it not so user friendly and very verbose. Custom schema definitions and refs makes life a little bit easier but not so much.
I like the way type declarations made in RAML 1.0. It has a lot of sugar, it allows users to define user types, extending primitives. So we need to implement something like this:
$json->matches('UserRegisterRequest');
// or we can use inline type declarations
$json->matches([
'type' => 'UserRegisterRequest',
'properties' => [
'foo' => 'string'
]
]);
Type expressions
Type expressions are fully stolen from RAML:
Type expressions provide a powerful way of referring to, and even defining, types. Type expressions can be used wherever a type is expected. The simplest type expression is just the name of a type. Using type expressions, you can devise type unions, arrays, maps, and other things.
Expression
Description
Person
The simplest type expression: A single type
Person[]
An array of Person objects
string[]
An array of string scalars
string[][]
A bi-dimensional array of string scalars
`string
Person`
`(string
Person)[]`
The text was updated successfully, but these errors were encountered:
Json Schema is very powerful tool to verify JSON responses. But it not so user friendly and very verbose. Custom schema definitions and refs makes life a little bit easier but not so much.
I like the way type declarations made in RAML 1.0. It has a lot of sugar, it allows users to define user types, extending primitives. So we need to implement something like this:
And then we can just use it:
Type expressions
Type expressions are fully stolen from RAML:
The text was updated successfully, but these errors were encountered: