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

Option to flatten inheritance hierarchy #5

Closed
RicoSuter opened this issue Nov 29, 2015 · 1 comment
Closed

Option to flatten inheritance hierarchy #5

RicoSuter opened this issue Nov 29, 2015 · 1 comment

Comments

@RicoSuter
Copy link
Owner

Add an option to flatten the inheritance hierarchy when generating JSON Schema from a type:

public class AA
{
    public string FirstName { get; set; }
}

public class BB : AA
{
    public string LastName { get; set; }
}

public class CC : BB
{
    public string Address { get; set; }
}

Currently converts to:

{
  "typeName": "CC",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "Address": {
      "type": "string"
    }
  },
  "allOf": [
    {
      "typeName": "BB",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "LastName": {
          "type": "string"
        }
      },
      "allOf": [
        {
          "typeName": "AA",
          "additionalProperties": false,
          "type": "object",
          "properties": {
            "FirstName": {
              "type": "string"
            }
          }
        }
      ]
    }
  ],
  "$schema": "http://json-schema.org/draft-04/schema#"
}

And with this new option to:

{
  "typeName": "CC",
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "Address": {
      "type": "string"
    },
    "LastName": {
      "type": "string"
    },
    "FirstName": {
      "type": "string"
    }
  }
}
@RicoSuter
Copy link
Owner Author

Added in v1.14, 57ff751

option FlattenInheritanceHierarchy

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

No branches or pull requests

1 participant