Skip to content

amalmurali47/swagroutes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swagroutes

swagroutes is a command-line tool that extracts and lists API routes from Swagger files in YAML or JSON format. It simplifies the process of fetching the routes provided by an API and supports processing multiple files or directories at once.

Install

pip install swagroutes

Upgrade

pip install -U swagroutes

Help

usage: swagroutes [-h] [-o OUTPUT] [-p] input [input ...]

Extract routes from Swagger files.

positional arguments:
  input                 Input file(s) or directory containing Swagger files.

options:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output file to store the results.
  -p, --include-params  Include query parameters in the extracted routes.

Usage

To use swagroutes, simply provide input files or directories containing Swagger files as arguments. The tool will process the files and print the extracted routes.

Single YAML or JSON file

swagroutes file.yaml
swagroutes file.json

Multiple YAML and/or JSON files

swagroutes file1.yaml file2.json

Directory containing Swagger files

swagroutes directory/

Mix of files and directories

swagroutes file1.yaml directory1/ file2.json directory2/

Extract parameters

swagroutes file1.yaml --include-params

Output to a file

Save the extracted routes to an output file using the -o or --output option:

swagroutes file.yaml -o output.txt 

Examples

Input:

basePath: /api
paths:
  /users:
    get: {}
    post: {}
  /profile/{profile_id}:
    put: {}

Output:

GET /api/users
POST /api/users
PUT /api/profile/{profile_id}

Input:

basePath: /api/v1
paths:
  /users:
    get:
      parameters:
        - name: limit
          in: query
        - name: offset
          in: query

  /users/{userId}:
    get:
      parameters:
        - name: userId
          in: path
          required: true
          type: string

Output:

GET /api/v1/users/{userId}
GET /api/v1/users?limit&offset

About

swagroutes is a command-line tool that extracts and lists API routes from Swagger files in YAML or JSON format.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages