Skip to content

json schema "number" by default returns an integer cast to a float. #127

@bisgaard-itis

Description

@bisgaard-itis

The following example shows that jsf by default generates an integer (and casts it to a float) for properties specified as "number" in a json schema.

from jsf import JSF
import json


schema = json.loads('{"type":"object","properties":{"input_1":{"type":"number"}},"required":["input_1"]}')
faker = JSF(schema)

print(faker.generate())

A json schema number could be an integer, but it could also be a float (see https://json-schema.org/understanding-json-schema/reference/numeric#numeric-types). To distinguish the "number" type from "integer" I would have expected that jsf would generate random floats for the "number" type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions