swama

command module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 6 Imported by: 0

README

Swama CLI Tool

Swama is a simple CLI tool to list, view, and convert Swagger API endpoints. It helps you explore the API structure from a Swagger/OpenAPI specification file and convert API requests into common formats like curl, fetch.

Features

  • List: Display all API endpoints from a Swagger file in a structured table format.
  • View: View detailed information about a specific API endpoint.
  • Convert: Convert an API endpoint into curl, fetch request formats.

Installation

You can install swama by cloning the repository and building the binary:

git clone https://github.com/idsulik/swama
cd swama
go build -o swama

Ensure that the binary is placed in a directory included in your PATH.

Usage

Swama provides several commands for interacting with your Swagger/OpenAPI file:

General Usage
swama [command]
Available Commands
  • completion: Generate the autocompletion script for your shell.
  • convert: Convert an API endpoint to different request formats (e.g., curl, fetch).
  • list: Lists all API endpoints in a structured table format.
  • view: View details about a specific API endpoint.
  • help: Show help for commands.
Global Flags
  • -f, --file: Path to the Swagger JSON/YAML file. If omitted, swama will attempt to locate the Swagger file in the current directory.
  • -h, --help: Display help for the swama CLI.
Examples
List all endpoints
swama list -f ./swagger.json

This command lists all API endpoints defined in the swagger.json file.

Output example grouped by tag:

preview1

Output example grouped by method:

preview2

View details of a specific endpoint
swama view -f ./swagger.json --endpoint /api/users

This command will display detailed information about the /api/users endpoint.

Convert an endpoint to a curl command
swama convert -f ./swagger.json --endpoint /api/users --type curl

This command converts the /api/users endpoint to a curl command.

Generate shell autocompletion

You can generate autocompletion scripts for your shell (e.g., bash, zsh, fish):

swama completion bash > /etc/bash_completion.d/swama

More Information

For more details on each command, use the --help flag with the command:

swama [command] --help

For example:

swama list --help

Contributing

Feel free to contribute to this project by submitting issues or pull requests at the official GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Swama simplifies exploring and interacting with your Swagger-defined API, making it easier to understand and test API endpoints quickly.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL