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

SwiftFormatter doesn't make use of IntegerItem.format to support Int32 and Int64 #53

Closed
martinknabbe opened this issue Nov 28, 2017 · 2 comments · Fixed by #54
Closed

Comments

@martinknabbe
Copy link
Contributor

Swagger provides the field format for integer types to distinguish between int32 and int64 (https://swagger.io/specification/#dataTypeFormat). This field is parsed in IntegerItem, though the SwiftFormatter ignores it and uses always Int as Swift type.
This can lead to loss of data, e.g. when Swagger specification contains int32 and generated code is running on device with 64-bit architecture. Putting a value bigger than int32 max into the field will result in a wrong value on receivers side.

@yonaskolb
Copy link
Owner

Hi @martinknabbe.
Yes, you’re right. This was actually done on purpose to make working with Ints easier to work with in the swift client, and follows Apple’s recommendations with regards to the use of Int.
I can understand though if someone would want to be more strict for certain use cases, so it should be an option added to the template. I don’t have time to work on this right now, but would happily accept a PR.

@martinknabbe
Copy link
Contributor Author

Thanks for the quick answer. Sure, will do a PR with the requested changes.

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

Successfully merging a pull request may close this issue.

2 participants