apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.64k stars 2.14k forks source link

Attributes with array of objects produce incomplete schema #328

Closed agougousis closed 8 years ago

agougousis commented 8 years ago

The following part of my text file:

Produces this HTML:

pic1

The part of schema inside the ""nodes" is missing! Why? I have also tried to use data structures but the schema remains incomplete.

pksunkara commented 8 years ago

@agougousis Can you try the following?

nodes (array[object], fixed)
agougousis commented 8 years ago

Ok! Though I haven't found yet where this "fixed" world came from, now the schema is complete. However, it seems that the produced schema is not right. The schema produced is:

pic3

and the correct schema should be:

pic4

Am I wrong?

pksunkara commented 8 years ago

Can you try this?

+ nodes (array, fixed)
    + (object)
        + id: 4 (number)
agougousis commented 8 years ago

Yeap! A lot better! I didn't think that "anonymous" objects can be defined! I am not sure, but I think that the brackets marked in the following screenshot should not be there. What do you think? schema

w-vi commented 8 years ago

@agougousis The brackets are correct as items is an array of possible types

agougousis commented 8 years ago

I don't remember very well the rules, but in http://jsonschema.net/ (a quick and dirty solution that I use from time to time) when i give the json data as input it gives me the schema without these brackets.

kamihouse commented 6 years ago

@agougousis use a fixed-type for this:

+ nodes (array, fixed-type)
    + (object)
        + id: 4 (number)
tomacf commented 6 years ago

+1 for the fixed-type

fixed - instance of this type structure and values are fixed. This attribute propagates to Nested Member Types.

fixed-type - instance of this type structure is fixed, value is not. This attribute does not propagate to Nested Member Types.

https://apiblueprint.org/documentation/mson/specification.html#353-type-attribute