apiaryio / drafter

API Blueprint Parser (C++)
https://apiblueprint.org/
MIT License
301 stars 54 forks source link

Fixed array with a mixin inside produces incorrect json schema #786

Open Ge11ert opened 4 years ago

Ge11ert commented 4 years ago

Suppose we have the next apib:

# My API

# Group Example

# GET /

+ Response 200 (application/json)
    + Attributes (array, fixed)
        + Karlin
        + Include Address

# Data Structures

## Address (array)
+ Prague
+ Wendy's

It produces the next json schema, which looks like a bug:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "array",
  "minItems": 2,
  "items": [
    {
      "const": "Karlin"
    },
    {
      "type": "array",
      "minItems": 2,
      "items": [
        {
          "const": "Prague"
        },
        {
          "const": "Wendy's"
        }
      ],
      "additionalItems": false
    }
  ],
  "additionalItems": false
}

Expected result:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "array",
  "minItems": 3,
  "items": [
    {
      "const": "Karlin"
    },
    {
      "const": "Prague"
    },
    {
      "const": "Wendy's"
    },
  ],
  "additionalItems": false
}

Produced body is correct:

[
  "Karlin",
  "Prague",
  "Wendy's"
]

Used environment:

$ drafter -v
v5.0.0