You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example of the metadata and server routes sections of an OpenAPI specification - YAML
openapi: 3.0.0info:
title: Music Bands APIdescription: Provides information about music bands. This description supports [CommonMark](http://commonmark.org/) or HTML syntax.version: 1.2.1servers:
- url: http://api.rockbands.io/v1description: Main (production) server # This description is optional
- url: http://staging-api.rockbands.iodescription: Internal staging server for testing # This description is optional
Example of the paths section of an OpenAPI specification - YAML
paths:
/bands/{band_id}:
description: Returns a band by its id, and optionally its location detailsparameters:
- name: band_idin: pathrequired: truedescription: the band identifierschema:
type: integer
- name: includeLocationin: querydescription: whether to return the band's locationrequired: falseschema:
type: booleanget:
responses:
'200':
description: the band being returnedcontent:
application/json:
schema:
type: objectproperties:
id: # the unique band idtype: integername: # the band's nametype: stringformat: binarylocation: # the band's locationtype: stringformat: binary
Example of the implementation of an API path in Python, as defined in an excerpt of an OpenAPI specification - Python script
@app.route('/bands/{band_id}', method= ['GET'])defband(band_id):
"""Returns a band by its id, and optionally its location details"""includeLocation=request.args['includeLocation'] # Capture the optional query parameterresult=db.select('bands', band_id, includeLocation)
... # Some result post-processing as neededresponse= {'id': result.id, 'name': result.name , 'location' : result.location }
returnjsonify(response)
Query that retrieves all rock bands in Wikidata - SPARQL