Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rhaqim/restcli
A command line interface written in RUST for generating endpoints that can be tested with CURL, Postman or VS Code's rest-client extension. The tool allows you to select one or more files that contain the applications routes. At the moment the tool works with Gin Gonic in Golang and Flask in Python
https://github.com/rhaqim/restcli
cli curl postman rest rest-client rust
Last synced: 25 days ago
JSON representation
A command line interface written in RUST for generating endpoints that can be tested with CURL, Postman or VS Code's rest-client extension. The tool allows you to select one or more files that contain the applications routes. At the moment the tool works with Gin Gonic in Golang and Flask in Python
- Host: GitHub
- URL: https://github.com/rhaqim/restcli
- Owner: Rhaqim
- Created: 2024-09-08T04:22:27.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-17T21:48:23.000Z (about 2 months ago)
- Last Synced: 2024-10-11T16:01:13.250Z (25 days ago)
- Topics: cli, curl, postman, rest, rest-client, rust
- Language: Rust
- Homepage:
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rest CLI endpoint Generator
This is a simple CLI tool to generate REST API endpoints from defined routes in Python, Rust, Golang and JavaScript files.
## Features
- Generate REST API endpoints for Postman collection, VSCode REST Client, and curl (HTTPie).
- Generate REST API endpoints for Python, Rust, Golang, and JavaScript.## Installation
To install the CLI tool, you can use the following command:
```bash
cargo install --path .
```## Flags
- `--help` - Display help information.
- `-p`, `--postman` - Generate Postman collection.
- `r`, `--rest-client` - Generate VSCode REST Client.
- `-c`, `--curl` - Generate curl commands.
- `url` - The base URL for the REST API. Default is `http://localhost`.
- `port` - The port number for the REST API. Default is `8080`.
- `a`, `--append` - Append the generated REST API endpoints to an existing file.
- `-o`, `--output` - The output file for the generated REST API endpoints. Default is `requests`.## Supported Languages and Frameworks
- Python (Flask)
- Rust (Actix Web)
- Golang (Gin)
- JavaScript (Express)## Example
Here is an example of a Python file with defined routes:
```python
from flask import Flask, request, jsonifyapp = Flask(__name__)
@app.route('/api/v1/hello', methods=['GET'])
def hello():
return jsonify({'message': 'Hello, World!'})@app.route('/api/v1/greet', methods=['POST'])
def greet():
data = request.get_json()
name = data.get('name')
return jsonify({'message': f'Hello, {name}!'})if __name__ == '__main__':
app.run(port=8080)
```You can generate REST API endpoints for this Python file using the following command:
- Single File
```bash
rest-cli -p -r -c --url http://localhost --port 8080 app.py
```- Multiple Files
```bash
rest-cli -p -r -c --url http://localhost --port 8080 app1.py app2.py app3.py
```This will generate the following files:
- `requests.postman_collection.json` - Postman collection.
- `requests.http` - VSCode REST Client.
- `requests.sh` - curl commands.You can import the Postman collection into Postman, open the VSCode REST Client file in VSCode, and run the curl commands in your terminal.