Skip to content

Decycle produce a wrong schema for schemas with description #727

Description

@juneidy

The original schema:

{
  "title": "Request",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "requestBody": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "active": {
          "description": "Active style.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "foo": {
              "type": "string"
            }
          }
        },
        "default": {
          "description": "Default style.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "foo": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "required": [
    "requestBody"
  ]
}

The decycled schema:

{
  "title": "Request",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "requestBody": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "active": {
          "description": "Active style.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "foo": {
              "type": "string"
            }
          }
        },
        "default": {
          "description": "Default style.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "$ref": "#/properties/requestBody/properties/active/properties"
          }
        }
      }
    }
  },
  "required": [
    "requestBody"
  ]
}

I would imagine the correct result should be something like:

{
  "title": "Request",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "requestBody": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "active": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "foo": {
              "type": "string"
            }
          },
          "description": "Style definition."
        },
        "default": {
          "$ref": "#/properties/requestBody/properties/active"
        }
      }
    }
  },
  "required": [
    "requestBody"
  ]
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions