Pet Store CRUD

We will use the Truebit CLI to Create and Test the API Task. Once it's ready, we will deploy it to the coordination hub so that everyone who knows the namespace and taskname.

Step 1. Define The API Manifest

The manifest is already defined within the folder "examples/api-tasks/petstore-crud/manifest.json"".

Step 2. Test The API Task

Execute the start-api command to test the manifest.

Add a New Record Using POST Verb

truebit start-api truebit-nextgen-examples/api-tasks/petstore-crud/manifest.json truebit-nextgen-examples/api-tasks/petstore-crud/post.add.input.json 

Output

Executing the API Task
API Task executed with status - OK 

Input request :
{
  "path": "/store/order",
  "method": "POST",
  "body": {
    "id": 2,
    "petId": 198772,
    "quantity": 7,
    "shipDate": "2077-08-24T14:15:22Z",
    "status": "approved",
    "complete": true
  },
  "headers": {}
}

Base URL = https://petstore.swagger.io/v2 
OpenAPI manifest check - OK 

API Task response
{
  "id": 2,
  "petId": 198772,
  "quantity": 7,
  "shipDate": "2077-08-24T14:15:22.000+0000",
  "status": "approved",
  "complete": true
}

Retrieve The Record Using GET Verb

Output

Update The Record Using The POST Verb

Output

Delete The Record Using The DELETE Verb

Output

Step 3. Create The API Task

Execute the create-api command against the Truebit Verify Node to execute the endpoint.

Output

Step 4. Deploy The API Task

Last but not least, please go ahead and execute the deploy command to deploy the API task to the coordination hub, so that anyone with the taskId can use it.

  • [taskId]: Add the taskId generated in step 3

Output

Last updated

Was this helpful?