apiaryio / api-blueprint

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

Rendering table for selected/all data structures #314

Closed Perni1984 closed 8 years ago

Perni1984 commented 8 years ago

I am defining all possible errors of my API in the Data structures section as follows (corresponding to Json-api):

# Data Structures

## ERR_USER_NOT_ALLOWED (object)
- id: 2
- links 
    - about: http://docs.offisy.apiary.io/#reference/errors/ERR_USER_NOT_ALLOWED
- status: 403
- code: ERR_USER_NOT_ALLOWED
- title: User not allowed
- detail: You are not allowed to do this action.

## ERR_USER_NOT_FOUND (object)
- id: 3
- links 
    - about: http://docs.offisy.apiary.io/#reference/errors/ERR_USER_NOT_FOUND
- status: 404
- code: ERR_USER_NOT_FOUND
- title: User not found
- detail: A user with the given user_id was not found

## ERR_COMPANY_NOT_FOUND (object)
- id: 4
- links 
    - about: http://docs.offisy.apiary.io/#reference/errors/ERR_COMPANY_NOT_FOUND
- status: 404
- code: ERR_COMPANY_NOT_FOUND
- title: Company not found
- detail: A company with the given company_id was not found

## ERR_USER_ALREADY_EXISTS (object)
- id: 5
- links 
    - about: http://docs.offisy.apiary.io/#reference/errors/ERR_USER_ALREADY_EXISTS
- status: 409
- code: ERR_USER_ALREADY_EXISTS
- title: User already exists
- detail: A user with the given email address jane.doe@email.com already exists

## ERR_COMPANY_ALREADY_EXISTS (object)
- id: 6
- links 
    - about: http://docs.offisy.apiary.io/#reference/errors/ERR_COMPANY_ALREADY_EXISTS
- status: 409
- code: ERR_COMPANY_ALREADY_EXISTS
- title: Company already exists
- detail: A company with the given name and address already exists

There are also other data structures defined besides the errors. As I would like to reference them via links->about, I am looking for a way to partially render those data structures in a table in a "errors" group inside the documentation, or to at least render all data structures somewhere in the documentation.

How can this be achieved currently?

Perni1984 commented 8 years ago

I use a manual table as a workaround for now, like that:


| Id | Error-Code | Status                     | Title                  | Detail                                                   |
|----|------------|----------------------------|------------------------|----------------------------------------------------------|
| 2  | 403        | ERR_USER_NOT_ALLOWED       | User not allowed       | You are not allowed to do this action.                   |
| 3  | 404        | ERR_USER_NOT_FOUND         | User not found         | A user with the given user_id was not found              |
| 4  | 404        | ERR_COMPANY_NOT_FOUND      | Company not found      | A company with the given company_id was not found        |
| 5  | 409        | ERR_USER_ALREADY_EXISTS    | User already exists    | A user with the given email address already exists       |
| 6  | 409        | ERR_COMPANY_ALREADY_EXISTS | Company already exists | A company with the given name and address already exists |

but this is not very DRY.

zdne commented 8 years ago

Hey @Perni1984 the Data Structures rendering is planned and on its way.

zdne commented 8 years ago

Also I have started playing with JSON API error here https://github.com/apiaryio/datapool/blob/zdne/datapool-origin/jsonapi-error.apib

Perni1984 commented 8 years ago

@zdne: nice.

Perni1984 commented 8 years ago

I am closing this issue and waiting for rendering of data structures to be implemented in Apiary.