2016-07-19 8 views
0

新しいAPIの素晴らしいドキュメントを作成するには、aglio/api blueprintを使用します。ミックスリクエスト/レスポンスボディとデータ構造

JSONは非常に大きく(オプションの値が多い)、本体に適切なユースケースを与えたいと思いますが、jsonスキーマのデータ構造も使用したいと思います。 しかし、スキーマがボディに完全に適合する場合は、サンプルデータを記入していないため、結果として得られるHTMLが "Hello、world!"をスローします。しかし、ボディに完全で有効なサンプルがあるので、私は、Hello Worldの出力を作成するaglioを期待していないでしょう。

参考のために、それは私が表示される結果のHTMLS体内に期待するものです。

{ 
    "a": "i want this to appear", 
    "b": "in my aglio", 
    "c": "html file" 
} 

これは、実際に表示されるんです:

{ 
    "a": "Hello, world!", 
    "b": "Hello, world!", 
    "c": "Hello, world!", 
    "d": "Hello, world!" 
} 

そして、それは、生のAPIの青写真です:

FORMAT: 1A 

# JSON Schema 

# Test [/post/something] 

## A Test [POST] 

+ Request (application/json) 
    + Attributes (SomeObject) 

    + Body 

     { 
      "a": "i want this to appear", 
      "b": "in my aglio", 
      "c": "html file" 
     } 

+ Response 200 

# Data Structures 
## SomeObject (object) 
+ a (string) - A 
+ b (string) - B 
+ c (string) - C 
+ d (string, optional) - I'm optional, yet don't want to appear in the html, only the schema 

だから、最初に、これは有効な方法ですか?別の方法をお勧めしますか?これは、私がそれを意図しているように羊膜炎で動作するので、これはaglioのバグですか? ありがとう!

+0

それが原因であるかどうかは分かりません。 – kashiraja

+0

両方が有効であり、出力に変更がないようです。しかし、ありがとう。 – zaubara

答えて

0

あなたは、次の

FORMAT: 1A 
# JSON Schema 
# Test [/post/something] 
JSON Schema Title 
## A Test [POST] 

+ Request (application/json) 
    + Attributes (object) 
     + a a-value (string, required) - description about a 
     + b b-value (number, required) - description about b 
     + c c-value (string, required) - description about c 
     + d [a1, a2, a3] (array, optional) - I'm optional 

+ Response 200 (application/json) 
    { 
    "message": "this works" 
    } 

値(文字列、必須)行うことができます - 上記の行で説明 "" - >属性名を、 "値" - > "+"属性の前に空白行を挿入します。スキーマの生成には、 "(文字列、必須)" - >スキーマの属性記述を指定してください。