---
title: "Discussion on \"Recursive and cyclic schemas in OpenAPI: self-referencing $ref for trees, nested comments, and graphs\" | Hashnode"
description: "Discussion on \"Recursive and cyclic schemas in OpenAPI: self-referencing $ref for trees, nested comments, and graphs\". Categories contain children, comments have replies, and org charts nest forever. Model these with a self-referencing $ref and generated clients produce recursive types that compile; inline the shape and codegen either loops or flattens it. Here is how to model trees, nullable chi"
url: "https://hashnode.com/posts/openapi-recursive-cyclic-schema-refs/6aca07926c2d4303c9d9882a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Recursive and cyclic schemas in OpenAPI: self-referencing $ref for trees, nested comments, and graphs](https://blogs.powerduck.com/openapi-recursive-cyclic-schema-refs?utm_source=hashnode&utm_medium=feed)

Categories contain children, comments have replies, and org charts nest forever. Model these with a self-referencing $ref and generated clients produce recursive types that compile; inline the shape and codegen either loops or flattens it. Here is how to model trees, nullable chi

Oct 8 · 6 min read · blogs.powerduck.com  
Read the article

-   [#openapi](https://hashnode.com/tag/openapi)
-   [#json-schema](https://hashnode.com/tag/json-schema)
-   [#data-modeling](https://hashnode.com/tag/data-modeling)
-   [#tutorial](https://hashnode.com/tag/tutorial)

## Written by

[Powerduck](https://hashnode.com/@powerduck)

@powerduck · hon

  
[View profile](https://hashnode.com/@powerduck)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
