ClientSchema final class
Minn\Rest\ClientSchema · public/minn/src/Minn/Rest/ClientSchema.php · 81 lines
A JSON schema trimmed for a client (probe json-schema): only the keywords a profile allows, in the order given, at every level a sub-schema sits.
A property's boolean required becomes its object's required list (names whose required is true), kept where the object's own required is not a list, appended last otherwise, even where the profile drops required itself; an object's own list wins. A boolean required is always dropped. Sub-schemas are trimmed where they are objects: a keyword's value, a list's members, a map's entries; anything else stays as given.
Constants and properties
| private | DRAFT_04_FIRST = array ( 0 => '$schema', 1 => 'id', 2 => '$ref', ) | |
| private | DRAFT_04_LAST = array ( 0 => 'required', 1 => 'allOf', 2 => 'not', 3 => 'definitions', 4 => 'dependencies', 5 => 'additionalItems', ) | |
| private | MAPS = array ( 0 => 'properties', 1 => 'patternProperties', 2 => 'definitions', 3 => 'dependencies', ) | Keywords whose value maps names to sub-schemas. |
| private | SCHEMAS = array ( 0 => 'items', 1 => 'additionalProperties', 2 => 'additionalItems', 3 => 'not', 4 => 'anyOf', 5 => 'oneOf', 6 => 'allOf', ) | Keywords whose value is a sub-schema or a list of them. |
Public
| static | keywords(string $profile): array# | The keywords a profile keeps: draft-04's whole set, the REST API's for any other profile. @return list<string> | ||||||
| static | trim(array $schema, array $allowed): array# | A schema with only the allowed keywords, keyed by keyword (the values do not matter), trimmed all the way down.
@return array<array-key, mixed> |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | position(mixed $value, array $allowed): mixed# | A sub-schema's place: an object trimmed, a list's object members trimmed, anything else as given. |
| private | member(mixed $value, array $allowed): mixed# | A list member or map entry: trimmed when it is an object schema. |
| private | requiredNames(array $schema): array# | @return list<string> the properties whose required is true |
Nothing matches.