2016-12-07 9 views
0

スワッガーファイルがwarnigで期待通りに機能しています。警告付きスワッガーファイル

{ 
    'swagger': "2.0", 
    "info": { 
    "version": "3.0", 
    "title": "Sample Service", 
    }, 
    "schemes": [ "http" ], 
    "host": "sampleservice.azurewebsites.net", 
    "paths": { 
    "/": { 
     "post": { 
     "summary": "Sample service", 
     "description": "sample service", 
     "parameters": [ 
      { 
      "name": "Input", 
      "in": "body", 
      "description": "valid input", 

      "schema": { 
       "type": "object", 
       "properties": { 
       "MainAttr-1": { 
        "required": [ "Attr-1" ], 
        "type": "object", 
        "properties": { 
        "Attr-1": { 
         "description": "Attr-1", 
         "required": true, 
         "type": "string" 
        }, 
        "Attr-2": { 
         "description": "Attr-2", 
         "required": false, 
         "type": "string" 
        }, 
        "Attr-3": { 
         "description": "Attr-3", 
         "required": false, 
         "type": "boolean" 
        }, 
        "Attr-4": { 
         "description": "Attr-4", 
         "required": false, 
         "type": "boolean" 
        }, 
        "Attr-5": { 
         "description": "Attr-5", 
         "required": false, 
         "type": "string" 
        } 
        } 
       }, 
       "MainAttr-2": { 
        "type": "array", 
        "items": { 
        "type": "object", 
        "required": [ "Attr-1", "Attr-3", "Attr-5", "Attr-8" ], 
        "properties": { 
         "Attr-1": { 
         "description": "Attr-1", 
         "required": true, 
         "type": "string" 
         }, 
         "Attr-2": { 
         "description": "Attr-2", 
         "required": false, 
         "type": "string" 
         }, 
         "Attr-3": { 
         "description": "Attr-3", 
         "required": true, 
         "type": "boolean" 
         }, 
         "Attr-4": { 
         "description": "Attr-4", 
         "required": false, 
         "type": "boolean" 
         }, 
         "Attr-5": { 
         "description": "Attr-5", 
         "required": true, 
         "type": "string" 
         }, 

         "Attr-6": { 
         "description": "Attr-6", 
         "required": false, 
         "type": "string" 
         }, 
         "Attr-7": { 
         "description": "Attr-7", 
         "required": false, 
         "type": "string" 
         }, 
         "Attr-8": { 
         "description": "Attr-8", 
         "required": true, 
         "type": "string" 
         } 
        } 
        } 
       } 
       } 
      } 
      } 
     ], 
     "responses": { 
      "200": { 
      "description": "success" 
      } 
     } 
     } 
    } 
    } 
} 

enter image description here

号-1)警告 "MainAttr-2" に

号-2)のAttr-3を除去しなければならないブール型の属性であり、これは必要とされています。しかし、ドロップダウンから「偽」を選択すると、無効な入力として扱われます。有効な入力として「真」のみを扱います。 (このように動作する必要がある任意のブール属性)

この警告のため、私はコードを渡すことができません。

ありがとうございます。初めに

答えて

1
  1. "swagger"に変更'swagger'。 JSONでは文字列を二重引用符で囲む必要があります。

  2. の末尾に余分なコンマを削除します。

    "title": "Sample Service", 
    
  3. ALLプロパティ定義(Attr-8からAttr-1)からrequired属性を削除し、(MainAttr-1MainAttr-2下)の代わりにオブジェクトレベルでrequiredリストを使用します。あなたのスペックは大丈夫であること以外は

     "MainAttr-1": { 
          "required": [ "Attr-1" ], <-- list the required properties in this array 
          "type": "object", 
          "properties": { 
          "Attr-1": { 
           "description": "Attr-1", 
           "required": true,  <-- remove this 
           "type": "string" 
          }, 
    

+0

お返事ありがとうございます。それでも私は同じ警告を受けています – Ganesh

+0

すべてのプロパティ( 'Attr-1'から' Attr-8')から 'required'属性を削除してオブジェクトレベル(' MainAttr-1'と'MainAttr-2')。 – Helen

+0

ヘレンに感謝します。修正された問題 – Ganesh