agentsclimarketplace

Generate pydantic dtos and business logic class from fastapi rou

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/generate-pydantic-dtos-and-business-logic-class-from-fastapi-rou

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.From its SKILL.md

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

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.6 KB, 500 tokens by cl100k_base, as published. Nobody here has run it

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

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.