|
7 | 7 | "import ormar",
|
8 | 8 | "import ormar.exceptions",
|
9 | 9 | "from fastapi import HTTPException",
|
10 |
| - "", |
11 | 10 | "from freenit.api.router import route",
|
12 | 11 | "",
|
13 | 12 | "from ..models.${1} import ${1/(.*)/${1:/capitalize}/}, ${1/(.*)/${1:/capitalize}/}Optional",
|
14 | 13 | "",
|
| 14 | + "tags=['${1}']", |
| 15 | + "", |
15 | 16 | "",
|
16 |
| - "@route('/${1}s', tags=['${1}'])", |
| 17 | + "@route('/${1}s', tags=tags)", |
17 | 18 | "class ${1/(.*)/${1:/capitalize}/}ListAPI():",
|
18 | 19 | " @staticmethod",
|
19 | 20 | " async def get() -> List[${1/(.*)/${1:/capitalize}/}]:",
|
|
25 | 26 | " return ${1}",
|
26 | 27 | "",
|
27 | 28 | "",
|
28 |
| - "@route('/${1}s/{id}', tags=['${1}'])", |
| 29 | + "@route('/${1}s/{id}', tags=tags)", |
29 | 30 | "class ${1/(.*)/${1:/capitalize}/}DetailAPI():",
|
30 | 31 | " @staticmethod",
|
31 | 32 | " async def get(id: int) -> ${1/(.*)/${1:/capitalize}/}:",
|
|
60 | 61 | "prefix": "freenitormar",
|
61 | 62 | "body": [
|
62 | 63 | "import ormar",
|
63 |
| - "", |
64 |
| - "from freenit.models.ormar.base import OrmarBaseModel, generate_optional, ormar_config", |
| 64 | + "from freenit.models.ormar.base import (", |
| 65 | + " OrmarBaseModel,", |
| 66 | + " generate_optional,", |
| 67 | + " ormar_config,", |
| 68 | + ")", |
65 | 69 | "",
|
66 | 70 | "",
|
67 | 71 | "class ${1}(OrmarBaseModel):",
|
|
73 | 77 | "${1}Optional = generate_optional(${1})"
|
74 | 78 | ],
|
75 | 79 | "description": "Freenit model using Ormar"
|
| 80 | + }, |
| 81 | + |
| 82 | + "pydantic": { |
| 83 | + "prefix": "freenitpydantic", |
| 84 | + "body": [ |
| 85 | + "from pydantic import BaseModel, Field", |
| 86 | + "from freenit.models.ormar.base import generate_optional", |
| 87 | + "", |
| 88 | + "", |
| 89 | + "class ${1}(BaseModel):", |
| 90 | + " ${2:field_name}: str = Field(\"\", description=(\"${3:Field description}\"))", |
| 91 | + "", |
| 92 | + "", |
| 93 | + "${1}Optional = generate_optional(${1})" |
| 94 | + ], |
| 95 | + "description": "Freenit model using Pydantic" |
76 | 96 | }
|
77 | 97 | }
|
0 commit comments