Skip to content

Latest commit

 

History

History
85 lines (55 loc) · 2.01 KB

README.md

File metadata and controls

85 lines (55 loc) · 2.01 KB
Speakeasy Logo

Speakeasy Django OpenAPI Example

This example Django app demonstrates Speakeasy-recommended practices for generating clear OpenAPI specifications and SDKs.

This project was bootstrapped with Django:

django-admin openapi-django books_project

Prerequisites

The only pre-requisite needed is a supported version of Python installed, we recommend a version greater than 3.8.

If you intend to generate an SDK, you'll need the Speakeasy CLI installed, or use the Speakeasy dashboard.

Installation

  1. Clone the repository:
git clone https://github.com/speakeasy-api/django-openapi-example.git
  1. Navigate into the directory:
cd django-openapi-example
  1. Create a virtual environment and install all dependencies with:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Running the application

  1. Apply database migrations:
python manage.py makemigrations
python manage.py migrate
  1. Start the development server:
python manage.py runserver

Working with the OpenAPI specification

  1. Install Speakeasy CLI on Linux:
curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh
  1. To generate the OpenAPI specification file in YAML format, run:
python manage.py spectacular --file schema.yaml
  1. 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. Enter schema.yaml when prompted for the OpenAPI document location, select a language and generate.

License

This project is licensed under the terms of the Apache 2.0 license.