{"id":20492561,"url":"https://github.com/redmadrobot/service-autograph","last_synced_at":"2025-04-13T17:01:59.812Z","repository":{"id":63920387,"uuid":"113958221","full_name":"RedMadRobot/service-autograph","owner":"RedMadRobot","description":"Service generation utility.","archived":false,"fork":false,"pushed_at":"2018-06-29T04:03:08.000Z","size":12,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-03-14T22:22:57.750Z","etag":null,"topics":["code-generation","ios","macos","service","soa","sourcekit","swift","template"],"latest_commit_sha":null,"homepage":"","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/RedMadRobot.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-12-12T07:31:27.000Z","updated_at":"2021-12-27T09:20:45.000Z","dependencies_parsed_at":"2023-01-14T14:00:40.643Z","dependency_job_id":null,"html_url":"https://github.com/RedMadRobot/service-autograph","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fservice-autograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fservice-autograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fservice-autograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2Fservice-autograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedMadRobot","download_url":"https://codeload.github.com/RedMadRobot/service-autograph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224819488,"owners_count":17375275,"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":["code-generation","ios","macos","service","soa","sourcekit","swift","template"],"created_at":"2024-11-15T17:29:38.268Z","updated_at":"2024-11-15T17:29:39.232Z","avatar_url":"https://github.com/RedMadRobot.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Service Autograph\n\nService and object parser generation utility based on [Autograph](https://github.com/RedMadRobot/autograph) and [Synopsis](https://github.com/RedMadRobot/synopsis) frameworks.\n\n# Usage\n## Prepare your sources\n\nMark your service protocols like this:\n\n```swift\n/**\n MANDATORY SERVICE ANNOTATION:\n @service PersonServiceGen\n \n YOU MAY OMIT THE EXPLICIT SERVICE NAME\n */\nprotocol PersonService {\n\n    /**\n     EACH SERVICE METHOD MUST RETURN ServiceCall\u003c\u003e OR CancelableServiceCall\u003c\u003e\n     \n     `GET` IS A DEFAULT HTTP METHOD.\n     */\n    func get() -\u003e ServiceCall\u003c[Person]\u003e\n    \n    /**\n     PROVIDE RELATIVE URL\n     @url /{id}\n     \n     BASE URL IS INJECTED BY CONSTRUCTOR\n     */\n    func get(\n        personId id: Int // MARK ARGUMENTS TO BE INSERTED INTO URL PLACEHOLDERS: @url\n    ) -\u003e ServiceCall\u003cPerson\u003e\n    \n    /**\n     SUPPORTED HTTP METHODS: get, post, put, patch, delete, head, options\n     @post\n     \n     USE CancelableServiceCall\u003c\u003e WHEN CALL CANCELING OPTION IS REQUIRED\n     \n     KEEP IN MIND YOU CAN USE Void IN CASE YOU DON'T NEED SERVER RESPONSE TO BE PARSED\n     */\n    func register(\n        firstName: String, // @json first_name\n        lastName: String   // @json last_name\n    ) -\u003e CancelableServiceCall\u003cVoid\u003e\n    \n    /**\n     SUPPORTED ARGUMENT SERIALIZATION OPTIONS: json, query, plist, url, header\n     \n     ARGUMENT BODY NAME IS AN IMPLICIT ANNOTATION VALUE\n     \n     @put\n     */\n    func auth(\n        token: String // @header X-Auth-Header\n    ) -\u003e ServiceCall\u003cString\u003e\n    \n}\n```\n\n**Service Autograph** will generate concrete implementations for each of your service protocols and also a supporting `Service.swift` file.\n\n**Service Autograph** can also generate a generic `object parser` utility class for you, and also `Decodable` extensions for each of your models.\nIn order to do so, use corresponding `-write_parser` argument.\n\n## Build executable\n\nRun `spm_build.command` script in order to build from sources.\n\nYou'll find your `ServiceAutograph` executable in `./build/x86_64-apple-macosx10.10/release` folder or similar, depending on your OS.\n\n## Add run script build phase to your project\n\nRun `ServiceAutograph` executable before other build phases, so that new generated source code would be taken into the process.\nThe utility accepts next arguments:\n\n* `-help` — print help, do not execute;\n* `-verbose` — print additional debug information;\n* `-write_parser` — turn on object parser generation;\n* `-input_model [folder]` — path to the folder with your model classes and structures (used during parser generation);\n* `-input_service [folder]` — path to the folder with your service protocols;\n* `-output [folder]` — path to the folder, where to put generated files.\n\nYour script may look like this:\n\n```bash\nSERVICE_AUTOGRAPH_PATH=Utilities/ServiceAutograph\n\nif [ -f $SERVICE_AUTOGRAPH_PATH ]\nthen\n    echo \"ServiceAutograph executable found\"\nelse\n    osascript -e 'tell app \"Xcode\" to display dialog \"Service generator executable not found in \\nUtilities/ServiceAutograph\" buttons {\"OK\"} with icon caution'\nfi\n\n$SERVICE_AUTOGRAPH_PATH \\\n    -write_parser \\\n    -input_model \"$PROJECT_NAME/Classes/Model\" \\\n    -input_service \"$PROJECT_NAME/Classes/Service\" \\\n    -output \"./$PROJECT_NAME/Generated/Classes\"\n```\n\n## Demo \u0026 running tests\n\nUse `spm_resolve.command` to load all dependencies and `spm_generate_xcodeproj.command` to assemble an Xcode project file.\nAlso, ensure Xcode targets macOS.\n\nRun `spm_run_sandbox.command` script for a demo — it builds and launches **Service Autograph** with `Sources/Sandbox` as a working directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Fservice-autograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredmadrobot%2Fservice-autograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Fservice-autograph/lists"}