-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle values with multiple types (including null) [SCH-1643] (#57)
This PR extends our test suite to cover JSON Schemas with properties that specify union types (`type: ["string", "number"]`), including union types with a `null` type (`type: ["string", "null"]`). Specifically, this resolves an issue with the Android client not generating enums (and instead crashing during `typewriter gen-android`). ------ While testing the example Android app against Turo's inferred spec, I also noticed that there were collisions between property key names, because similar properties (like `optional any` and `optional_any`) would map to the same key identifier (`OPTIONAL_ANY_KEY`). This was fixed by inlining these values. ------- I also identified an issue with event name collisions, specifically if you have two event names that differ by delimiter characters (f.e. `check_in_event` and `checkin_event`). They both map to the same filename (causing one of the files to be overwritten). In this example case, `CheckInEvent.java` and `CheckinEvent.java` (note: file systems are case-insensitive). Java will end up complaining because the class name (either `CheckInEvent` or `CheckinEvent`) differs from the filename. This can be solved by an upstream PR to QuickType ([see our conversation in Slack](https://quicktype.slack.com/archives/C68E91E8J/p1551486779009600)), but I'm not going to block this PR on that. The fix would be to make the `Namer` case-insensitive so that it uses a suffix in both the class and file names to differentiate between these events. The simplest solution for affected users is to remove all but one of the colliding events. Usually these events appear due to inferring on bad data, so it usually won't be a problem. I've added a warning that notifies users when their Tracking Plan contains events that collide in Android. ------ I also made a few refactoring changes: - The logic to generate QuickType's `inputData` is duplicated across all QuickType-based clients, so I moved that out to `utils/rules.ts` - Removed `PropertiesSerializable` because it wasn't necessary
- Loading branch information
Showing
31 changed files
with
2,358 additions
and
635 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
examples/gen-android/java/app/src/main/java/com/segment/analytics/KicksAppAnalytics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
...ples/gen-android/java/app/src/main/java/com/segment/analytics/PropertiesSerializable.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.