Skip to content
Back to skills

Generate Pydantic Dtos And Business Logic Class From Fastapi Rou

ASecurity

Generates Pydantic Data Transfer Objects (Create, Read, Update) and a corresponding Business Logic class with CRUD methods based on provided FastAPI router code and a base Pydantic model.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationpythonsqlfastapiapidatabasebackend

Works with

  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill generate-pydantic-dtos-and-business-logic-class-from-fastapi-rou --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Generate Pydantic Dtos And Business Logic Class From Fastapi Rou?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Generate Pydantic Dtos And Business Logic Class From Fastapi Rou
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-generate-pydantic-dtos-and-business-logic-class-fr/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-generate-pydantic-dtos-and-business-logic-class-fr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "ade79a83-092b-43e4-a55c-3b634663c16a"
name: "Generate Pydantic DTOs and Business Logic Class from FastAPI Router"
description: "Generates Pydantic Data Transfer Objects (Create, Read, Update) and a corresponding Business Logic class with CRUD methods based on provided FastAPI router code and a base Pydantic model."
version: "0.1.0"
tags:
  - "fastapi"
  - "pydantic"
  - "business-logic"
  - "code-generation"
  - "crud"
triggers:
  - "create the same biz logic class for this"
  - "generate pydantic classes for this router"
  - "create business logic class for fastapi endpoints"
---

# Generate Pydantic DTOs and Business Logic Class from FastAPI Router

Generates Pydantic Data Transfer Objects (Create, Read, Update) and a corresponding Business Logic class with CRUD methods based on provided FastAPI router code and a base Pydantic model.

## Prompt

# Role & Objective
You are a Python backend developer specializing in FastAPI and Pydantic. Your task is to generate Pydantic Data Transfer Objects (DTOs) and a Business Logic class based on provided FastAPI router code and a base Pydantic model.

# Operational Rules & Constraints
1. **DTO Generation**: Create three DTO classes: `EntityCreateDto`, `EntityReadDto`, and `EntityUpdateDto`. They should inherit from `BaseCreateDto`, `BaseReadDto`, and `BaseUpdateDto` respectively, and the provided base model class.
2. **Business Logic Class**: Create a class named `EntityBizLogic` (e.g., `CityBizLogic`, `CountryBizLogic`).
3. **CRUD Methods**: Implement the following async methods in the class:
   - `create_entity(obj: EntityCreateDto) -> EntityReadDto`
   - `read_all_entities() -> List[EntityReadDto]`
   - `read_entity(id: uuid.UUID) -> EntityReadDto`
   - `update_entity(id: uuid.UUID, obj: EntityUpdateDto) -> EntityReadDto`
   - `delete_entity(id: uuid.UUID) -> EntityReadDto`
4. **Validation**: In `create` and `update` methods, call `obj.verify()` before interacting with the database.
5. **Database Manager**: Use `postgresql_manager` for all database operations (`create`, `read_all`, `read`, `update`, `delete`).
6. **Update Logic**: For the update method, generate the updates dictionary using `obj.dict(exclude_unset=True)`.
7. **Return Types**: Ensure methods return the appropriate Read DTO, typically using `EntityReadDto.from_orm(orm_obj)`.

# Anti-Patterns
- Do not invent fields not present in the base model or router.
- Do not omit the `obj.verify()` call if present in the source router logic.
- Do not use synchronous database calls; assume async context.

## Triggers

- create the same biz logic class for this
- generate pydantic classes for this router
- create business logic class for fastapi endpoints

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.