Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/add-pydantic-emitter-2026-02-13-02-26-11.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@typespec/pydantic"
---

Add new `@typespec/pydantic` emitter that generates Python pydantic model classes from TypeSpec definitions. Models are categorized by HTTP operation usage into separate modules (`input_types.py`, `output_types.py`, `roundtrip_types.py`). Includes support for constraints, enums, unions, inheritance, and configurable module names.
1 change: 1 addition & 0 deletions .chronus/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ versionPolicies:
packages:
- "@typespec/http-client-python"
- "@typespec/http-client-java"
- "@typespec/pydantic"

changelog: ["@chronus/github/changelog", { repo: "microsoft/typespec" }]

Expand Down
1 change: 1 addition & 0 deletions cspell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ words:
- pyimport
- pylint
- pylintrc
- pydantic
- pyodide
- pyproject
- pyright
Expand Down
1 change: 1 addition & 0 deletions packages/pydantic/lib/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@typespec/http";
68 changes: 68 additions & 0 deletions packages/pydantic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@typespec/pydantic",
"version": "0.1.0",
"author": "Microsoft Corporation",
"description": "TypeSpec library for emitting Pydantic model classes",
"homepage": "https://github.com/microsoft/typespec",
"readme": "https://github.com/microsoft/typespec/blob/main/README.md",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/microsoft/typespec.git"
},
"bugs": {
"url": "https://github.com/microsoft/typespec/issues"
},
"keywords": [
"TypeSpec",
"pydantic",
"python"
],
"type": "module",
"main": "dist/src/index.js",
"exports": {
".": {
"typespec": "./lib/main.tsp",
"types": "./dist/src/index.d.ts",
"default": "./dist/src/index.js"
},
"./testing": {
"types": "./dist/src/testing/index.d.ts",
"default": "./dist/src/testing/index.js"
}
},
"tspMain": "lib/main.tsp",
"engines": {
"node": ">=20.0.0"
},
"scripts": {
"clean": "rimraf ./dist ./temp",
"build": "tsc -p tsconfig.build.json",
"watch": "tsc -p tsconfig.build.json --watch",
"test": "vitest run",
"test:ui": "vitest --ui",
"test:ci": "vitest run --coverage --reporter=junit --reporter=default",
"lint": "eslint . --max-warnings=0",
"lint:fix": "eslint . --fix"
},
"files": [
"lib/*.tsp",
"dist/**",
"!dist/test/**"
],
"peerDependencies": {
"@typespec/compiler": "workspace:^",
"@typespec/http": "workspace:^"
},
"devDependencies": {
"@types/node": "~25.0.2",
"@typespec/compiler": "workspace:^",
"@typespec/http": "workspace:^",
"@typespec/rest": "workspace:^",
"@vitest/coverage-v8": "^4.0.15",
"@vitest/ui": "^4.0.15",
"rimraf": "~6.1.2",
"typescript": "~5.9.2",
"vitest": "^4.0.15"
}
}
Loading