| name | ballog-spec-format |
| description | /feat-new 가 읽는 Ballog API 명세 MD의 YAML 스키마 정의. endpoints/types/msw/figma 필드와 작성 규칙. spec 파일 작성이나 파싱할 때 참조. |
Ballog API Spec Format
docs/specs/<feature>.md 안에 첫 ```yaml 코드 블록으로 작성한다. 첫 블록 외에는 무시.
스키마
domain: emotion-v2
layer: widgets
figma: https://figma.com/design/...
endpoints:
- name: getEmotionRecord
method: GET
path: /emotion/:matchRecordId
params:
matchRecordId: number
response: EmotionResponseDTO
- name: createEmotion
method: POST
path: /emotion
request: CreateEmotionRequestDTO
response: EmotionResponseDTO
invalidates: [getEmotionRecord]
types:
Emotion:
id: number
type: "'HAPPY' | 'SAD' | 'ANGRY'"
createdAt: string
EmotionResponseDTO: "ApiResponseWithNoSuccess<Emotion[]>"
CreateEmotionRequestDTO:
type: "Emotion['type']"
matchRecordId: number
msw:
scenarios:
- endpoint: createEmotion
when: "body.matchRecordId === 0"
status: 400
response: { error: "invalid match" }
작성 규칙
- 타입 표현력: 값 위치에 문자열을 주면 TypeScript 원문으로 취급. 유니온/제네릭/유틸리티 타입 전부 가능.
- 공용 타입 자동 import:
ApiResponse<T>, ApiResponseWithNoSuccess<T>, ApiErrorMessage, KyHttpError 는 @/types/api/common 에서 자동 임포트.
- Mutation 판별: method가 GET이 아니면 mutation 훅 생성.
- invalidates: 각 name →
<camel>Queries.<name>._def 기준으로 invalidateQueries.
- path 파라미터:
:name 은 params에 반드시 선언. 자동으로 URL 치환 + 타입 반영.
네이밍 변환
spec domain | directory | file/variable base | Pascal |
|---|
emotion | emotion/ | emotion | Emotion |
emotion-v2 | emotion-v2/ | emotionV2 | EmotionV2 |
demo-ticket | demo-ticket/ | demoTicket | DemoTicket |
- 디렉토리: spec 값 그대로 (kebab 허용)
- 파일명·변수명: camelCase 변환 (
demoTicket.api.ts, demoTicketGet)
- 클래스/타입/훅 prefix: PascalCase (
useDemoTicketQuery, DemoTicketResponseDTO)
파싱 결과 → 생성물 매핑
| spec 필드 | 생성 |
|---|
types.* | entities/<kebab>/model/<camel>.type.ts |
endpoints[].request/response | 같은 파일에 Request/Response DTO alias 추가 |
endpoints[GET] | <camel>Get.<name> + use<Pascal><Endpoint>Query |
endpoints[!GET] | <camel><Method>.<name> + use<Pascal><Endpoint>Mutation |
endpoints[].invalidates | mutation onSuccess 의 invalidateQueries |
msw.scenarios | handler 내부 조건 분기 |
figma | --figma 미지정 시 fallback URL |