Skip to content

Data types

Specify that the provided template argument should be emitted as raw JSON or YAML as opposed to a schema. Use in combination with the @extension decorator. For example, @extension("x-schema", { x: "value" }) will emit a JSON schema value for x-schema, whereas @extension("x-schema", Json<{x: "value"}>) will emit the raw JSON code {x: "value"}.

model TypeSpec.JsonSchema.Json<Data>
NameDescription
Datathe type to convert to raw JSON
NameTypeDescription
valueDataThe value to emit as raw JSON or YAML.

Well-known JSON Schema formats.

enum TypeSpec.JsonSchema.Format
NameValueDescription
dateTime"date-time"A date and time, as defined by the date-time production in RFC 3339.
date"date"A calendar date, as defined by the full-date production in RFC 3339.
time"time"A time of day, as defined by the full-time production in RFC 3339.
duration"duration"An ISO 8601 duration such as P3DT4H5M, as defined by the duration production in RFC 3339, appendix A.
email"email"An email address, as defined by the addr-spec production in RFC 5322.
idnEmail"idn-email"An internationalized email address, as defined by RFC 6531.
hostname"hostname"A host name, as defined by RFC 1123.
idnHostname"idn-hostname"An internationalized host name, as defined by RFC 5890.
ipv4"ipv4"An IPv4 address, as defined by the dotted-quad production in RFC 2673.
ipv6"ipv6"An IPv6 address, as defined by RFC 4291.
uri"uri"A URI, as defined by RFC 3986.
uriReference"uri-reference"A URI reference, which may be relative, as defined by RFC 3986.
iri"iri"An internationalized resource identifier, as defined by RFC 3987.
iriReference"iri-reference"An internationalized resource identifier reference, which may be relative, as defined by RFC 3987.
uuid"uuid"A universally unique identifier, as defined by RFC 4122.
jsonPointer"json-pointer"A JSON pointer, as defined by RFC 6901.
relativeJsonPointer"relative-json-pointer"A relative JSON pointer, as defined by the relative JSON pointer draft.
regex"regex"A regular expression, as defined by ECMA-262.