Skip to content

Generator would parse version number as float string #50

Closed
@raymond-u

Description

@raymond-u

Describe

I encountered a problem that the class generator seems to parse version number as float or float strings.

I'm using the latest version installed with pip, and I used the following command to generate the model.

$ json2models -s nested --max-strings-literals 0 -m VersionInfo version_info.json >version_info.py

Reproduce

Package version: 0.2.7
JSON data:

{
	"Version": [{
		"Name": "1.1",
		"Url": "https://foo"
	}, {
		"Name": "1.2",
		"Url": "https://foo"
	}]
}

Actual result

Class code:

from json_to_models.dynamic_typing import FloatString
from typing import List


class VersionInfo:
    class Version:
        name: FloatString
        url: str

    version: List['Version']

Expected result

Class code:

from typing import List


class VersionInfo:
    class Version:
        name: str
        url: str

    version: List['Version']

Additional context

I'd like an option to disable all string converters, if possible (e.g., --disable-strings-converters).
Thanks for the great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLICommand line agruments and related code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions