{"id":21067978,"url":"https://github.com/jgsamudio/modelsynchro","last_synced_at":"2025-05-16T03:32:55.968Z","repository":{"id":62447939,"uuid":"112242899","full_name":"jgsamudio/ModelSynchro","owner":"jgsamudio","description":"A JSON model generator for Swift 4","archived":false,"fork":false,"pushed_at":"2019-02-16T16:58:19.000Z","size":18471,"stargazers_count":21,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-18T11:00:15.059Z","etag":null,"topics":["generator","json","model"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/jgsamudio.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-11-27T20:07:21.000Z","updated_at":"2023-06-23T14:55:06.000Z","dependencies_parsed_at":"2022-11-01T23:03:09.928Z","dependency_job_id":null,"html_url":"https://github.com/jgsamudio/ModelSynchro","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgsamudio%2FModelSynchro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgsamudio%2FModelSynchro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgsamudio%2FModelSynchro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgsamudio%2FModelSynchro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgsamudio","download_url":"https://codeload.github.com/jgsamudio/ModelSynchro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225402661,"owners_count":17468837,"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":["generator","json","model"],"created_at":"2024-11-19T18:13:33.510Z","updated_at":"2024-11-19T18:13:34.267Z","avatar_url":"https://github.com/jgsamudio.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ModelSynchro | [![Build Status](https://travis-ci.org/jgsamudio/ModelSynchro.svg?branch=master)](https://travis-ci.org/jgsamudio/ModelSynchro)\n\n## Description\n\nAn automated way to generate network models from JSON and keep them up to date.\n\n[Logic Diagram](https://www.lucidchart.com/invitations/accept/d9a748ce-7ffd-463a-abcd-716f6914a8d5).\n\n## Installation\n\n### CocoaPods\n\nModelSynchro is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```\npod 'ModelSynchro'\n```\n\nAfter adding the ModelSynchro to your Podfile, add the following script as a run script in your Build Phases.\n\n```\n\"${PODS_ROOT}/ModelSynchro/ModelSynchro/Source/ModelSynchro\" -projectDirectory ${SRCROOT}/\n```\n\nNext, you will need to configure a custom configuration.json file and add it to the root of your project.\n\n```\n{\n  \"authorName\" : \"Jonathan Samudio\",\n  \"companyName\" : \"Prolific Interactive\",\n  \"projectName\" : \"MyProject\",\n  \"language\" : \"swift\",\n  \"outputDirectory\" : \"MyProject/Models/\",\n  \"localJSONDirectory\" : [\n    {\n        \"inputDirectory\" : \"SampleJSON1/\",\n        \"outputDirectory\" : \"SampleJSONOutput1/\"\n    },\n    {\n        \"inputDirectory\" : \"SampleJSON2/\",\n        \"outputDirectory\" : \"SampleJSONOutput2/\"\n    }\n  ],\n  \"endpoints\" : [\n    {\n      \"url\" : \"https://facebook.github.io/react-native/movies.json\",\n      \"name\" : \"Movies\"\n    },\n    {\n      \"url\" : \"https://facebook.github.io/react-native/movies.json\",\n      \"name\" : \"Movies\"\n    }\n  ],\n  \"mappedModelNames\" : [\n    {\n        \"jsonKey\" : \"filters\",\n        \"mappedName\" : \"Filter\"\n    },\n    {\n        \"jsonKey\" : \"event_guests\",\n        \"mappedName\" : \"EventGuest\"\n    },\n    {\n        \"jsonKey\" : \"event\",\n        \"mappedName\" : \"RegistrationEvent\"\n    },\n    {\n        \"fileName\": \"Event\",\n        \"mappedName\": \"MappedEvent\"\n    }\n  ]\n}\n```\n\n### Manual Installation\n\nTo run the application manually, run the following command.\n\n```\n[Directory to ModelSynchro source]/ModelSynchro -projectDirectory [Root Project Directory]\n```\n\n## Custom Keys\n\nIf the variable names from the api are not what you wish to use as variable names for your models, then ModelSynchro allows you to mark and make updates to your model variable names. Take the `swift` model below as an example.\n\n```\nstruct Book: Codable {\n\tlet author: String\n\tlet id: Int\n\n\tenum CodingKeys: String, CodingKey {\n\t\tcase author = \"author\"\n\t\tcase id = \"id\"\n\t}\n}\n```\n\nIf you would like to change `id` to `bookId` then all we need to do is change the variable name from `id` to `bookId` and mark the line with a `//` after the variable declaration. In addition, the `id` case in the `CodingKeys` will need to be changed to `bookId`.   \n\n```\nstruct Book: Codable {\n\tlet author: String\n\tlet bookId: Int //\n\n\tenum CodingKeys: String, CodingKey {\n\t\tcase author = \"author\"\n\t\tcase bookId = \"id\"\n\t}\n}\n```\n\n## Custom Model Names\n\nBy default, the name of the swift network model will be set to the name of the local JSON file or the keys of the JSON object for sub-models. If you would like to change the name of the model to something else add the `mappedModelNames` object to the configuration file. Here you can add the JSON key or filename along with the mapped name.\n\n```\n\"mappedModelNames\" : [\n    {\n        \"jsonKey\" : \"filters\",\n        \"mappedName\" : \"Filter\"\n    },\n    {\n        \"jsonKey\" : \"event_guests\",\n        \"mappedName\" : \"EventGuest\"\n    },\n    {\n        \"jsonKey\" : \"event\",\n        \"mappedName\" : \"RegistrationEvent\"\n    },\n    {\n        \"fileName\": \"Event\",\n        \"mappedName\": \"MappedEvent\"\n    }\n]\n```\n\n## Languages\n\nAs of now `swift` is supported as the primary language to generate models. `objective-c` is also available, however is currently in beta. To add a custom language please refer to the LanguageFormatter protocol to create a new language formatter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgsamudio%2Fmodelsynchro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgsamudio%2Fmodelsynchro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgsamudio%2Fmodelsynchro/lists"}