finish
This commit is contained in:
1 parent
32ae5530b6
commit
c07a2f6dae
20 files changed
+995
-61
No files matched your search
@@ -11,6 +11,7 @@ from app.database.session import engine
|
||||
# User 모델 import (테이블 메타데이터 등록용)
|
||||
from app.user.models import User, RefreshToken # noqa: F401
|
||||
|
||||
from app.archive.api.routers.v1.archive import router as archive_router
|
||||
from app.home.api.routers.v1.home import router as home_router
|
||||
from app.user.api.routers.v1.auth import router as auth_router, test_router as auth_test_router
|
||||
from app.lyric.api.routers.v1.lyric import router as lyric_router
|
||||
@@ -36,6 +37,14 @@ tags_metadata = [
|
||||
|
||||
- **Access Token**: 1시간 유효, API 호출 시 사용
|
||||
- **Refresh Token**: 7일 유효, Access Token 갱신 시 사용
|
||||
|
||||
## Scalar에서 인증 사용하기
|
||||
|
||||
1. 카카오 로그인 또는 테스트 토큰 발급으로 `access_token` 획득
|
||||
2. 우측 상단 **Authorize** 버튼 클릭
|
||||
3. `access_token` 값 입력 (Bearer 접두사 없이 토큰만 입력)
|
||||
4. **Authorize** 클릭하여 저장
|
||||
5. 이후 인증이 필요한 API 호출 시 자동으로 토큰이 포함됨
|
||||
""",
|
||||
},
|
||||
# {
|
||||
@@ -44,16 +53,24 @@ tags_metadata = [
|
||||
# },
|
||||
{
|
||||
"name": "Crawling",
|
||||
"description": "네이버 지도 크롤링 API - 장소 정보 및 이미지 수집",
|
||||
"description": """네이버 지도 크롤링 API - 장소 정보 및 이미지 수집
|
||||
|
||||
**인증: 불필요** (공개 API)
|
||||
""",
|
||||
},
|
||||
{
|
||||
"name": "Image-Blob",
|
||||
"description": "이미지 업로드 API - Azure Blob Storage",
|
||||
"description": """이미지 업로드 API - Azure Blob Storage
|
||||
|
||||
**인증: 필요** - `Authorization: Bearer {access_token}` 헤더 필수
|
||||
""",
|
||||
},
|
||||
{
|
||||
"name": "Lyric",
|
||||
"description": """가사 생성 및 관리 API
|
||||
|
||||
**인증: 필요** - `Authorization: Bearer {access_token}` 헤더 필수
|
||||
|
||||
## 가사 생성 흐름
|
||||
|
||||
1. `POST /api/v1/lyric/generate` - 가사 생성 요청 (백그라운드 처리)
|
||||
@@ -65,6 +82,8 @@ tags_metadata = [
|
||||
"name": "Song",
|
||||
"description": """노래 생성 및 관리 API (Suno AI)
|
||||
|
||||
**인증: 필요** - `Authorization: Bearer {access_token}` 헤더 필수
|
||||
|
||||
## 노래 생성 흐름
|
||||
|
||||
1. `POST /api/v1/song/generate/{task_id}` - 노래 생성 요청
|
||||
@@ -75,11 +94,32 @@ tags_metadata = [
|
||||
"name": "Video",
|
||||
"description": """영상 생성 및 관리 API (Creatomate)
|
||||
|
||||
**인증: 필요** - `Authorization: Bearer {access_token}` 헤더 필수
|
||||
|
||||
## 영상 생성 흐름
|
||||
|
||||
1. `GET /api/v1/video/generate/{task_id}` - 영상 생성 요청
|
||||
2. `GET /api/v1/video/status/{creatomate_render_id}` - Creatomate 상태 확인
|
||||
3. `GET /api/v1/video/download/{task_id}` - 영상 다운로드 URL 조회
|
||||
""",
|
||||
},
|
||||
{
|
||||
"name": "Archive",
|
||||
"description": """아카이브 API - 완료된 영상 목록 조회 및 삭제
|
||||
|
||||
**인증: 필요** - `Authorization: Bearer {access_token}` 헤더 필수
|
||||
|
||||
## 주요 기능
|
||||
|
||||
- `GET /api/v1/archive/videos/` - 완료된 영상 목록 페이지네이션 조회
|
||||
- `DELETE /api/v1/archive/videos/{task_id}` - 아카이브 영상 삭제 (CASCADE)
|
||||
|
||||
## 참고
|
||||
|
||||
- status가 'completed'인 영상만 반환됩니다.
|
||||
- 동일한 task_id가 있는 경우 가장 최근에 생성된 1개만 반환됩니다.
|
||||
- created_at 기준 내림차순 정렬됩니다.
|
||||
- 삭제 시 관련 Lyric, Song, Video가 CASCADE로 함께 삭제됩니다.
|
||||
""",
|
||||
},
|
||||
]
|
||||
@@ -137,12 +177,24 @@ def custom_openapi():
|
||||
}
|
||||
}
|
||||
|
||||
# 인증이 필요하지 않은 엔드포인트 (공개 API)
|
||||
public_endpoints = [
|
||||
"/auth/kakao/login",
|
||||
"/auth/kakao/callback",
|
||||
"/auth/kakao/verify",
|
||||
"/auth/refresh",
|
||||
"/auth/test/", # 테스트 엔드포인트
|
||||
"/crawling",
|
||||
"/autocomplete",
|
||||
]
|
||||
|
||||
# 보안이 필요한 엔드포인트에 security 적용
|
||||
for path, path_item in openapi_schema["paths"].items():
|
||||
for method, operation in path_item.items():
|
||||
if method in ["get", "post", "put", "patch", "delete"]:
|
||||
# /auth/me, /auth/logout 등 인증이 필요한 엔드포인트
|
||||
if any(auth_path in path for auth_path in ["/auth/me", "/auth/logout"]):
|
||||
# 공개 엔드포인트가 아닌 경우 인증 필요
|
||||
is_public = any(public_path in path for public_path in public_endpoints)
|
||||
if not is_public and path.startswith("/api/"):
|
||||
operation["security"] = [{"BearerAuth": []}]
|
||||
|
||||
app.openapi_schema = openapi_schema
|
||||
@@ -182,6 +234,7 @@ app.include_router(auth_router, prefix="/user") # Auth API 라우터 추가
|
||||
app.include_router(lyric_router)
|
||||
app.include_router(song_router)
|
||||
app.include_router(video_router)
|
||||
app.include_router(archive_router) # Archive API 라우터 추가
|
||||
|
||||
# DEBUG 모드에서만 테스트 라우터 등록
|
||||
if prj_settings.DEBUG:
|
||||
|
||||
Reference in new issue
Block a user