mirror of
https://github.com/koxudaxi/datamodel-code-generator.git
synced 2024-03-18 14:54:37 +03:00
Add code highlight for docs (#1738)
This commit is contained in:
38
README.md
38
README.md
@@ -1,6 +1,7 @@
|
||||
# datamodel-code-generator
|
||||
|
||||
This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) model, [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html), [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict) and [msgspec.Struct](https://github.com/jcrist/msgspec) from an openapi file and others.
|
||||
This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) model, [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html), [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict)
|
||||
and [msgspec.Struct](https://github.com/jcrist/msgspec) from an openapi file and others.
|
||||
|
||||
[](https://pypi.python.org/pypi/datamodel-code-generator)
|
||||
[](https://anaconda.org/conda-forge/datamodel-code-generator)
|
||||
@@ -12,14 +13,12 @@ This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) mod
|
||||
[](https://pydantic.dev)
|
||||
[](https://pydantic.dev)
|
||||
|
||||
|
||||
## Help
|
||||
See [documentation](https://koxudaxi.github.io/datamodel-code-generator) for more details.
|
||||
|
||||
## Sponsors
|
||||
[](https://github.com/JetBrainsOfficial)
|
||||
|
||||
|
||||
## Quick Installation
|
||||
|
||||
To install `datamodel-code-generator`:
|
||||
@@ -238,7 +237,10 @@ class Apis(BaseModel):
|
||||
</details>
|
||||
|
||||
## Projects that use datamodel-code-generator
|
||||
These OSS projects use datamodel-code-generator to generate many models. See the following linked projects for real world examples and inspiration.
|
||||
|
||||
These OSS projects use datamodel-code-generator to generate many models.
|
||||
See the following linked projects for real world examples and inspiration.
|
||||
|
||||
- [airbytehq/airbyte](https://github.com/airbytehq/airbyte)
|
||||
- *[code-generator/Dockerfile](https://github.com/airbytehq/airbyte/blob/master/tools/code-generator/Dockerfile)*
|
||||
- [apache/iceberg](https://github.com/apache/iceberg)
|
||||
@@ -266,18 +268,19 @@ These OSS projects use datamodel-code-generator to generate many models. See the
|
||||
- *[generate-types.sh](https://github.com/SeldonIO/MLServer/blob/master/hack/generate-types.sh)*
|
||||
|
||||
## Supported input types
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#data-types))
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html)/[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html))
|
||||
- JSON/YAML/CSV Data (it will be converted to JSON Schema)
|
||||
- Python dictionary (it will be converted to JSON Schema)
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/))
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#data-types));
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html)/[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html));
|
||||
- JSON/YAML/CSV Data (it will be converted to JSON Schema);
|
||||
- Python dictionary (it will be converted to JSON Schema);
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/));
|
||||
|
||||
## Supported output types
|
||||
- [pydantic](https://docs.pydantic.dev/1.10/).BaseModel
|
||||
- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel
|
||||
- [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html)
|
||||
- [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict)
|
||||
- [msgspec.Struct](https://github.com/jcrist/msgspec)
|
||||
- [pydantic](https://docs.pydantic.dev/1.10/).BaseModel;
|
||||
- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel;
|
||||
- [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html);
|
||||
- [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict);
|
||||
- [msgspec.Struct](https://github.com/jcrist/msgspec);
|
||||
- Custom type from your [jinja2](https://jinja.palletsprojects.com/en/3.1.x/) template;
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -292,6 +295,13 @@ If you want to resolve `$ref` for remote files then you should specify `http` ex
|
||||
$ pip install 'datamodel-code-generator[http]'
|
||||
```
|
||||
|
||||
### `graphql` extra option
|
||||
|
||||
If you want to generate data model from a GraphQL schema then you should specify `graphql` extra option.
|
||||
```bash
|
||||
$ pip install 'datamodel-code-generator[graphql]'
|
||||
```
|
||||
|
||||
### Docker Image
|
||||
The docker image is in [Docker Hub](https://hub.docker.com/r/koxudaxi/datamodel-code-generator)
|
||||
```bash
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# datamodel-code-generator
|
||||
|
||||
This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) model, [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html), [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict) and [msgspec.Struct](https://github.com/jcrist/msgspec)from an openapi file and others.
|
||||
|
||||
This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) model, [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html), [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict) and [msgspec.Struct](https://github.com/jcrist/msgspec) from an openapi file and others.
|
||||
|
||||
[](https://pypi.python.org/pypi/datamodel-code-generator)
|
||||
[](https://anaconda.org/conda-forge/datamodel-code-generator)
|
||||
@@ -13,7 +12,6 @@ This code generator creates [pydantic v1 and v2](https://docs.pydantic.dev/) mod
|
||||
[](https://pydantic.dev)
|
||||
[](https://pydantic.dev)
|
||||
|
||||
|
||||
## Sponsors
|
||||
[](https://github.com/JetBrainsOfficial)
|
||||
|
||||
@@ -187,7 +185,7 @@ components:
|
||||
<details>
|
||||
<summary>model.py</summary>
|
||||
|
||||
```python
|
||||
```py
|
||||
# generated by datamodel-codegen:
|
||||
# filename: api.yaml
|
||||
# timestamp: 2020-06-02T05:28:24+00:00
|
||||
@@ -235,7 +233,10 @@ class Apis(BaseModel):
|
||||
</details>
|
||||
|
||||
## Projects that use datamodel-code-generator
|
||||
These OSS projects use datamodel-code-generator to generate many models. See the following linked projects for real world examples and inspiration.
|
||||
|
||||
These OSS projects use datamodel-code-generator to generate many models.
|
||||
See the following linked projects for real world examples and inspiration.
|
||||
|
||||
- [airbytehq/airbyte](https://github.com/airbytehq/airbyte)
|
||||
- *[code-generator/Dockerfile](https://github.com/airbytehq/airbyte/blob/master/tools/code-generator/Dockerfile)*
|
||||
- [apache/iceberg](https://github.com/apache/iceberg)
|
||||
@@ -263,18 +264,20 @@ These OSS projects use datamodel-code-generator to generate many models. See the
|
||||
- *[generate-types.sh](https://github.com/SeldonIO/MLServer/blob/master/hack/generate-types.sh)*
|
||||
|
||||
## Supported input types
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types))
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html)/[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html))
|
||||
- JSON/YAML/CSV Data (it will be converted to JSON Schema)
|
||||
- Python dictionary (it will be converted to JSON Schema)
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/))
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types));
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html)/[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html));
|
||||
- JSON/YAML/CSV Data (it will be converted to JSON Schema);
|
||||
- Python dictionary (it will be converted to JSON Schema);
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/));
|
||||
|
||||
## Supported output types
|
||||
- [pydantic](https://docs.pydantic.dev/1.10/).BaseModel
|
||||
- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel
|
||||
- [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html)
|
||||
- [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict)
|
||||
- [msgspec.Struct](https://github.com/jcrist/msgspec)
|
||||
- [pydantic](https://docs.pydantic.dev/1.10/).BaseModel;
|
||||
- [pydantic_v2](https://docs.pydantic.dev/2.0/).BaseModel;
|
||||
- [dataclasses.dataclass](https://docs.python.org/3/library/dataclasses.html);
|
||||
- [typing.TypedDict](https://docs.python.org/3/library/typing.html#typing.TypedDict);
|
||||
- [msgspec.Struct](https://github.com/jcrist/msgspec);
|
||||
- Custom type from your [jinja2](https://jinja.palletsprojects.com/en/3.1.x) template;
|
||||
|
||||
## Installation
|
||||
|
||||
To install `datamodel-code-generator`:
|
||||
@@ -288,6 +291,13 @@ If you want to resolve `$ref` for remote files then you should specify `http` ex
|
||||
$ pip install 'datamodel-code-generator[http]'
|
||||
```
|
||||
|
||||
### `graphql` extra option
|
||||
|
||||
If you want to generate data model from a GraphQL schema then you should specify `graphql` extra option.
|
||||
```bash
|
||||
$ pip install 'datamodel-code-generator[graphql]'
|
||||
```
|
||||
|
||||
### Docker Image
|
||||
The docker image is in [Docker Hub](https://hub.docker.com/r/koxudaxi/datamodel-code-generator)
|
||||
```bash
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
This code generator supports the following input formats:
|
||||
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types))
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html) /[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html))
|
||||
- JSON/YAML Data (it will be converted to JSON Schema)
|
||||
- Python dictionary (it will be converted to JSON Schema)
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/))
|
||||
- OpenAPI 3 (YAML/JSON, [OpenAPI Data Type](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#data-types));
|
||||
- JSON Schema ([JSON Schema Core](http://json-schema.org/draft/2019-09/json-schema-validation.html) /[JSON Schema Validation](http://json-schema.org/draft/2019-09/json-schema-validation.html));
|
||||
- JSON/YAML Data (it will be converted to JSON Schema);
|
||||
- Python dictionary (it will be converted to JSON Schema);
|
||||
- GraphQL schema ([GraphQL Schemas and Types](https://graphql.org/learn/schema/));
|
||||
|
||||
## Implemented data types and features
|
||||
|
||||
@@ -39,4 +39,4 @@ Below are the data types and features recognized by datamodel-code-generator for
|
||||
- anyOf (as typing.Union)
|
||||
- oneOf (as typing.Union)
|
||||
- $ref ([http extra](../#http-extra-option) is required when resolving $ref for remote files.)
|
||||
- $id (for [JSONSchema](https://json-schema.org/understanding-json-schema/structuring.html#id)
|
||||
- $id (for [JSONSchema](https://json-schema.org/understanding-json-schema/structuring.html#id))
|
||||
|
||||
@@ -8,8 +8,15 @@ theme:
|
||||
accent: 'light blue'
|
||||
analytics:
|
||||
gtag: 275257853
|
||||
|
||||
markdown_extensions:
|
||||
- codehilite
|
||||
- pymdownx.highlight:
|
||||
anchor_linenums: true
|
||||
line_spans: __span
|
||||
pygments_lang_class: true
|
||||
- pymdownx.inlinehilite
|
||||
- pymdownx.snippets
|
||||
- pymdownx.superfences
|
||||
- admonition
|
||||
|
||||
repo_name: koxudaxi/datamodel-code-generator
|
||||
|
||||
Reference in New Issue
Block a user