private function getContext(Request $request): SerializationContext
    {
        $fields = $request->get('fields', ['id']);
        $depth = $request->get('depth', 20);
        $depth = is_numeric($depth) ? (int)$depth : 20;

        if (is_string($fields)) {
            $fields = explode(',', $fields);
        }

        $context = new SerializationContext();
        $context->addExclusionStrategy(new FieldsExclusionStrategy($fields));
        $context->addExclusionStrategy(new DepthExclusionStrategy($depth));

        return $context;
    }