For this exercise, you’ll use the Swagger editor in SwaggerHub to document some simple requests of an API. Let’s say you were writing an OAS file to define an API for a music service. Let’s define two requests: one to retrieve a list of playlists, and another to delete a playlist.
# Endpoints paths: # Playlists /playlist: # Get one or more playlists get: # Query parameters parameters: # Number to return - name: limit in: query required: false type: integer # Number to skip - name: offset in: query required: false type: integer # Search term - name: search in: query required: false type: string
Query parameter | Required | Definition |
---|---|---|
limit | false | Number of playlists to return |
offset | false | Index of the first playlist to return. (0=start at the beginning, 10 = skip the first 10, etc.) |
search | false | Return playlists whose name contains this string |
# Endpoints paths: # Playlists /playlist: # Get one or more playlists get: # Query parameters parameters: # Number to return - name: limit in: query required: false type: integer # Number to skip - name: offset in: query required: false type: integer # Search term - name: search in: query required: false type: string responses: # Response code 200: description: Successful response