[T] ExtensionDecorator
Specify a custom property to add to the emitted schema. Useful for adding custom keywords
and other vendor-specific extensions. Scalar values need to be specified using typeof
to be converted to a schema.
For example, @extension("x-schema", typeof "foo")
will emit a JSON schema value for x-schema
,
whereas @extension("x-schema", "foo")
will emit the raw code "foo"
.
The value will be treated as a raw value if any of the following are true:
- The value is a scalar value (e.g. string, number, boolean, etc.)
- The value is wrapped in the
Json<Data>
template - The value is provided using the value syntax (e.g.
#{}
,#[]
)
For example, @extension("x-schema", { x: "value" })
will emit a JSON schema value for x-schema
,
whereas @extension("x-schema", #{x: "value"})
and @extension("x-schema", Json<{x: "value"}>)
will emit the raw JSON code {x: "value"}
.
Parameters
Parameter | Type | Description |
---|---|---|
context | DecoratorContext | - |
target | Type | - |
key | string | the name of the keyword of vendor extension, e.g. x-custom . |
value | Type | unknown | the value of the keyword. |
Returns
void