2017-11-26 19 views
0

iteminオプション私はswagger.yaml闊歩のYAMLの定義

Content: 
    type: object 
    properties: 
     text: 
      type: string 
     image: 
      ref: "#/definitions/Image" 
      allowEmptyValue: true 

に次のdeinitionを持っている私が許可されていない追加のプロパティを取得:エラー

としてallowEmptyValueにはどうすれば画像はオプション作るのですか?つまり、テキストのみの画像である可能性があります

答えて

1

allowEmptyValueはクエリパラメータにのみ適用され、異なるものを意味します。 パラメータは含まれていますが、その値は?param=のように空白になることがあります。

スキーマでは、すべてのプロパティはデフォルトでのオプションです。 required配列に含めることによって、必要な特定のプロパティを作成できます。 requiredに記載されていないプロパティはオプションです。

Content: 
    type: object 
    properties: 
     text: 
      type: string 
     image: 
      ref: "#/definitions/Image" 
    # text is required, image is optional 
    required: 
     - text