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

Nested arrays are not parsed correctly #47

Closed
w-vi opened this issue Jun 17, 2015 · 14 comments
Closed

Nested arrays are not parsed correctly #47

w-vi opened this issue Jun 17, 2015 · 14 comments
Labels

Comments

@w-vi
Copy link
Member

w-vi commented Jun 17, 2015

The nested array object is not correctly parsed using drafter, see the example API Blueprint below.
In Apiary I can see render only

{
  "categories": [
    {
      "name": "Category One",
      "subcategories": []
    }
  ]
}

instead of

{
  "categories": [
    {
      "name": "Category One",
      "subcategories":
      [
        {
          "name": "Sub category One"
        }
      ]
    }
  ]
}

Example Blueprint

FORMAT: 1A

# Test nested arrays-in-object-arrays

A navigation has multiple categories. Each category can have multiple subcategories.

# GET /navigation

+ Response 200 (application/json)

    + Attributes

        + categories (array)
            + (object)
                + name: Category One (string) - Name of the category
                + subcategories (array)
                    + (object)
                        + name: Sub category One (string) - Name of the subcategory

EDIT by @pksunkara: The MSON AST which is generated from the blueprint is wrong.

@pksunkara
Copy link
Contributor

Thanks for the report @JeroenVdb. I am going to look into this now.

@pksunkara
Copy link
Contributor

This is a bug in the parser itself. The generated MSON AST is not correct given the MSON.

@JeroenVdb
Copy link

Super @pksunkara can you give a shout here when this is fixed?
How can I see if this is then used by the apiary.io editor?

@pksunkara
Copy link
Contributor

@JeroenVdb Apiary should have the bug fix as soon as we release the bug fix in here.

@alexturek
Copy link

@pksunkara Is this the right snowcrash bug? Or is one filed?

@pksunkara
Copy link
Contributor

@alexturek No, that is a different bug. This is a drafter or drafter.js bug which needs to be fixed which is why it is created in drafter repo.

@huiyiqun
Copy link

Please refer this: apiaryio/drafter.js#38

Working apib:

FORMAT: 1A

# Test nested arrays-in-object-arrays

A navigation has multiple categories. Each category can have multiple subcategories.

# GET /navigation

+ Response 200 (application/json)

    + Attributes

        + categories (array)
            + (object, fixed)
                + name: Category One (string) - Name of the category
                + subcategories (array)
                    + (object, fixed)
                        + name: Sub category One (string) - Name of the subcategory

OK, the schema works while the example not when I compiled it with aglio.

However, fixed means that there could not be any additional attributes in the nested objects, this may be a problem.

@obihann
Copy link

obihann commented Sep 30, 2015

@pksunkara I mentioned this in a an apiary issue ( danielgtaylor/aglio#155), would you agree this is the same issue?

Also, I'm more than happy to help out on this, just point me in the right direction. I know we spoke of this earlier but now that I am far more familiar with the drafter codebase I can probably understand the issue better.

@pksunkara
Copy link
Contributor

@obihann No, this issue is completely different. The blueprint is not correctly being parsed at all in this issue while danielgtaylor/aglio#55 is about JSON Schema rendering.

@obihann
Copy link

obihann commented Sep 30, 2015

@pksunkara strange, they seem so similar, oh well I'll trust your expertise 👍. Once nullable has been properly implemented into all the tools I'll start looking into danielgtaylor/aglio#155 unless somebody has already.

@honzajavorek
Copy link
Contributor

Just to verify, is this issue also about following problem or is my problem a new thing?

Input:

...
+ dimensions (array)
  + *20, 30, 40* (array[number], fixed)
...

Generated JSON:

{
  ...
  "dimensions": [],
  "20, 30, 40": [ null ],
  ...
}

Expected JSON:

{
  ...
  "dimensions": [ [20, 30, 40] ],
  ...
}

@w-vi
Copy link
Member Author

w-vi commented Dec 22, 2015

@honzajavorek it probably is the same issue or at least it is fixed in the #199 PR as is this one.

@w-vi
Copy link
Member Author

w-vi commented Jan 7, 2016

@JeroenVdb It has been fixed a while ago can you verify? I am closing this one, if it doesn't work for you feel free to reopen

@w-vi w-vi closed this as completed Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants