danielgtaylor / aglio

An API Blueprint renderer with theme support that outputs static HTML
4.75k stars 481 forks source link

Arrays in JSONSchema do not contain `items` field #243

Open udoprog opened 8 years ago

udoprog commented 8 years ago

Hey,

Using the example blueprint, with master (and overriding protagonist to version 1.3.0-dev.0), I'd expect the output JSONSchema to be the same as the example render.

Right now, I get a discrepancy in the 200 Response in the GET /notes endpoint.

Expected:

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": {
        "type": "number",
        "description": "Unique identifier"
      },
      "title": {
        "type": "string",
        "description": "Single line description"
      },
      "body": {
        "type": "string",
        "description": "Full description of the note which supports Markdown."
      }
    },
    "required": [
      "id",
      "title"
    ]
  },
  "$schema": "http://json-schema.org/draft-04/schema#"
}

Actual:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "array"
}
vbartacek commented 8 years ago

This is related to this drafter issue: https://github.com/apiaryio/drafter/issues/211

AlekSi commented 8 years ago

I'd expect the output JSONSchema to be the same as the example render.

In fact, I tried to render example.apib with current aglio (npm install -g aglio) and I got "type": "array", not what default.html promised me. Is it regression, or should I use some other version, or something else?

vbartacek commented 8 years ago

A workaround is to remove/do not mention the media type 'application/json' - without that it is working as expected. See the last comments in the issue https://github.com/danielgtaylor/aglio/issues/155

udoprog commented 8 years ago

Good to know about the workaround, but I don't know how useful it is since the cost is getting rid of useful documentation :(.

davibe commented 8 years ago

we ended up writing application / json (see spaces) :(