Skip to content

When providing example json with a value great than Integer/MAX_VALUE, it should generate a long field in Java #971

Closed

Description

@Loki-Afro

When providing an json with a long it generates an int

input:

{
	"id": "c3a8edfe-9654-4663-9037-e4f6384cd963",
	"createdTimestamp": 1555001539041
}

output:

@JsonProperty("createdTimestamp")
private Integer createdTimestamp;

but 1555001539041 is bigger than java.lang.Integer#MAX_VALUE

shouldn't this get detected by default? I know there is a config somewhere ...

Activity

  1. muka commented on Mar 24, 2020

    @muka

    From the command line

       -l, --long-integers
           Use long (or Long) instead of int (or Integer) when the JSON Schema type
           'integer' is encountered
           Default: false
    
  2. Loki-Afro commented on Mar 24, 2020

    @Loki-Afro
    Author

    @muka but wouldn't that change all integers to long?

    That's why I wrote detected when there is an integer higher than java.lang.Integer#MAX_VALUE use long instead.

    Also based on the documentation snippet, I am not providing a schema, but a JSON directly. Parameter makes absolutely sense for schemas ;)

  3. muka commented on Mar 24, 2020

    @muka
  4. added this to the 1.1.1 milestone on Apr 2, 2021
  5. changed the title [-]When providing an json with a long it generates an int[/-] [+]When providing example json with a value great than Integer/MAX_VALUE, it should generate a long field in Java[/+] on Apr 2, 2021
  6. added a commit that references this issue on Aug 8, 2024
    c90da8c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions