Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casts default values of type number (scientific notation) to str #1955

Open
maximilian-tech opened this issue May 11, 2024 · 0 comments
Open

Comments

@maximilian-tech
Copy link

Describe the bug
Bug in parsing number in scientific notation

To Reproduce

Example schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "test": {
            "type": "number",
            "title": "Test",
            "description": "Testcase",
            "default": 1e-5
        }
    }
}

Used commandline:

$  datamodel-codegen --input test_codegen.json --output model_test_codegen.py --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema

Observed behavior

class Model(BaseModel):
    test: Optional[float] = Field('1e-5', description='Testcase', title='Test')

Expected behavior

class Model(BaseModel):
    test: Optional[float] = Field(1e-5, description='Testcase', title='Test')

Version:

  • OS: Linux
  • Python version: 3.10.12
  • datamodel-code-generator version: 0.25.6

Maybe related to #1952 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant