apiaryio / api-blueprint

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

How to reuse RESPONSE in Apiary #358

Closed zatziky closed 7 years ago

zatziky commented 7 years ago

Is there a way how to reuse RESPONSE in Apiary? I think that Data Structures are not the correct way but I can't find anything else...

w-vi commented 7 years ago

What do you mean by reusing response? If you want to specify just one response and then refer to it in some of the methods then that is not possible, there is no syntax for it. If you want to reuse the content of response there you can use the Data Structures as you already mentioned.

zatziky commented 7 years ago

@w-vi thanks for the answer. I would like to reuse this part:

+ Response 201 (application/json)

    + Body

            {
                "message": {
                    "id": "MESSAGE_ID"
                    "recipient" : {
                        "id": "USER_ID"
                    }
                }
            }

Can you tell if it's possible to reuse it at least partially?

w-vi commented 7 years ago

Would something like the following example work for you?

# A

## A [/a]

### Get A [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)

## B [/b]

### Get B [GET]

+ Response 201 (application/json)

    + Attributes (GenericRes)

# Data Structures

## GenericRes(object)
+ message (object)
    + id : MESSAGE_ID (string) - Message ID
    + recipient(object)
      + id : USER_ID (string)- User ID
zatziky commented 7 years ago

Thank you @w-vi , that's exactly what I needed!