Skip to content

Generate integers for "number" schema? #80

Open
@Stranger6667

Description

@Stranger6667

At the moment the "number" type corresponds to st.float strategy, but as integers are valid for the "number" type in JSON Schema, I am wondering whether it will make sense to generate integers there as well.

I believe it may increase the output variation. What do you think?

I was thinking about your comment in the context of negating schemas and tried to canonicalise {"not": {"minimum": 42}} which gives {'not': {'minimum': 42, 'type': 'number'}, 'type': 'number'}. Even though it is a valid transformation, it seems too restrictive. For example, the end-user might expect that negating {"minimum": 42} will give e.g. 41, or some other integers, but there will be always floats. Having type: integer in place will solve this ({"not": {"minimum": 42}, "type": "integer"} works), but still sometimes it happens that it is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions