-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Typed arrays don't render any values in JSON #271
Comments
Hey @sheela-na-geek , this is actually (a known) bug in the JSON renderer. We have it fixed in our parser – Drafter – but it hasn't been released on Apiary.io production just yet. We will update this issue once the fix is published on Apiary.io. Regarding the schema – this is a bug as well and we are working towards its fix. Please note MSON is still considered in beta quality, we do our best to squash all these bugs as soon as possible! But please keep them reporting 😀 Thanks! |
I just encountered this as well, and ended up working around it by adding an explicit Looks like the fix hasn't landed on apiary.io yet, and the last activity here was several months ago. I'd be happy to see this fixed. |
@LukeWinikates Can you give the related part of the API Blueprint? The fix has been landed in Apiary, so I am wondering if you are running into another bug. Thanks. |
Sorry for the delayed response here. Here's a repro. FORMAT: 1A
HOST: http://polls.apiblueprint.org/
# typed-array-example
## Rocks [/rocks]
### List All Rocks [GET]
+ Response 200 (application/json;charset=UTF-8)
+ Attributes (array[Rock])
+ Body
[
{
"id": "124",
"title": "marble",
"type": "metamorphic"
}
]
# Data Structures
## Rock (object)
+ `id` (string, required) -
+ `title` (string, required) - e.g. basalt, marble, diamond
+ `type` (enum[string], required)
+ Members
+ igneous
+ metamorphic
+ sedimentary In the apiary editor, the JSON schema generated looks like this: {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "array"
} I would have expected the generated schema to include the schema for the |
@LukeWinikates By default, an array in MSON doesn't have a fixed type. An array may contain the sample values you've specified or anything else. If you would like to make the JSON Schema of a fixed type, you will need to add the + Attributes (array[Rock], fixed-type) The original problem in this issue that was discussed have been fixed for some time now. |
I'm trying to use something like
(array[number])
which should be possible according to MSON spec .I want to have an array of numbers with resulting JSON
{ "foo" : [1, 99] }
and preferrably type information in schema.- foo: 1, 99 (array)
renders{"foo": [ "1", "99" ]}
- foo: 1, 99 (array[number])
renders{ "foo": [] }
The only way I got proper number array JSON was
but this is way longer plus it's still not an array of numbers, just an array which elements happen to be numbers.
Also no type info is generated in schema in any case, it's always
"foo": { "type": "array" }
.What am I missing here?
Test suite: http://docs.typedarraytest.apiary.io/#reference/default/foo/test
The text was updated successfully, but these errors were encountered: