datamodel-code-generator

datamodel-code-generator

Generate Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct from various data formats.

Agent SkillDevOpen source
Type
Agent Skill
Open source
Yes
GitHub Stars
★ 4.0k
Source
skill-github

Overview

datamodel-code-generator is a powerful tool that generates Python data models from multiple data formats including OpenAPI, JSON Schema, GraphQL, Avro, Protobuf, and raw JSON/YAML/CSV. It supports generating Pydantic v2 models, dataclasses, TypedDict, and msgspec.Struct. The tool handles complex schema definitions such as `$ref`, `allOf`, `oneOf`, `anyOf`, enumerations, and nested types. With a simple command-line interface, users can quickly generate type-safe and validated code that works well with IDEs and type checkers. Ideal for developers who need to generate Python data models from various data sources.

Capabilities

  • ▪Generate Pydantic v2 models from OpenAPI
  • ▪Generate dataclasses from JSON Schema
  • ▪Generate TypedDict from GraphQL
  • ▪Generate msgspec.Struct from Avro
  • ▪Handle complex schema definitions
  • ▪Generate type-safe code

Use cases

Generate data models from API documentationGenerate Python classes from JSON SchemaGenerate type definitions from GraphQLGenerate structs from Protobuf

Setup

Requires: Python 环境pip
pip install datamodel-code-generator

This information was compiled by AI from public sources and may contain inaccuracies — please refer to the source.

FAQ

How do I install additional dependencies?

Use `pip install 'datamodel-code-generator[http]'` to install HTTP support.

Is Docker support available?

Yes, you can use `docker pull koxudaxi/datamodel-code-generator`.

Related skills