JSON Schema로 API 계약을 문서화하고, JSON payload를 검증하며, 테스트/데모용으로 현실적인 mock 데이터를 생성할 수 있습니다.
JSON Schema 기능에 대한 중요한 안내
- 일부 스키마는
$ref, anyOf, oneOf, 및 allOf같은 고급 keyword에 의존합니다. - Validator는 draft와 keyword 지원 범위가 다를 수 있습니다. 엄격한 준수가 필요하다면 CI에서 전체 기능 JSON Schema validator를 사용하세요.
예시: JSON → JSON Schema (간단 버전)
// JSON input
{
"id": 1,
"name": "Maeve Winters",
"active": true,
"tags": ["developer", "backend"]
}
// Generated schema (example)
{
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"active": { "type": "boolean" },
"tags": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["id", "name", "active", "tags"]
}