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


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でテスト。