/plushcap/analysis/bump/use-document-polymorphism-API

How to use and document polymorphism in API

What's this blog post about?

Polymorphism is an important concept in API development to help achieve objectives such as easy code changes and scalable API design. It refers to the possibility of using the same endpoint for similar but different objects, reducing the amount of endpoint duplications. In this article, the author explains how polymorphism can be used in API development with examples from a real estate agency application. They also discuss how to properly document polymorphic resources with OpenAPI or AsyncAPI specifications based on JSON Schema. The article covers inheritance and DRY patterns, discriminator support, and provides an example of how to use the oneOf combinator for defining alternatives in API documentation.

Company
Bump

Date published
April 27, 2023

Author(s)
Paul Monseu de Bodinat

Word count
2106

Language
English

Hacker News points
1


By Matt Makai. 2021-2024.