Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

JSON Schema generation can contain redundant anyOf entries for fixed-type arrays #566

@kylef

Description

@kylef

The following API Blueprint produces a redundant JSON Schema that contains anyOf containing the same entires multiple times. In this trivial case, could they be de-duplicated in the JSON Schema providing an array of fixed-type?

# GET /

+ Response 200 (application/json)
    + Attributes
        + direction: north, east, south, west (array[string, array], fixed-type)
$ ./bin/drafter test.apib -f json | ./tools/refract-filter.py

OK.
{
  "direction": [
    "north"
  ]
}
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "direction": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "string"
          },
          {
            "type": "string"
          },
          {
            "type": "string"
          },
          {
            "type": "string"
          },
          {
            "type": "array"
          }
        ]
      }
    }
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions