Swagger specification

  1. Here's the outline of the Swagger specification:
        
specification = { 
            'swagger': '2.0', 
            'info': { 
                'title': '''Python Cookbook\nChapter 10, recipe 6.''', 
                'version': '1.0' 
            }, 
            'schemes': ['http'], 
            'host': '127.0.0.1:5000', 
            'basePath': '/dealer', 
            'consumes': ['application/json'], 
            'produces': ['application/json'], 
            'paths': { 
                '/players': {...}, 
                '/players/{id}': {...}, 
            } 
            'definitions': { 
                'player: {..} 
            } 
        } 

The first fields are essential boilerplate for RESTful web services. The paths and definitions will be filled in with the URLs and the schema definitions that are part of the service.

  1. Here's the schema definition used to validate a new player. This goes inside the definition of the overall specification:
 'player': { 'type': ...

Get Modern Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.