{"id":17115755,"url":"https://github.com/pathikrit/metarest","last_synced_at":"2025-09-12T23:40:20.118Z","repository":{"id":26790590,"uuid":"30248922","full_name":"pathikrit/metarest","owner":"pathikrit","description":"Scala macros to generate RESTful Models","archived":false,"fork":false,"pushed_at":"2017-06-01T10:03:08.000Z","size":74,"stargazers_count":195,"open_issues_count":2,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-21T18:03:51.953Z","etag":null,"topics":["rest-api","scala-macros","support-scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pathikrit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-03T15:16:03.000Z","updated_at":"2024-03-17T22:47:18.000Z","dependencies_parsed_at":"2022-09-01T21:12:09.387Z","dependency_job_id":null,"html_url":"https://github.com/pathikrit/metarest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pathikrit/metarest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fmetarest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fmetarest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fmetarest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fmetarest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pathikrit","download_url":"https://codeload.github.com/pathikrit/metarest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pathikrit%2Fmetarest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274894069,"owners_count":25369482,"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","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["rest-api","scala-macros","support-scala"],"created_at":"2024-10-14T17:46:24.849Z","updated_at":"2025-09-12T23:40:20.072Z","avatar_url":"https://github.com/pathikrit.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"MetaRest [![CircleCI](https://img.shields.io/circleci/project/pathikrit/metarest.svg)](https://circleci.com/gh/pathikrit/metarest) [![Download](https://api.bintray.com/packages/pathikrit/maven/metarest/images/download.svg)](https://bintray.com/pathikrit/maven/metarest/_latestVersion)\n--------\nUse Scala macros to generate your RESTy models\n\nLet's say you have the following `User` model in your business layer:\n```scala\ncase class User(id: Int, name: String, email: String, registeredOn: DateTime)\n```\n\nBut, now you want to create well-formed models to describe the requests/responses of your HTTP REST APIs:\n```scala\n// Response to GET /users/$id (Retrieve an existing user)\ncase class UserGet(id: Int, name: String, email: String)\n\n// Request body of POST /users (Create a new user)\ncase class UserPost(name: String, email: String)\n\n//Request body of PATCH /users/$id (Edit name of an existing user)\ncase class UserPatch(name: Option[String])\n```\n\nThat is a lot of boilerplate! Keeping all these request models in sync with your business model and/or adding/removing fields quickly becomes tedious for more complicated models.\nWith MetaRest, all you need to do is:\n```scala\nimport com.github.pathikrit.metarest._\n\n@Resource case class User(\n  @get               id            : Int,\n  @get @post @patch  name          : String,\n  @get @post         email         : String,\n                     registeredOn  : DateTime\n)\n```\n\nThe above annotated code would generate code essentially looking like this:\n```scala\nobject User {\n  case class Get(id: Int, name: String, email: String)\n  case class Post(name: String, email: String)\n  case class Patch(name: Option[String])        // Note: all fields in a PATCH are optional\n}\n```\n\nNow, you can have a well defined CRUD interface for your API:\n```scala\ntrait UserRepo {\n  def getAll: List[User.Get]\n  def get(id: Int): User.Get\n  def create(request: User.Post): User.Get\n  def replace(id: Int, request: User.Put): User.Get\n  def update(id: Int, request: User.Patch): User.Get\n  def delete(id: Int): User.Get\n}\n```\n\n**sbt**\n\nIn your `build.sbt`, add the following entries:\n```scala\nresolvers += Resolver.bintrayRepo(\"pathikrit\", \"maven\")\n\nlibraryDependencies += \"com.github.pathikrit\" %% \"metarest\" % \"2.0.0\"\n\naddCompilerPlugin(\"org.scalameta\" % \"paradise\" % \"3.0.0-M8\" cross CrossVersion.full)\n```\n\nAlthough this library currently only supports Scala 2.11+, [older versions](https://github.com/pathikrit/metarest/tree/a883c674c67a31f9eddf70797328e864f185a714) of this library that used to support Scala 2.10.x are available [here](http://dl.bintray.com/pathikrit/maven/com/github/pathikrit).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Fmetarest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpathikrit%2Fmetarest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathikrit%2Fmetarest/lists"}