{"id":18000067,"url":"https://github.com/liyu001989/dingo-serializer-switch","last_synced_at":"2025-10-25T22:07:56.905Z","repository":{"id":60774564,"uuid":"95616232","full_name":"liyu001989/dingo-serializer-switch","owner":"liyu001989","description":"A middleware to switch fractal serializers in dingo","archived":false,"fork":false,"pushed_at":"2022-11-23T02:42:25.000Z","size":14,"stargazers_count":48,"open_issues_count":1,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T17:57:57.050Z","etag":null,"topics":["dingo","laravel","serializer","transformer"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liyu001989.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-28T01:33:53.000Z","updated_at":"2023-06-20T16:41:30.000Z","dependencies_parsed_at":"2023-01-23T17:16:36.895Z","dependency_job_id":null,"html_url":"https://github.com/liyu001989/dingo-serializer-switch","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyu001989%2Fdingo-serializer-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyu001989%2Fdingo-serializer-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyu001989%2Fdingo-serializer-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liyu001989%2Fdingo-serializer-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liyu001989","download_url":"https://codeload.github.com/liyu001989/dingo-serializer-switch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038114,"owners_count":21684626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dingo","laravel","serializer","transformer"],"created_at":"2024-10-29T22:16:18.334Z","updated_at":"2025-10-25T22:07:51.865Z","avatar_url":"https://github.com/liyu001989.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dingo Serializer Switch\n\nThis is a middleware for dingo/api to switch serializer\n\nIf a resource's relationship is null, we can return `$this-\u003enull()` in a transformer. But default serializer return [], I think null is better.\nAlso when pagination has no links, default is [], I wish to return null. So I write two serializer to fix this.\n\nIf you want to use default serializer just use `default_array` or `default_data_array`.\n\n## Installation\n\n### Laravel\n\n- `composer require liyu/dingo-serializer-switch`\n\n\n### Lumen\n\n*bootstrap/app.php*\n```php\n$app-\u003erouteMiddleware([\n    // ...\n    'serializer' =\u003e Liyu\\Dingo\\SerializerSwitch::class,\n]);\n```\n\n## Usage\n\n```\n$api-\u003eversion('v1',\n    ['middleware' =\u003e 'serializer:array'],\n    function ($api) {\n});\n\n$api-\u003eversion('v2',\n    ['middleware' =\u003e 'serializer'],\n    function ($api) {\n});\n\n$api-\u003eversion('v3',\n    ['middleware' =\u003e 'serializer:data_array'],\n    function ($api) {\n});\n```\n\ndefault key is data_array, so v2 v3 is same.\n\n```\n'default_array' =\u003e 'League\\Fractal\\Serializer\\ArraySerializer',\n'default_data_array' =\u003e 'League\\Fractal\\Serializer\\DataArraySerializer',\n'json_api' =\u003e 'League\\Fractal\\Serializer\\JsonApiSerializer',\n\n'array' =\u003e 'Liyu\\Dingo\\Serializers\\ArraySerializer',\n'data_array' =\u003e 'Liyu\\Dingo\\Serializers\\DataArraySerializer',\n```\n\n## License\n[MIT LICENSE](https://github.com/liyu001989/dingo-serializer-switch/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyu001989%2Fdingo-serializer-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliyu001989%2Fdingo-serializer-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliyu001989%2Fdingo-serializer-switch/lists"}