Skip to content

Repository with code examples for my presentation at PyCon India 2021

Notifications You must be signed in to change notification settings

abunuwas/pycon-india-2021

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyCon India 2021, 17-19 September 2021

Delivering successful API integrations with documentation-driven development

Author: Jose Haro Peralta

image image

Full stack consultant

Co-founder of microapis.io

  • 35% discount code: ctwpyconin21
  • Download two chapters of the book for free from this link.

How to work with this repo

This repo provides examples for my talk at PyCon India 2021, titled "Delivering successful API integrations with documentation-driven development". The code includes the implementation of a simple TODO REST API in Python, using the popular FastAPI framework. The specification for the API is included under the oas.yaml file. To set up the environment required to run the code in this repo, make sure you have:

  • Python 3.9 together with pipenv
  • node.js version 12 or higher

To install the dependencies, run the following commands:

$ pipenv install --dev
$ yarn

This will install the Python dependencies required to run and test the app, as well as the npm dependencies that we use for furhter testing and for server mocking.

To activate the Python environment, run the following command:

$ pipenv shell

Now you can run the TODO API with the following command:

$ uvicorn todo.server:server

To run the Dredd test suite, run the following command:

$ ./node_modules/.bin/dredd oas.yaml http://127.0.0.1:8000 --server "uvicorn todo.server:app" --hookfiles=./hooks.py --language=python 

To run the schemathesis test suite, run the following command, while running the FastAPI server with the uvicorn command show earlier (uvicorn todo.server:server):

$ schemathesis run oas.yaml --base-url=http://localhost:8000 --stateful=links

If you wish to set up your own Travis CI server to test this code, make sure you create a Heroku app with a valid name, include the name of the app in the deployment file, and run the following command to encrypt your deployment key:

$ travis --encrypt $(heroku auth:token) --add deploy.api_key --pro

About

Repository with code examples for my presentation at PyCon India 2021

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages