2017-07-12 4 views
1

で例に含めます以下の構文は合法的でなければなりません。唯一の違いは、401サンプルセクションに現れるjsonにアクセスする方法にあります。RAML 1.0は従わない!私は両方の、私はRAML 1.0仕様を読んで、私が理解からきた私のAPI</p> <p>を文書化するMulesoftのAPIの設計ツールを使用していresponses.body

/password: 
    post: 
    description: Verifies the supplied user name and password, returning the associated Customer Id 
    body: 
     type: tokens.password-verification-request 
     example: !include examples/password-verification-request.json 
    responses: 
     200: 
     body: 
      application/json: 
      type: tokens.password-verification-response-success 
      example: !include examples/password-verification-response-200.json 
     401: 
     body: 
      application/json: 
      type: tokens.error-response 
      examples: 
       invalidcredentials: 
       value: | 
        { 
        "failure" : { 
         "errors" : [ { 
         "code" : "ID10050", 
         "desc" : "Invalid User Credentials supplied" 
         } ], 
         "trackingId" : "e6d370da-3978-4dde-9e50-d485023cd47a" 
        } 
        } 
       accountlocked: 
....... 

/password: 
    post: 
    description: Verifies the supplied user name and password, returning the associated Customer Id 
    body: 
     type: tokens.password-verification-request 
     example: !include examples/password-verification-request.json 
    responses: 
     200: 
     body: 
      application/json: 
      type: tokens.password-verification-response-success 
      example: !include examples/password-verification-response-200.json 
     401: 
     body: 
      application/json: 
      type: tokens.error-response 
      examples: 
       invalidcredentials: 
       value: !include examples/error.json 
       accountlocked: 
....... 

これら二つの例の第二は、それが「失敗」を見つけることができないと言って、デザイナーでエラーとして通知されます。私はerror.jsonファイルの内容を解析しようとしていると想定しています。

error.jsonファイルが存在し、適切な場所にあると確信しています。私はそれが正しいjsonを含んでいることも嬉しいです(私はこのファイルからjsonを上記の例1のexamplesプロパティにコピーしました)。

!includeで何か問題がありますか?私は仕様を誤解していますが、これを許さない仕様ですか? APIデザイナーツール自体が混乱していますか?

答えて

0

たとえば、あなたが完全な例と200例のように指定する必要がありますJSONの例の内側することはできません、次のとおりです!

401: 
    body: 
     application/json: 
     type: tokens.error-response 
     examples: 
     - !include examples/error_01.json 
     - !include examples/error_02.json 
+0

しかし、どのように401レスポンスの例は複数ありますか? – DaveH

+0

複数のサンプルを使用する方法を示すレスポンスを編集しました。 –

+0

私はこの構文を試してみると、 "例はマップでなければならない"と言います。 – DaveH

0

は、実際の構文は次のとおりであることを蒸散:

401: 
    body: 
     application/json: 
     type: t.error-response 
     examples: 
      invalidcredentials: !include examples/errors/error-response-1.json 
      accountlocked: !include examples/errors/error-response-2.json 
      accountinactive: !include examples/errors/error-response-3.json 
関連する問題