옵션
집 Skill 개발자 도구 pydantic-models-py

pydantic-models-py

microsoft/skills microsoft/skills

Pydantic v2를 사용하는 Python 애플리케이션에서 깨끗한 API 계약을 위해 Base, Create, Update, Response, InDB 변형을 갖춘 다중 모델 패턴을 따르는 Pydantic 모델을 생성합니다.

...모든 것을 확장하십시오
7
업데이트 된 시간 2026년 9월 12일

Pydantic 모델

깨끗한 API 계약을 위해 다중 모델 패턴을 따르는 Pydantic 모델을 생성합니다.

빠른 시작

assets/template.py에서 템플릿을 복사하고 자리 표시자를 바꿉니다:

  • {{ResourceName}} → PascalCase 이름 (예: Project)
  • {{resource_name}} → snake_case 이름 (예: project)

다중 모델 패턴

모델목적
`Base`모델 간에 공유되는 공통 필드
`Create`생성을 위한 요청 본문 (필수 필드)
`Update`업데이트를 위한 요청 본문 (모두 선택 사항)
`Response`모든 필드를 포함하는 API 응답
`InDB``doc_type`이 포함된 데이터베이스 문서

camelCase 별칭

class MyModel(BaseModel):
    workspace_id: str = Field(..., alias="workspaceId")
    created_at: datetime = Field(..., alias="createdAt")

    class Config:
        populate_by_name = True  # snake_case와 camelCase 모두 허용

선택적 업데이트 필드

class MyUpdate(BaseModel):
    """PATCH 요청에 대해 모든 필드가 선택 사항입니다."""
    name: Optional[str] = Field(None, min_length=1)
    description: Optional[str] = None

데이터베이스 문서

class MyInDB(MyResponse):
    """Cosmos DB 쿼리를 위한 doc_type을 추가합니다."""
    doc_type: str = "my_resource"

통합 단계

  1. src/backend/app/models/에 모델 생성
  2. src/backend/app/models/__init__.py에서 내보내기
  3. 해당 TypeScript 유형 추가
GitHub에서 보기
---
name: pydantic-models-py
description: Create Pydantic models following the multi-model pattern with Base, Create, Update, Response, and InDB variants for clean API contracts in Python applications using Pydantic v2.
license: MIT
---

# Pydantic Models

Create Pydantic models following the multi-model pattern for clean API contracts.

## Quick Start

Copy the template from [assets/template.py](assets/template.py) and replace placeholders:
- `{{ResourceName}}` → PascalCase name (e.g., `Project`)
- `{{resource_name}}` → snake_case name (e.g., `project`)

## Multi-Model Pattern

| Model | Purpose |
|-------|---------|
| `Base` | Common fields shared across models |
| `Create` | Request body for creation (required fields) |
| `Update` | Request body for updates (all optional) |
| `Response` | API response with all fields |
| `InDB` | Database document with `doc_type` |

## camelCase Aliases

```python
class MyModel(BaseModel):
    workspace_id: str = Field(..., alias="workspaceId")
    created_at: datetime = Field(..., alias="createdAt")
    
    class Config:
        populate_by_name = True  # Accept both snake_case and camelCase
```

## Optional Update Fields

```python
class MyUpdate(BaseModel):
    """All fields optional for PATCH requests."""
    name: Optional[str] = Field(None, min_length=1)
    description: Optional[str] = None
```

## Database Document

```python
class MyInDB(MyResponse):
    """Adds doc_type for Cosmos DB queries."""
    doc_type: str = "my_resource"
```

## Integration Steps

1. Create models in `src/backend/app/models/`
2. Export from `src/backend/app/models/__init__.py`
3. Add corresponding TypeScript types

모든 파일

0개 파일

pydantic-models-py 설치

스킬 파일을 다운로드하여 .claude/skills/ 디렉토리에 추출하세요.

ZIP 다운로드

저장소를 클론하고 스킬 파일을 프로젝트에 복사하세요.

git clone https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-python/skills/pydantic-models-py # Copy SKILL.md to your .claude/skills/ directory

복사 복사
빠른 설정: 스킬 폴더를 .claude/skills/에 복사하세요. Claude가 자동으로 감지하고 사용합니다.
저장소 microsoft/skills

관련 스킬

algorithmic-art
업데이트 된 시간 2026년 8월 27일
receiving-code-review
업데이트 된 시간 2026년 9월 3일
tech-debt-tracker
업데이트 된 시간 2026년 8월 29일
senior-backend
업데이트 된 시간 2026년 8월 30일
OR