This repository demonstrates the following engineering flow for API development:
- Define new endpoint(s) in OpenAPI (found at api/docs/openapi.yaml)
- Generate and run contract tests from spec (see here). They should fail.
- Implement new endpoint(s)
- Repeat Step 2. They should pass!
To build the Docker image containing the API:
docker build -t dino-api:local .
To drop all data and start with a fresh (migrated) database:
rm db/db.sqlite3
docker run -v $(pwd)/db:/usr/app/db dino-api:local python manage.py migrate
To run the API after migrating the database (see above):
docker run -p 8000:8000 -v $(pwd)/db:/usr/app/db dino-api:local
To view the generated API documentation after starting the API (see above), navigate to localhost:8000/api/docs/.
To run contract tests after starting the API (see above):
docker run \
-v $(pwd)/api/docs:/api \
apiaryio/dredd \
dredd /api/openapi.yaml http://host.docker.internal:8000