Building better APIs: from Django to client libraries with OpenAPI

tl;dr

A summary of resources and learnings related to building REST API I put together over the last couple of years. Complete API development workflow from Django backend to frontend clients using Django REST Framework, drf-spectacular for OpenAPI spec generation, and automated client generation with openapi-generator. Big productivity boost!

There is a lot of discussion about frameworks for building REST APIs, some of them being even able to generate OpenAPI specs directly for you. Django is not quite known for that, but there are ways of doing this by automating most of the process while being very productive and offering your team a clean developer experience.

Overview

The stack I prefer makes use of several additional modules you will require: django-rest-framework and drf-spectacular alongside Django. REST Framework helps you extend your application in order to have a REST API, while drf-spectacular will help you the ability to generate the OpenAPI spec (standalone post: Create OpenAPI spec for Django REST Framework APIs.

After having the OpenAPI spec, you can generate clients with openapi-generator. Here is an example I mapped out of generating an Angular client:

Step-by-step process

There is also a recording from my GLT 2025 talk where I summarize most of these ideas.

<figure> <figcaption>Building Better APIs - From Django to Client Libraries with OpenAPI</figcaption> </figure>

In case you want to follow along, here is a step-by-step guide from the repository I showed during the presentation:

From the last step, you can generate the API clients for the platform you require. You can follow the README and the examples available in my glt25-client repository.

Maintaining compatibility over time

The final tool you can use is openapi-diff, which will help you keep your documentation compatible. This is very important once your REST API is used in production:

Example of a compatible change: glt25-demo v1 to v2

docker run --rm -t openapitools/openapi-diff:latest https://github.com/nezhar/glt25-demo/releases/download/v1/openapi.yaml https://github.com/nezhar/glt25-demo/releases/download/v2/openapi.yaml

Example of a breaking change: glt25-demo v2 to v3

docker run --rm -t openapitools/openapi-diff:latest https://github.com/nezhar/glt25-demo/releases/download/v2/openapi.yaml https://github.com/nezhar/glt25-demo/releases/download/v3/openapi.yaml

Automating the maintenance

The process can be automated even further using GitHub Actions and Dependabot. Here are what the steps look like with this full continuous delivery setup:

Takeways

Building a complete API development workflow from Django to client libraries using OpenAPI creates a powerful and maintainable development experience. By combining Django REST Framework with drf-spectacular for automatic OpenAPI spec generation and openapi-generator for client creation, you can eliminate manual API documentation and reduce integration errors.

If you want to go even further, you can automate the integration of error codes inside the OpenAPI spec. This way you can better support languages that are even more strict when consuming the REST API!

Thank you to Harald Nezbeda for proposing this guest post on the Django blog!

https://www.djangoproject.com/weblog/2025/aug/13/building-better-apis-django-to-clients-openapi/

#django #python #webdev

Just resurrected the demo of my first-ever visualization project from 2008 (which was part of my Dipl.-Ing thesis):

https://mariandoerk.de/visgets/

It is not mobile-friendly, but should work fine on desktop browsers featuring early @globalvoices posts (2008-2010).

Had to untangle the code from outdated CakePHP and a deprecated Google Maps API in favor of @leaflet. Hope to revive all my early vis projects that fell through the cracks due to server updates and site migrations…

#OldWeb #DataVis #WebDev

Marian Dörk – VisGets

Visual information exploration on the web combining faceted navigation and visual search along time, location, and tags.

Web development term of the day:

→ Software testing

https://webglossary.info/terms/software-testing/

#webdev #webdevglossary

Software testing · WebGlossary.info

😑 #webdev rant of the day

In 8 years using #PyCharm I don't think I've seen such a terrible upgrade as 2025.2. Many obvious regressions (fortunately, they've been fixed quite diligently, 2025.2.0.1 appeared today), some performance degradation, and still some clear possible enhancements when it comes to Django or CSS, that are still not on the roadmap apparently, because, you know, "AI"...

If #jetbrains continues to be all-in on AI, I'm gonna have to find a new #ide ...

#resistai #noai

#TIL Along with Element.moveBefore we also got connectedMoveCallback for customElements - From @mdn - "When defined, this is called instead of connectedCallback() and disconnectedCallback() each time the element is moved to a different place in the DOM via Element.moveBefore(). Use this to avoid running initialization/cleanup code in the connectedCallback() and disconnectedCallback() callbacks when the element is not actually being added to or removed from the DOM." - https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#custom_element_lifecycle_callbacks #webdev
Using custom elements - Web APIs | MDN

One of the key features of web components is the ability to create custom elements: that is, HTML elements whose behavior is defined by the web developer, that extend the set of elements available in the browser.

MDN Web Docs

🦖 transform-style
✅ Widely available (from Sept 2015)

https://developer.mozilla.org/en-US/docs/Web/CSS/transform-style

The transform-style CSS property sets whether children of an element are positioned in the 3D space or are flattened in the plane of the element.

#webdev #CSS

transform-style - CSS | MDN

The transform-style CSS property sets whether children of an element are positioned in the 3D space or are flattened in the plane of the element.

MDN Web Docs

Hi there! I'm looking for a job as #fullstack #webdev in #Bonn #Germany or #remote.

My main skills are: #Typescript #Angular #react #Python #Java and a bit of #Devops and #UX #uidesign
And I would like to work for #opensource projects.

My #CV is here https://cv.isman.fr/

Let's get in touch! :)

#boostswelcome #fedihire #fedihired #fedihiring #getfedihired #hirefedi

Pascal Isman - Full-Stack Web Developer

Hi there! I'm on the lookout for a job where I can really make a difference.

<time>: The (Date) Time element - HTML | MDN

The <time> HTML element represents a specific period in time. It may include the datetime attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.

MDN Web Docs

Made a scroll-driven animation that stacks cards. Powered by `animation-timeline: view()`, not JavaScript.

Now live on: https://mrwillcom.com

#webdev #CSS #animation #BuildInPublic