Api-blueprint: How can I make a nest of object using data structure?

Created on 24 Oct 2017  路  2Comments  路  Source: apiaryio/api-blueprint

I read the documentation.
https://apiblueprint.org/documentation/advanced-tutorial.html

According to Data Structures section, we can write data structure in array like below example.

### List All Questions [GET]
+ Response 200 (application/json)

    + Attributes (array[Question])

## Data Structures

### Question
+ question: Favourite programming language? (required)
+ published_at: `2014-11-11T08:40:51.620Z` (required)
+ url: /questions/1 (required)
+ choices (array[Choice], required)

### Choice
+ choice: Javascript (required)
+ url: /questions/1/choices/1 (required)
+ votes: 2048 (number, required)

By the way, I want to define JSON structure as bellow.

{
  Obj1: { ... },
  Obj2: {....}
}

Obj1 and Obj2 are defined as Data Structure respectively.
How can I write?

I tried to write this. But I didn't get it.

+ Response 200 (application/json)
    + Attributes (Obj)

## Data Structures
### Obj
+ Obj1 (object)
    + (Obj1)
+ Obj2 (object)
    + (Obj2)

### Obj1
+ ID: 1 (string, required)
+ Name: 'My Name' (string, required)

### Obj2
+ URL: `http://example.com` (string, required)
+ Title: example site (string, required)

Do you have any idea?

Question

Most helpful comment

+ Response 200 (application/json)
    + Attributes (Obj)

## Data Structures
### Obj
+ Obj1 (Obj1)
+ Obj2 (Obj2)

### Obj1
+ ID: 1 (string, required)
+ Name: 'My Name' (string, required)

### Obj2
+ URL: `http://example.com` (string, required)
+ Title: example site (string, required)

All 2 comments

+ Response 200 (application/json)
    + Attributes (Obj)

## Data Structures
### Obj
+ Obj1 (Obj1)
+ Obj2 (Obj2)

### Obj1
+ ID: 1 (string, required)
+ Name: 'My Name' (string, required)

### Obj2
+ URL: `http://example.com` (string, required)
+ Title: example site (string, required)

@kylef
Thank you very very much!
I got it:)

Was this page helpful?
0 / 5 - 0 ratings