Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luiscib3r/retrofit_cli
Dart Retrofit API Generator
https://github.com/luiscib3r/retrofit_cli
api-rest bricks cli command-line dart dart-package flutter mason mustache retrofit
Last synced: 1 day ago
JSON representation
Dart Retrofit API Generator
- Host: GitHub
- URL: https://github.com/luiscib3r/retrofit_cli
- Owner: luiscib3r
- License: mit
- Created: 2023-02-06T02:43:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-13T14:45:54.000Z (over 1 year ago)
- Last Synced: 2024-01-28T13:44:36.577Z (9 months ago)
- Topics: api-rest, bricks, cli, command-line, dart, dart-package, flutter, mason, mustache, retrofit
- Language: Dart
- Homepage: https://pub.dev/packages/retrofit_cli
- Size: 36.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## retrofit_cli
Dart [Retrofit](https://pub.dev/packages/retrofit) API Generator (🚧 under
construction 🚧)### Install
```sh
dart pub global activate retrofit_cli
```#### Install from source
```sh
dart pub global activate --source=git https://github.com/luiscib3r/retrofit_cli.git
```or
```sh
git clone https://github.com/luiscib3r/retrofit_cli.git
cd retrofit_cli
make install
```### Usage
#### 1. Define your api using a yaml file
#### Example of `api.yaml`
```yaml
name: Todos
endpoints:
- name: getTodos
method: GET
url: /todos
params:
- name: String
- description: String
- count: int
response: |
[
{
"id": "idstring",
"name": "todo name",
"description": "todo description",
"price": 2.5,
"count": 3
}
]
- name: getTodo
method: GET
url: /todos/{id}
paths:
- id: String
response: |
{
"id": "idstring",
"name": "todo name",
"description": "todo description",
"price": 2.5,
"count": 3
}
- name: saveTodo
method: POST
url: /todos
headers:
- Authorization
payload: |
{
"name": "todo name",
"description": "todo description"
}
response: |
{
"id": "idstring",
"name": "todo",
"description": "desc1",
"price": 0.0,
"count": 0
}
- name: updateTodo
method: PUT
url: /todos/{id}
headers:
- Authorization
paths:
- id: String
payload: |
{
"name": "new todo name",
"description": "new todo description"
}
response: |
{
"id": "idstring",
"name": "new todo name",
"description": "new todo description"
}
- name: deleteTodo
method: DELETE
url: /todos/{id}
headers:
- Authorization
paths:
- id: String
response: |
{}
```#### 2. Generate api package using retrofit_cli
**Default**
```sh
retrofit_cli api
```**Set output package folder (default is api)**
```sh
retrofit_cli api -o api_package_name
```**Set input .yaml file (default is api.yaml)**
```sh
retrofit_cli api -o api_package_name -i my_api.yaml
```