nimgent/structured_output/jsonschema_derive
This page is generated from the module’s exported API and ## documentation comments.
Compile-time derivation of JSON Schema from Nim types.Optional field annotations understood by jsonSchema. They are declared
as pragmas so they can be used directly on object fields without generating
runtime code.
Templates
Section titled “Templates”jsonDescription
Section titled “jsonDescription”Add a JSON Schema description.
template jsonDescription(value: static[string]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[string] |
jsonMinimum
Section titled “jsonMinimum”Set a numeric minimum.
template jsonMinimum(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonMaximum
Section titled “jsonMaximum”Set a numeric maximum.
template jsonMaximum(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonMinLength
Section titled “jsonMinLength”Set a string minimum length.
template jsonMinLength(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonMaxLength
Section titled “jsonMaxLength”Set a string maximum length.
template jsonMaxLength(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonMinItems
Section titled “jsonMinItems”Set an array minimum length.
template jsonMinItems(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonMaxItems
Section titled “jsonMaxItems”Set an array maximum length.
template jsonMaxItems(value: static[int]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[int] |
jsonPattern
Section titled “jsonPattern”Set a string pattern.
template jsonPattern(value: static[string]) {.pragma.}Type parameters: value:type.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
static[string] |
jsonOptional
Section titled “jsonOptional”Mark an object field as optional.
template jsonOptional() {.pragma.}Procedures
Section titled “Procedures”schemaName
Section titled “schemaName”OpenAI structured-output names: at most 64 [a-zA-Z0-9_-] characters.
proc schemaName(s: string): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
Macros
Section titled “Macros”jsonSchema
Section titled “jsonSchema”JSON Schema for Nim objects, variants, containers, generics, enums, and
primitives. Field pragmas add constraints or make a property optional.
Option fields stay in required as [T, null] (OpenAI strict).
macro jsonSchema(T: typedesc): JsonNodeType parameters: T:type.
Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
T |
typedesc |