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
Copy file name to clipboardExpand all lines: README.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,7 +222,7 @@ Using comment tags, arguments can be customized.
222
222
|---|---
223
223
| `@ignored` | This field will be ignored.
224
224
| `@default {<value>}` | The `default` attribute of the parameter will be set to `<value>`
225
-
| `@range {<type>}` | The `range` attribute of the parameter will be set to `<type>`. You can only use values that fit the type of field. Options: `boolean, int, integer, number, byte, long, float, decimal, double, string`. For example, if your field has the type `number`, you could explicitly mark it as a `float` by using `@range {float}`. See [the documentation](https://componentsjs.readthedocs.io/en/latest/configuration/components/parameters/).
225
+
| `@range {<type>}` | The `range` attribute of the parameter will be set to `<type>`. You can only use values that fit the type of field. Options: `json, boolean, int, integer, number, byte, long, float, decimal, double, string`. For example, if your field has the type `number`, you could explicitly mark it as a `float` by using `@range {float}`. See [the documentation](https://componentsjs.readthedocs.io/en/latest/configuration/components/parameters/).
226
226
227
227
#### Examples
228
228
@@ -265,6 +265,59 @@ Component file:
265
265
}
266
266
```
267
267
268
+
**Tagging constructor fields as raw JSON:**
269
+
270
+
TypeScript class:
271
+
```typescript
272
+
exportclassMyActor {
273
+
/**
274
+
* @parammyValue - Values will be passed as parsed JSON @range {json}
275
+
* @paramignoredArg - @ignored
276
+
*/
277
+
constructor(myValue:any, ignoredArg:string) {
278
+
279
+
}
280
+
}
281
+
```
282
+
283
+
Component file:
284
+
```json
285
+
{
286
+
"components": [
287
+
{
288
+
"parameters": [
289
+
{
290
+
"@id": "my-actor#TestClass#myValue",
291
+
"range": "rdf:JSON",
292
+
"required": false,
293
+
"unique": false,
294
+
"comment": "Values will be passed as parsed JSON"
295
+
}
296
+
],
297
+
"constructorArguments": [
298
+
{
299
+
"@id": "my-actor#TestClass#myValue"
300
+
}
301
+
]
302
+
}
303
+
]
304
+
}
305
+
```
306
+
307
+
When instantiating TestClass as follows, its JSON value will be passed directly into the constructor:
0 commit comments