This example Django app demonstrates the Speakeasy-recommended practices for generating clear OpenAPI specifications and SDKs.
This project was bootstrapped with Django:
django-admin openapi-django books_project
The only requirement is that you have a supported version of Python (version 3.8 or later) installed on your machine.
If you intend to generate an SDK, you'll either need the Speakeasy CLI installed on your machine or be comfortable using the Speakeasy dashboard UI.
- Clone the repository:
git clone https://github.com/speakeasy-api/django-openapi-example.git
- Navigate into the directory:
cd django-openapi-example
- Create a virtual environment and install all dependencies with the following commands:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Apply database migrations:
python manage.py makemigrations
python manage.py migrate
- Start the development server:
python manage.py runserver
- Install Speakeasy CLI on Linux:
curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh
- To generate the OpenAPI specification file in YAML format, run:
python manage.py spectacular --file schema.yaml
- To generate an SDK, run:
speakeasy quickstart
Follow the onscreen prompts to provide the necessary configuration details for your new SDK, such as the name, schema location, and output path. When prompted, enter schema.yaml
for the OpenAPI document location, select a language, and generate.
This project is licensed under the terms of the Apache 2.0 license.