Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Ability to reuse responses #467

Open
goganchic opened this issue Apr 30, 2017 · 0 comments
Open

Ability to reuse responses #467

goganchic opened this issue Apr 30, 2017 · 0 comments

Comments

@goganchic
Copy link
Contributor

In our project we have very big api documentation. A lot of actions have identical responses like:

+ Response 401 (appliction/json)
    + Attributes
        + status: Unauthorized (required, fixed)

It's inconvenient to add such responses to almost every action. If we adds/modify/remove some common responses we have to process all actions. Chance to forget or misspell something is huge. So it will be very useful to have an ability to write common responses only once and drafter should do all required magic. Here is example:

# Group Authorized resources

# Common Data
+ Response 401 (application/json)
    + Attributes
        + status: Unauthorized (required, fixed)

## Posts [GET /posts]
+ Response 200 (application/json)
    + Attributes
        + result (array) - list of posts

## Comments [GET /comments]
+ Response 200 (application/json)
    + Attributes
        + result (array) - list of comments

In this case response 401 should be added to GET /posts and GET /comments actions. If I need to modify it - I'll do it only once in one place.

If I need to add some common data to one group only I can do it like this:

# Group Authorized resources

# Common Data
+ Response 401 (application/json)
    + Attributes
        + status: Unauthorized (required, fixed)

## Posts [GET /posts]
+ Response 200 (application/json)
    + Attributes
        + result (array) - list of posts

## Comments [GET /comments]
+ Response 200 (application/json)
    + Attributes
        + result (array) - list of comments

# Group Authentication

## Login [POST /login]
In this section 401 response will not be added, because it was defined in another group
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@goganchic and others