Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use schema inheritence #197

Open
2 tasks done
mikaelkaron opened this issue Dec 23, 2024 · 2 comments
Open
2 tasks done

Unable to use schema inheritence #197

mikaelkaron opened this issue Dec 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mikaelkaron
Copy link

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

@mcollina mcollina added the bug Something isn't working label Dec 23, 2024
@Uzlopak
Copy link
Collaborator

Uzlopak commented Jan 7, 2025

unevaluatedProperties is not supported?

@mikaelkaron
Copy link
Author

unevaluatedProperties is not supported?

That could be the problem. From the docs

unevaluatedProperties works by collecting any properties that are successfully validated when processing the schemas and using those as the allowed list of properties.

So that could be part of the problem.

@Uzlopak Uzlopak changed the title Unable to use shema inheritence Unable to use s hema inheritence Jan 30, 2025
@Uzlopak Uzlopak changed the title Unable to use s hema inheritence Unable to use schema inheritence Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants