You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
Currently params had to be one of the supported types, or expose a
`valueOf` function. However at Faire, we want to offer better type
validation for our parameters. For example, we have `Token<T>` where `T`
could be something like `Brand` or `Product`. Each of these token types
has a unique prefix, so even if we have a `valueOf` function exposed we
lack the ability to validate the type is correct. With this change we
can inspect the type of the parameter, and validate it's the correct
type before converting the `String`.
Note that this is technically a breaking change because I've changed
`StringConverter` to an interface, and updated the public constructor of
`FeatureBindingFactory`, but they're small enough changes that I don't
think people will have any issues upgrading.
## Testing Strategy
I updated `QueryParamFeatureBindingTest` to show that a custom
`StringConverter` can be used to properly parse a string to a value
class, which otherwise would fail. I didn't update all the other binding
tests because the code path is the same, but can update them if people
feel strongly.
GitOrigin-RevId: ce50018634417ae91eef5dbba8d7e6d7c58c9b1f
Copy file name to clipboardExpand all lines: misk/api/misk.api
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1296,7 +1296,11 @@ public final class misk/web/FeatureBinding$DefaultImpls {
1296
1296
}
1297
1297
1298
1298
public abstract interface class misk/web/FeatureBinding$Factory {
1299
-
public abstract fun create (Lmisk/Action;Lmisk/web/PathPattern;Lmisk/web/FeatureBinding$Claimer;)Lmisk/web/FeatureBinding;
1299
+
public abstract fun create (Lmisk/Action;Lmisk/web/PathPattern;Lmisk/web/FeatureBinding$Claimer;Ljava/util/List;)Lmisk/web/FeatureBinding;
1300
+
}
1301
+
1302
+
public final class misk/web/FeatureBinding$Factory$DefaultImpls {
1303
+
public static synthetic fun create$default (Lmisk/web/FeatureBinding$Factory;Lmisk/Action;Lmisk/web/PathPattern;Lmisk/web/FeatureBinding$Claimer;Ljava/util/List;ILjava/lang/Object;)Lmisk/web/FeatureBinding;
1300
1304
}
1301
1305
1302
1306
public abstract interface class misk/web/FeatureBinding$Subject {
@@ -1857,8 +1861,17 @@ public final class misk/web/extractors/RequestBodyException : java/io/IOExceptio
1857
1861
public fun <init> (Ljava/lang/Throwable;)V
1858
1862
}
1859
1863
1864
+
public abstract interface class misk/web/extractors/StringConverter {
1865
+
public abstract fun convert (Ljava/lang/String;)Ljava/lang/Object;
1866
+
}
1867
+
1868
+
public abstract interface class misk/web/extractors/StringConverter$Factory {
1869
+
public abstract fun create (Lkotlin/reflect/KType;)Lmisk/web/extractors/StringConverter;
1870
+
}
1871
+
1860
1872
public final class misk/web/extractors/StringConverterKt {
1861
-
public static final fun converterFor (Lkotlin/reflect/KType;)Lkotlin/jvm/functions/Function1;
1873
+
public static final fun converterFor (Lkotlin/reflect/KType;Ljava/util/List;)Lmisk/web/extractors/StringConverter;
1874
+
public static synthetic fun converterFor$default (Lkotlin/reflect/KType;Ljava/util/List;ILjava/lang/Object;)Lmisk/web/extractors/StringConverter;
1862
1875
}
1863
1876
1864
1877
public final class misk/web/formatter/ClassNameFormatter {
0 commit comments