LoginSignup
0
0

More than 3 years have passed since last update.

Postmanにてレスポンスボディのjsonの構造をチェックする

Last updated at Posted at 2020-05-16

This section contains different examples of validating JSON responses using the Ajv schema validator. I do not recommend using the tv4 (Tiny Validator for JSON Schema v4).

とあるのでこれに従いtestスクリプトを作成する。
そのためには想定するjsonの構造からチェック用のjsonスキーマを作成する必要がある。
想定するjson を入力すると自動でjsonスキーマに変換するサイトは以下。
https://app.quicktype.io/#s=coordinate
にて左のウィンドウでJSONを選択し、右のウィンドウにJSON Schemaを選択すると表示される。
この結果にはPostmanのtestでは不要な(エラーがでる)項目があり
https://postman-quick-reference-guide.readthedocs.io/en/latest/schema-validation.html
に示してある通りに整形する必要がある。
format
additionalProperties
は不要だった。
Postmanのtest の結果でエラーについてはある程度原因を教えてくれるのでそれにしたがって不要な物を消してPostmanでテスト。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0