Share via


ODataV4Format 類別

描述 OData V4 錯誤格式的類別。

http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793091

JSON 的範例:

error: { 「code」: 「ValidationError」, 「message」: 「一或多個欄位包含不正確的值:」, 「details」: [

  {
     "code": "ValidationError",
     "target": "representation",
     "message": "Parsing error(s): String '' does not match regex pattern '^[^{}/ :]+(?: :\d+)?$'.
     Path 'host', line 1, position 297."

  },
  {

     "code": "ValidationError",
     "target": "representation",
     "message": "Parsing error(s): The input OpenAPI file is not valid for the OpenAPI specificate
     https: //github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
     (schema [https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json))."

  }

]

}

繼承
builtins.object
ODataV4Format

建構函式

ODataV4Format(json_object: Mapping[str, Any])

參數

json_object
dict
必要

代表 ODataV4 JSON 的 Python 聽寫

變數

~.code
str

其值為服務定義的錯誤碼。 此代碼會作為回應中指定之 HTTP 錯誤碼的子狀態。

message
str

人類看得懂且與語言相關的錯誤標記法。

target
str

例如,錯誤 (中屬性的名稱) 的特定錯誤目標。 此欄位是選擇性的,而且可以是 None。

details
list[ODataV4Format]

必須包含程式碼和訊息之名稱/值組的 ODataV4Format 實例陣列,而且 MAY 包含目標的名稱/值組,如上所述。

innererror
dict

物件。 此物件的內容是服務定義的。 此物件通常包含可協助偵錯服務的資訊。

方法

message_details

傳回錯誤的詳細字串。

message_details

傳回錯誤的詳細字串。

message_details() -> str

傳回

包含錯誤詳細資料的字串。

傳回類型

str

屬性

error

CODE_LABEL

CODE_LABEL = 'code'

DETAILS_LABEL

DETAILS_LABEL = 'details'

INNERERROR_LABEL

INNERERROR_LABEL = 'innererror'

MESSAGE_LABEL

MESSAGE_LABEL = 'message'

TARGET_LABEL

TARGET_LABEL = 'target'