danielgtaylor / aglio

An API Blueprint renderer with theme support that outputs static HTML
4.75k stars 480 forks source link

"One of" is incorrectly translated to merged object schema in JSON Schema and loses required field information #301

Open rdgreen opened 7 years ago

rdgreen commented 7 years ago

An array[NodeData], where NodeDate is defined as:

## NoteData (fixed-type)
+ One of
    + Properties
        + id: 1 (required, number) - Unique identifier
        + title: Grocery list (required) - Single line description
        + body: Buy milk - Full description of the note which supports Markdown.
    + Properties
        + id: 1 (required, number) - Unique identifier
        + title: Grocery list (required) - Single line description
        + body: Buy milk - Full description of the note which supports Markdown.
        + other: Other stuff (required)

produces, in the JSON schema:

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "number",
        "description": "Unique identifier"
      },
      "title": {
        "type": "string",
        "description": "Single line description"
      },
      "body": {
        "type": "string",
        "description": "Full description of the note which supports Markdown."
      },
      "other": {
        "type": "string"
      }
    },
    "allOf": [
      {
        "not": {
          "required": [
            "id",
            "title",
            "body",
            "id",
            "title",
            "body",
            "other"
          ]
        }
      }
    ]
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}