AZ Tools

JSON Schema 생성기

개발

붙여넣은 JSON을 순회해 타입(integer·number·string·boolean·null·array·object) 추론, 흔한 문자열 포맷(email·URI·UUID·IPv4·date·date-time) 감지, 검증에 쓸 수 있는 JSON Schema 출력. 선택적으로 모든 프로퍼티를 required로 표시하거나 값을 `examples`에 임베드.

JSON Schema (draft-07)
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "user": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "email": {
          "type": "string",
          "format": "email"
        },
        "verified": {
          "type": "boolean"
        },
        "roles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "address": {
          "type": "object",
          "properties": {
            "street": {
              "type": "string"
            },
            "city": {
              "type": "string"
            }
          },
          "required": [
            "street",
            "city"
          ]
        }
      },
      "required": [
        "id",
        "name",
        "email",
        "verified",
        "roles",
        "address"
      ]
    }
  },
  "required": [
    "user"
  ]
}

사용법

  1. JSON 샘플을 입력 박스에 붙여넣기.
  2. 모든 프로퍼티를 required로 둘지(엄격한 API 계약에 좋음) 또는 존재하는 키만(부분·patch 페이로드에 좋음) 선택.
  3. 값을 `examples`로 포함하면 생성된 문서가 타입과 함께 샘플도 보여줌.

자주 묻는 질문

어떤 draft 대상?
draft-07 — validator·코드 생성기·Stoplight·Redocly 같은 에디터 도구에서 가장 광범위하게 지원되는 버전. OpenAPI 3.0에서 사용하는 JSON Schema 조각과도 호환.
혼합 타입 배열 처리?
모든 요소가 같은 스키마를 만들면 `items`가 그 스키마로 축약. 요소가 다르면 `items.type`이 union(`['string', 'integer']`). `anyOf` / `oneOf`는 생성 안 함 — 가능한 한 단순 유지.
어떤 문자열 포맷 자동 감지?
`date-time`·`date`·`email`·`uri`·`uuid`·`ipv4`. 부분 문자열이 아닌 전체 문자열에 매치해야 함.
nullable 필드는?
입력의 null 값은 `"type": "null"`로. optional-nullable 필드는 대표 샘플로 생성기 돌리고 머지 — 추측보다는 최소 스키마 유지.

관련 도구