Skip to content

Unable to use schema inheritence #197

@mikaelkaron

Description

@mikaelkaron

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.2

Plugin version

5.2.0

Node.js version

22.9

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

debian 12

Description

Schemas using model inheritance are not working correctly.

This schema

{
  "swagger": "2.0",
  "info": {
    "version": "9.4.0",
    "title": "@fastify/swagger"
  },
  "definitions": {
    "def-0": {
      "type": "object",
      "properties": {
        "parent": {
          "type": "string"
        }
      },
      "required": [
        "parent"
      ],
      "title": "schema:parent"
    },
    "def-1": {
      "$ref": "#/definitions/def-0",
      "type": "object",
      "properties": {
        "child": {
          "type": "string"
        }
      },
      "required": [
        "child"
      ],
      "unevaluatedProperties": false,
      "title": "schema:child"
    }
  },
  "paths": {
    "/parent": {
      "get": {
        "responses": {
          "200": {
            "description": "Default Response",
            "schema": {
              "$ref": "#/definitions/def-0"
            }
          }
        }
      }
    },
    "/child": {
      "get": {
        "responses": {
          "200": {
            "description": "Default Response",
            "schema": {
              "$ref": "#/definitions/def-1"
            }
          }
        }
      }
    }
  }
}

Will not render correctly in the UI

Link to code that reproduces the bug

https://github.com/mikaelkaron/json-schema-inherit-error/tree/fastify

Expected Behavior

Schema inheritance to work as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions