Skip to content

Mount Swagger based REST services as virtual filesystem.

License

Notifications You must be signed in to change notification settings

bkryza/swaggerfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwaggerFS - Use REST services from command line

Usage

Manage local database of REST services under "~/.swaggerfs"

# Add Petstore test service using Swagger specification in local folder
$ swaggerfs add Petstore ./swagger.json http://petstore.swagger.io  --basic-auth alice:secret

# Add Petstore test service using Swagger  specification downloaded from URL
$ curl -sS http://petstore.swagger.io/v2/swagger.json | swaggerfs add Petstore - http://petstore.swagger.io  --api-key BADC0DE

# List registered services
$ swaggerfs list
Petstore

# Show details of a registered service
$ swaggerfs show Petstore
{
    "name": "Petstore",
    "endpoint": "http:\/\/petstore.swagger.io\/v2",
    "credentials": {
        "apikey": "BADC0DE"
    }
}

# Forget registered service
$ swaggerfs forget Petstore

Mount the REST service

$ swaggerfs mount Petstore /mnt/petstore

List service tags

$ ls /mnt/petstore/
pet
store
user

List operations

$ ls /mnt/petstore/store
getInventory
placeOrder
getOrderById
deleteOrder

Invoke GET operation

# curl -X GET --header 'Accept: application/json' 'http://petstore.swagger.io/v2/pet?status=pending'
$ SFS_HEADER="Accept: application/json" cat /mnt/petstore/paths/pet/findByStatus?status=pending

Invoke POST operation

# Export example body content into temporary file
$ cat /mnt/petstore/pet > pet.json && cat pet.json
{
  "id": 0,
  "category": {
    "id": 0,
    "name": "string"
  },
  "name": "doggie",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 1,
      "name": "string"
    }
  ],
  "status": "available"
}

# Edit request with actual values
$ vim pet.json

# Invoke the operation
$ SFS_HEADERS="Content-type: application/json" cat pet.json > /mnt/petstore/pet/addPet

Invoke PATCH operation

# Export example body content into temporary file
$ cat /mnt/petstore/pet/getPetById/123456 > pet.json && cat pet.json
{
  "id": 123456,
  "category": {
    "id": 02,
    "name": "string"
  },
  "name": "doggie",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 1,
      "name": "string"
    }
  ],
  "status": "available"
}


# Edit request with actual values
$ vim pet.json

# Invoke the operation
$ SFS_HEADERS="Content-type: application/json" cat pet.json > /mnt/petstore/pet/updatePet

Unmount the service

fusermount -u /mnt/petstore

License

See LICENSE.

About

Mount Swagger based REST services as virtual filesystem.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published