Adding a Delete request to OAS

We continue with our musicAPI from the previous lab. The second request to define will delete a playlist using the DELETE method. Here is a sample request: DELETE https://virtserver.swaggerhub.com/Orange-formation/musicAPI/1.0.0/playlist/playlist333

  1. Under paths, add the second path as shown below:
     # Playlists
      /playlist/{playlist-id}:    
        # Delete a playlist 
        delete:
          # Path parameter
          parameters:
            # Playlist id
            - name: playlist-id
              in: path
              required: true
              type: string
     
           # Incomplete response (to finish later)
          responses:
            # Response code
            200:
              description: Successful response
  2. The code above does the following:
    1. Add the path /playlist/{playlist-id} as the next key. It’s the part of the URL after the base path. It should start with a / and contain {playlist-id} to indicate a path parameter.
    2. Add the HTTP method Delete as the next key.
    3. Add the parameters key.
    4. Add the path parameter as a list item. You will need to have keys for name, in, required, and type. Don’t forget that you need a dash at the beginning because even though there’s only one parameter, it’s still considered a list item.
    5. Finally, addd a basic response
  3. Your API documentation contains now a GET and a Delete. Try to invoke the delete method. What is the response code?
  4. This won’t actually work because the API is fictional and there is no resource to delete. But if it were real, then clicking that button would actually make a call to the API and show you the results.