{"id":15010128,"url":"https://github.com/alisinabh/prex","last_synced_at":"2025-04-09T17:54:05.746Z","repository":{"id":57536427,"uuid":"94489937","full_name":"alisinabh/prex","owner":"alisinabh","description":"REST API client scaffolder for elixir","archived":false,"fork":false,"pushed_at":"2017-06-24T05:51:47.000Z","size":53,"stargazers_count":5,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T12:56:20.935Z","etag":null,"topics":["apiblueprint","elixir","mix-tasks","rest-client","under-development"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/alisinabh.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-16T00:39:05.000Z","updated_at":"2024-11-11T16:46:56.000Z","dependencies_parsed_at":"2022-08-29T00:41:27.571Z","dependency_job_id":null,"html_url":"https://github.com/alisinabh/prex","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisinabh%2Fprex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisinabh%2Fprex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisinabh%2Fprex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisinabh%2Fprex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisinabh","download_url":"https://codeload.github.com/alisinabh/prex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248083558,"owners_count":21045122,"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":["apiblueprint","elixir","mix-tasks","rest-client","under-development"],"created_at":"2024-09-24T19:30:29.686Z","updated_at":"2025-04-09T17:54:05.730Z","avatar_url":"https://github.com/alisinabh.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prex\n[![Status](https://img.shields.io/badge/status-under%20development-red.svg)]()\n[![Build Status](https://travis-ci.org/alisinabh/prex.svg?branch=master)](https://travis-ci.org/alisinabh/prex)\n\nTasks for generating api interfaces in elixir from ApiBlueprint files.\n\n\u003e And you don't feel much like ridin', You just wish the trip was through...\n\n**This project is under development and in experimental stage**\n\n## What is ApiBlueprint?\n\nAccording to [ApiBlueprint.org](https://apiblueprint.org/)\n\n\u003e API Blueprint is a powerful high-level API description language for web APIs.\n\nSo in an ApiBlueprint file (.apib) there is information on Actions and their parameters.\n\n## What Prex does?\n\nPrex can convert .apib files to equivalant elixir code as a bootstrap with .apib documents.\n\nIt can help you spend your time mostly on your issues instead of developing API client.\n\n## How prex Does it?\n\n1. Simply add ``:prex`` as dev only dependency in your project like this:\n\n```elixir\ndef deps do\n  [{:prex, \"~\u003e 0.0.2\", only: :dev, runtime: false}]\nend\n```\n\n2. Install ``drafter``(ApiBlueprint parser): [github.com/apiaryio/drafter](https://github.com/apiaryio/drafter#install)\n3. Run ``mix deps.get`` and ``mix deps.compile``\n4. Now you can run ``mix prex.gen.from_blueprint [path to .apib file] [name for api]``\n5. Tadaa! A file like this is now generated in lib directory of your project\n\n```elixir\n# Created by Prex\ndefmodule Newapi.User do\n  @moduledoc \"\"\"\n  Represents user details.\n\n  ---\n\n  **User attributes:**\n\n  - id `(Number)` : unique identifier.\n\n  - fname `(String)` : First Name.\n\n  - lname `(String)` : Last Name.\n\n  - email `(String)` : email id of the user.\n\n  ---\n  \"\"\"\n\n  @base_url \"http://sample.pandurangpatil.com\"\n\n  ###\n  # API Calls\n  ###\n\n  # User Collection\n\n  @doc \"\"\"\n  Retrieve paginated list of users.\n\n  ## Parameters\n    - since: Timestamp in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ` Only users updated at or after this time are returned.\n    - limit: maximum number of records expected by client.\n  \"\"\"\n  def list_all_users(since \\\\ nil, limit \\\\ nil) do\n    req_url = Path.join @base_url, \"/users?limit=#{limit |\u003e URI.encode_www_form}\" \u003c\u003e\n     (if since != nil, do: \"since=#{since |\u003e URI.encode_www_form}\", else: \"\")\n\n    HTTPoison.request(:get, req_url, body: Poison.encode!(%{\"since\" =\u003e since, \"limit\" =\u003e limit}), headers: [\"Content-Type\": \"application/json\"])\n  end\n\n  def list_all_users!(since \\\\ nil, limit \\\\ nil) do\n    {:ok, result} = list_all_users(since, limit)\n    result\n  end\n\n  @doc \"\"\"\n\n  \"\"\"\n  def create_a_user do\n    req_url = Path.join @base_url, \"/users{?since,limit}\"\n    HTTPoison.request(:put, req_url)\n  end\n\n  def create_a_user! do\n    {:ok, result} = create_a_user()\n    result\n  end\n\n  # User\n\n  @doc \"\"\"\n\n\n  ## Parameters\n    - id: Numeric `id` of the User to perform action with.\n  \"\"\"\n  def retrieve_a_user(id) do\n    req_url = Path.join @base_url, \"/users/?id=#{id |\u003e URI.encode_www_form}\"\n\n    HTTPoison.request(:get, req_url, body: Poison.encode!(%{\"id\" =\u003e id}), headers: [\"Content-Type\": \"application/json\"])\n  end\n\n  def retrieve_a_user!(id) do\n    {:ok, result} = retrieve_a_user(id)\n    result\n  end\n\n  @doc \"\"\"\n  Update user details\n\n  ## Parameters\n    - id: Numeric `id` of the User to perform action with.\n  \"\"\"\n  def update_a_user(id) do\n    req_url = Path.join @base_url, \"/users/?id=#{id |\u003e URI.encode_www_form}\"\n\n    HTTPoison.request(:post, req_url, body: Poison.encode!(%{\"id\" =\u003e id}), headers: [\"Content-Type\": \"application/json\"])\n  end\n\n  def update_a_user!(id) do\n    {:ok, result} = update_a_user(id)\n    result\n  end\n\n  @doc \"\"\"\n\n\n  ## Parameters\n    - id: Numeric `id` of the User to perform action with.\n  \"\"\"\n  def remove_a_user(id) do\n    req_url = Path.join @base_url, \"/users/?id=#{id |\u003e URI.encode_www_form}\"\n\n    HTTPoison.request(:delete, req_url, body: Poison.encode!(%{\"id\" =\u003e id}), headers: [\"Content-Type\": \"application/json\"])\n  end\n\n  def remove_a_user!(id) do\n    {:ok, result} = remove_a_user(id)\n    result\n  end\n\nend\n```\n\n## Documents\n\nCurrently docs for mix task and usage is not available!\n\n[Full documents](https://hexdocs.pm/prex).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisinabh%2Fprex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisinabh%2Fprex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisinabh%2Fprex/lists"}