@@ -85,7 +85,19 @@ HTTP Accept indicates what content types the web request will accept as a respon
8585
8686 # If provided, will add inline help to parameters.
8787 [Collections.IDictionary ]
88- $ParameterHelp
88+ $ParameterHelp ,
89+
90+ <#
91+ If set, will weakly type parameters generated by reflection.
92+
93+ 1. Any parameter type implements IList should be made a [PSObject[]]
94+ 2. Any parameter that implements IDictionary should be made an [Collections.IDictionary]
95+ 3. Booleans should be made into [switch]es
96+ 4. All other parameter types should be [PSObject]
97+ #>
98+ [Alias (' WeakType' , ' WeakParameters' , ' WeaklyTypedParameters' , ' WeakProperties' , ' WeaklyTypedProperties' )]
99+ [switch ]
100+ $WeaklyTyped
89101 )
90102
91103 begin {
@@ -205,7 +217,7 @@ HTTP Accept indicates what content types the web request will accept as a respon
205217
206218 foreach ($prop in $Parameter ) {
207219 if ($prop -is [Reflection.PropertyInfo ] -and -not $prop.CanWrite ) { continue }
208- $paramType =
220+ $paramType =
209221 if ($prop.ParameterType ) {
210222 $prop.ParameterType
211223 } elseif ($prop.PropertyType ) {
@@ -222,7 +234,18 @@ HTTP Accept indicates what content types the web request will accept as a respon
222234 $parameterAttribute
223235 if ($paramType -eq [boolean ]) {
224236 " [switch]"
225- } else {
237+ } elseif ($WeaklyTyped ) {
238+ if ($paramType.GetInterface ([Collections.IDictionary ])) {
239+ " [Collections.IDictionary]"
240+ }
241+ elseif ($paramType.GetInterface ([Collections.IList ])) {
242+ " [PSObject[]]"
243+ }
244+ else {
245+ " [PSObject]"
246+ }
247+ }
248+ else {
226249 " [$ ( $paramType -replace ' ^System\.' ) ]"
227250 }
228251 ' $' + $prop.Name
0 commit comments