18. Chai Json Schema

🤩 Kolay Yöntem

Schema Generator ile kolaylıkla json'dan schema elde edebilirsiniz.

JSON data type

type anahtar sözcüğü, verinin belirli bir türde (veya bazı türlerde) olmasını gerektirir.

Type şunlar olabilir : number, integer, string, boolean, array, object ve null

Örnek

  1. schema: {type: "number"} Doğru data: 1, 1.5 Yanlış data: "osman", "1", [], {}, null, false

  2. schema: {type: "integer"} Doğru data: 1, 2 Yanlış data: "abc", "1", 1.5, [], {}, null, true

  3. schema: {type: ["number", "string"]} Doğru data: 1, 1.5, "abc", "1" Yanlış Data:[], {}, null, true

nullable

maximum / minimum and exclusiveMaximum / exclusiveMinimum

String type için

Array type için

Object type için

Çok önemli bir field: anyOf

oneOf

if / then / else

Last updated