Viscacha.CLI
1.1.0
dotnet tool install --global Viscacha.CLI --version 1.1.0
dotnet new tool-manifest
dotnet tool install --local Viscacha.CLI --version 1.1.0
#tool dotnet:?package=Viscacha.CLI&version=1.1.0
nuke :add-package Viscacha.CLI --version 1.1.0
Viscacha CLI
A simple command-line tool for quickly testing REST API endpoints defined in YAML files. It supports variable substitution, authentication, and response handling, making it easy to automate and test API interactions.
Features
- Execute HTTP requests defined in YAML files.
- Supports multiple HTTP methods (GET, POST, PUT, PATCH, DELETE, etc.).
- Variable substitution from environment variables, command-line arguments, and previous responses.
- Supports authentication methods:
- API Key Authentication
- Azure Credentials Authentication
- Easy-to-read JSON formatted responses.
Usage
viscacha <yaml-file> [--var name=value ...]
Example
viscacha requests.yaml --var userId=123 --var token=abcdef
YAML File Structure
You can define requests in YAML files as follows:
defaults:
baseUrl: https://api.example.com
headers:
Accept: application/json
authentication:
type: api-key
key: ${API_KEY}
requests:
- method: GET
path: /users/{{userId}}
- method: POST
path: /users
contentType: application/json
body: |
{
"name": "John Doe",
"email": "john@example.com"
}
Variable Substitution
- Environment variables:
${env:VARIABLE_NAME} - Command-line variables:
${variableName} - Response variables:
#{r0.propertyName}(wherer0is the response from the first request)
Authentication Examples
API Key Authentication
authentication:
type: api-key
key: your-api-key
header: X-Api-Key
prefix: Bearer
Azure Credentials Authentication
authentication:
type: azure-credentials
scopes:
- https://management.azure.com/.default
Importing Defaults
You can import default settings from another YAML file using the import property within the defaults section. This allows you to reuse common configurations across multiple YAML files.
Example:
defaults:
import: common-defaults.yaml
Additionally, defaults can be imported from the command line:
viscacha <request-file> --defaults <defaults-file>
If defaults are provided using multiple mechanisms, the order of precedence is as follows: first, those provided via the command line, then those embedded in the file, and finally those imported in the file.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.