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

Respect format int32/int64 #855

Closed
jklingsporn opened this issue Apr 27, 2018 · 4 comments
Closed

Respect format int32/int64 #855

jklingsporn opened this issue Apr 27, 2018 · 4 comments

Comments

@jklingsporn
Copy link

Given this yaml schema

type: object
properties:
  thisShouldBeInt:
    type: integer
    format: int32
  thisShouldBeLong:
    type: integer
    format: int64

it generates a data object with both fields being Integer and not - as one would suspect - thisShouldBeLong being of type Long. As a workaround, I could use format utc-millisec but I really think format int64 should render Longtoo.

@thachhoang
Copy link
Collaborator

Just noting that int32 and int64 are not (at least not yet) part of the JSON schema spec, but defined by OAS/Swagger. Another workaround, if you don't want to edit the schema, is to force all integer fields to use Long with the useLongIntegers option.

@jklingsporn
Copy link
Author

jklingsporn commented May 8, 2018

Thanks for the reply. However I'm just wondering, because format is already supported, so supporting formats for integer type should be a low-hanging fruit. On the other hand I understand, that it is not (yet) part of the spec and if you add it now, and the spec will follow another syntax in the future, you are in a bad situation.
Is there an option (planned) to hook into the format-checks (besides forking)?

@jrehwaldt
Copy link
Contributor

You can register your own formats once 1.0.0-beta1 is released. Have a look at #923

@jklingsporn
Copy link
Author

I'll close this. For future readers: this is what you need to add to the maven-plugin in the <configuration>-tag:

<formatTypeMapping>
       <int64>java.lang.Long</int64>
</formatTypeMapping>

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

3 participants