protected function getSubResources(JsonDefinition $definition)
    {
        $resources = [];
        foreach ($definition->getFields() as $field) {
            while ($field instanceof JsonDefinitionArray) {
                $field = $field->getElement();
            }
            if (!$field instanceof JsonDefinitionHash) {
                continue;
            }

            $subDefiniton = $field->getJsonDefinition();

            $resources = array_merge($this->getSubResources($subDefiniton), $resources);
            $resources[] = $subDefiniton;
        }

        return $resources;
    }