Skip to content

Commit ca48ae2

Browse files
committed
Remove pydantic v1 output support
1 parent 69e33a8 commit ca48ae2

379 files changed

Lines changed: 3248 additions & 5809 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/datamodel-code-generator)](https://pypi.python.org/pypi/datamodel-code-generator)
99
[![codecov](https://codecov.io/gh/koxudaxi/datamodel-code-generator/graph/badge.svg?token=plzSSFb9Li)](https://codecov.io/gh/koxudaxi/datamodel-code-generator)
1010
![license](https://img.shields.io/github/license/koxudaxi/datamodel-code-generator.svg)
11-
[![Pydantic v1](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v1.json)](https://pydantic.dev)
1211
[![Pydantic v2](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json)](https://pydantic.dev)
1312

1413
> 📣 💼 Maintainer update: Open to opportunities. 🔗 [koxudaxi.dev](https://koxudaxi.dev/?utm_source=github_readme&utm_medium=top&utm_campaign=open_to_work)
@@ -17,7 +16,7 @@
1716

1817
- 📄 Converts **OpenAPI 3**, **JSON Schema**, **GraphQL**, and raw data (JSON/YAML/CSV) into Python models
1918
- 🐍 Generates from **existing Python types** (Pydantic, dataclass, TypedDict) via `--input-model`
20-
- 🎯 Generates **Pydantic v1/v2**, **dataclasses**, **TypedDict**, or **msgspec** output
19+
- 🎯 Generates **Pydantic v2**, **dataclasses**, **TypedDict**, or **msgspec** output
2120
- 🔗 Handles complex schemas: `$ref`, `allOf`, `oneOf`, `anyOf`, enums, and nested types
2221
- ✅ Produces type-safe, validated code ready for your IDE and type checker
2322

@@ -161,7 +160,6 @@ class Pet(BaseModel):
161160

162161
## 📤 Supported Output
163162

164-
- [pydantic v1](https://docs.pydantic.dev/1.10/) BaseModel
165163
- [pydantic v2](https://docs.pydantic.dev/) BaseModel
166164
- [pydantic v2](https://docs.pydantic.dev/) dataclass
167165
- [dataclasses](https://docs.python.org/3/library/dataclasses.html)

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
description: 'Input file type (openapi, jsonschema, json, yaml, csv, graphql)'
1616
required: true
1717
output-model-type:
18-
description: 'Output model type (pydantic_v2.BaseModel, pydantic.BaseModel, dataclasses.dataclass, typing.TypedDict, msgspec.Struct)'
18+
description: 'Output model type (pydantic_v2.BaseModel, dataclasses.dataclass, typing.TypedDict, msgspec.Struct)'
1919
required: true
2020
check:
2121
description: 'Validate that existing output is up to date (no generation)'

docs/ci-cd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ By default, the action runs in **check mode** (`--check`), which validates that
3333
| `input` | Yes | - | Input schema file or directory |
3434
| `output` | Yes | - | Output file or directory |
3535
| `input-file-type` | Yes | - | Input file type (`openapi`, `jsonschema`, `json`, `yaml`, `csv`, `graphql`) |
36-
| `output-model-type` | Yes | - | Output model type (`pydantic_v2.BaseModel`, `pydantic.BaseModel`, `dataclasses.dataclass`, `typing.TypedDict`, `msgspec.Struct`) |
36+
| `output-model-type` | Yes | - | Output model type (`pydantic_v2.BaseModel`, `dataclasses.dataclass`, `typing.TypedDict`, `msgspec.Struct`) |
3737
| `check` | No | `true` | Validate that existing output is up to date (no generation) |
3838
| `working-directory` | No | `.` | Working directory (where `pyproject.toml` is located) |
3939
| `profile` | No | - | Named profile from `pyproject.toml` |

docs/cli-reference/base-options.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,8 @@ instead of generating duplicate classes from external schema files.
134134

135135
from __future__ import annotations
136136

137-
from datetime import datetime
138-
139137
from mypackage.shared.models import Error, User
140-
from pydantic import BaseModel
138+
from pydantic import AwareDatetime, BaseModel
141139

142140

143141
class UserResponse(BaseModel):
@@ -147,7 +145,7 @@ instead of generating duplicate classes from external schema files.
147145

148146
class ErrorResponse(BaseModel):
149147
error: Error
150-
timestamp: datetime
148+
timestamp: AwareDatetime
151149
```
152150

153151
---
@@ -257,7 +255,7 @@ not `--input-file-type yaml`. The `yaml` type treats the file as raw data and in
257255
258256
from __future__ import annotations
259257
260-
from pydantic import BaseModel
258+
from pydantic import BaseModel, Field
261259
262260
263261
class Pet(BaseModel):
@@ -266,7 +264,7 @@ not `--input-file-type yaml`. The `yaml` type treats the file as raw data and in
266264
267265
268266
class Model(BaseModel):
269-
Pet: Pet
267+
Pet_1: Pet = Field(..., alias='Pet')
270268
```
271269

272270
=== "YAML"
@@ -288,7 +286,7 @@ not `--input-file-type yaml`. The `yaml` type treats the file as raw data and in
288286
289287
from __future__ import annotations
290288
291-
from pydantic import BaseModel
289+
from pydantic import BaseModel, Field
292290
293291
294292
class Pet(BaseModel):
@@ -297,7 +295,7 @@ not `--input-file-type yaml`. The `yaml` type treats the file as raw data and in
297295
298296
299297
class Model(BaseModel):
300-
Pet: Pet
298+
Pet_1: Pet = Field(..., alias='Pet')
301299
```
302300

303301
---

0 commit comments

Comments
 (0)