Api-blueprint: How to reuse RESPONSE in Apiary

Created on 1 Oct 2016  路  4Comments  路  Source: apiaryio/api-blueprint

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...

Most helpful comment

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

All 4 comments

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.

@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?

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robbinjanssen picture robbinjanssen  路  6Comments

bazo picture bazo  路  8Comments

rodriguise picture rodriguise  路  11Comments

basickarl picture basickarl  路  7Comments

Perni1984 picture Perni1984  路  6Comments