Describe the bug
Extra, invalid line generated with Pydantic.
This line doesn't do anything useful and even after trying several codegen versions and flags variations, I was unable to get an output that doesn't have it and doesn't break the Python interpreter. The line:
import MapStateItem1 as MapStateItem1_1
The error:
ModuleNotFoundError: No module named 'MapStateItem1'
To Reproduce
{
"$id": "https://example.com/schemas/MapState.json",
"title": "MapState",
"allOf": [
{
"anyOf": [
{
"type": "object",
"properties": {
"latitude": {
"type": "number",
"minimum": -90,
"maximum": 90
},
"longitude": {
"type": "number",
"minimum": -180,
"maximum": 180
},
"zoom": {
"type": "number",
"minimum": 0,
"maximum": 25,
"default": 0
},
"bearing": {
"type": "number"
},
"pitch": {
"type": "number",
"minimum": 0,
"exclusiveMaximum": 90
},
"dragRotate": {
"type": "boolean"
},
"mapSplitMode": {
"type": "string",
"const": "SINGLE_MAP"
},
"isSplit": {
"type": "boolean",
"const": false,
"default": false
}
},
"required": [
"latitude",
"longitude",
"pitch",
"mapSplitMode"
]
},
{
"type": "object",
"properties": {
"latitude": {
"$ref": "#/allOf/0/anyOf/0/properties/latitude"
},
"longitude": {
"$ref": "#/allOf/0/anyOf/0/properties/longitude"
},
"zoom": {
"$ref": "#/allOf/0/anyOf/0/properties/zoom"
},
"bearing": {
"$ref": "#/allOf/0/anyOf/0/properties/bearing"
},
"pitch": {
"$ref": "#/allOf/0/anyOf/0/properties/pitch"
},
"dragRotate": {
"$ref": "#/allOf/0/anyOf/0/properties/dragRotate"
},
"mapSplitMode": {
"type": "string",
"const": "SWIPE_COMPARE"
},
"isSplit": {
"type": "boolean",
"const": true,
"default": true
}
},
"required": [
"latitude",
"longitude",
"pitch",
"mapSplitMode"
]
},
{
"type": "object",
"properties": {
"latitude": {
"$ref": "#/allOf/0/anyOf/0/properties/latitude"
},
"longitude": {
"$ref": "#/allOf/0/anyOf/0/properties/longitude"
},
"zoom": {
"$ref": "#/allOf/0/anyOf/0/properties/zoom"
},
"bearing": {
"$ref": "#/allOf/0/anyOf/0/properties/bearing"
},
"pitch": {
"$ref": "#/allOf/0/anyOf/0/properties/pitch"
},
"dragRotate": {
"$ref": "#/allOf/0/anyOf/0/properties/dragRotate"
},
"mapSplitMode": {
"type": "string",
"const": "DUAL_MAP"
},
"isSplit": {
"type": "boolean",
"const": true,
"default": true
},
"isViewportSynced": {
"type": "boolean",
"const": true,
"default": true
}
},
"required": [
"latitude",
"longitude",
"pitch",
"mapSplitMode"
]
},
{
"type": "object",
"properties": {
"latitude": {
"$ref": "#/allOf/0/anyOf/0/properties/latitude"
},
"longitude": {
"$ref": "#/allOf/0/anyOf/0/properties/longitude"
},
"zoom": {
"$ref": "#/allOf/0/anyOf/0/properties/zoom"
},
"bearing": {
"$ref": "#/allOf/0/anyOf/0/properties/bearing"
},
"pitch": {
"$ref": "#/allOf/0/anyOf/0/properties/pitch"
},
"dragRotate": {
"$ref": "#/allOf/0/anyOf/0/properties/dragRotate"
},
"mapSplitMode": {
"type": "string",
"const": "DUAL_MAP"
},
"isSplit": {
"type": "boolean",
"const": true,
"default": true
},
"isViewportSynced": {
"type": "boolean",
"const": false,
"default": false
},
"isZoomLocked": {
"type": "boolean",
"default": false
},
"splitMapViewports": {
"type": "array",
"items": {
"type": "object",
"properties": {
"latitude": {
"$ref": "#/allOf/0/anyOf/0/properties/latitude"
},
"longitude": {
"$ref": "#/allOf/0/anyOf/0/properties/longitude"
},
"zoom": {
"$ref": "#/allOf/0/anyOf/0/properties/zoom"
},
"bearing": {
"$ref": "#/allOf/0/anyOf/0/properties/bearing"
},
"pitch": {
"$ref": "#/allOf/0/anyOf/0/properties/pitch"
},
"dragRotate": {
"$ref": "#/allOf/0/anyOf/0/properties/dragRotate"
}
},
"required": [
"latitude",
"longitude",
"pitch"
]
}
}
},
"required": [
"latitude",
"longitude",
"pitch",
"mapSplitMode",
"splitMapViewports"
]
}
]
},
{
"anyOf": [
{
"type": "object",
"properties": {
"mapViewMode": {
"type": "string",
"const": "MODE_2D"
}
},
"required": [
"mapViewMode"
]
},
{
"type": "object",
"properties": {
"mapViewMode": {
"type": "string",
"const": "MODE_3D"
}
},
"required": [
"mapViewMode"
]
},
{
"type": "object",
"properties": {
"mapViewMode": {
"type": "string",
"const": "MODE_GLOBE"
},
"globe": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"config": {
"type": "object",
"properties": {
"atmosphere": {
"type": "boolean"
},
"azimuth": {
"type": "boolean"
},
"azimuthAngle": {
"type": "number"
},
"terminator": {
"type": "boolean"
},
"terminatorOpacity": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"basemap": {
"type": "boolean"
},
"labels": {
"type": "boolean",
"default": false
},
"labelsColor": {
"anyOf": [
{
"type": "array",
"minItems": 3,
"maxItems": 3,
"items": [
{
"type": "number",
"minimum": 0,
"maximum": 255
},
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
},
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
}
]
},
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": [
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
},
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
},
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
},
{
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor/anyOf/0/items/0"
}
]
}
],
"default": [
114.75,
114.75,
114.75
]
},
"adminLines": {
"type": "boolean",
"default": true
},
"adminLinesColor": {
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor",
"default": [
40,
63,
93
]
},
"water": {
"type": "boolean",
"default": true
},
"waterColor": {
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor",
"default": [
17,
35,
48
]
},
"surface": {
"type": "boolean",
"default": true
},
"surfaceColor": {
"$ref": "#/allOf/1/anyOf/2/properties/globe/properties/config/properties/labelsColor",
"default": [
9,
16,
29
]
}
},
"required": [
"atmosphere",
"azimuth",
"azimuthAngle",
"terminator",
"terminatorOpacity",
"basemap"
]
}
},
"required": [
"enabled",
"config"
]
}
},
"required": [
"mapViewMode",
"globe"
]
}
]
}
],
"$schema": "http://json-schema.org/draft-07/schema#"
}
Used commandline:
$ datamodel-codegen --disable-timestamp --input-file-type jsonschema --output-model-type pydantic.BaseModel --snake-case-field --custom-file-header "# type: ignore" --use-double-quotes --reuse-model
Expected behavior
For generated model to work properly without any extra lines that break Python interpreter.
Version:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too