fastify / fastify/fastify-swagger-ui

Unable to use schema inheritence

Open
#197 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
191
Forks
46
Avg merge
12h 12m
Merged PRs (30d)
2

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] 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

```json
{
"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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.