{"record":{"id":"5634bbbaf366e9e1","repo":"can1357/oh-my-pi","slug":"jsonschema-target-options-target-is-not-suppo","errorCode":null,"errorMessage":"JSONSchema target '${options.target}' is not supported (must be \"draft-2020-12\" or \"draft-07\")","messagePattern":"JSONSchema target '(.+?)' is not supported \\(must be \"draft-2020-12\" or \"draft-07\"\\)","errorType":"exception","errorClass":"OmpTypeError","httpStatus":null,"severity":"error","filePath":"packages/omptype/src/type.ts","lineNumber":1066,"sourceCode":"\nObject.defineProperty(typeMethods, \"json\", {\n\tget(this: InternalType): unknown {\n\t\treturn arkJsonOf(this.ir);\n\t},\n});\n\nObject.defineProperty(typeMethods, \"props\", {\n\tget(this: InternalType): readonly TypeProperty[] {\n\t\tconst object = requireObject(this.ir, \"props\");\n\t\treturn object.props.map(prop => propertyFromIR(prop));\n\t},\n});\n\nObject.defineProperty(typeMethods, \"~standard\", {\n\tget(this: InternalType): StandardSchemaV1.Props {\n\t\tconst jsonSchema = (io: \"input\" | \"output\", options: StandardJsonSchemaOptions) => {\n\t\t\tif (options.target !== \"draft-2020-12\" && options.target !== \"draft-07\") {\n\t\t\t\tthrow new OmpTypeError(\n\t\t\t\t\t`JSONSchema target '${options.target}' is not supported (must be \"draft-2020-12\" or \"draft-07\")`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.toJsonSchema({ ...options.libraryOptions, target: options.target, io });\n\t\t};\n\t\treturn {\n\t\t\tversion: 1,\n\t\t\tvendor: \"omptype\",\n\t\t\tvalidate: (value: unknown): StandardSchemaV1.Result<unknown> => {\n\t\t\t\tconst out = this.run(value);\n\t\t\t\treturn out instanceof OmpErrors\n\t\t\t\t\t? { issues: out as unknown as readonly StandardSchemaV1.Issue[] }\n\t\t\t\t\t: { value: out };\n\t\t\t},\n\t\t\tjsonSchema: {\n\t\t\t\tinput: options => jsonSchema(\"input\", options),\n\t\t\t\toutput: options => jsonSchema(\"output\", options),\n\t\t\t},","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/omptype/src/type.ts#L1048-L1084","documentation":"The Standard Schema `~standard` JSON-Schema adapter only supports JSON Schema targets \"draft-2020-12\" and \"draft-07\". Passing any other `target` in `StandardJsonSchemaOptions` throws an OmpTypeError listing the accepted values.","triggerScenarios":"Calling the standard-schema JSON Schema accessor with `target: \"draft-04\"`, `\"openapi-3.0\"`, or an undefined/misspelled target; frameworks that request a legacy dialect by default.","commonSituations":"Integrating with tooling that assumes draft-04 or OpenAPI dialects; copy-pasting options from another schema library that accepts more targets; forgetting to set `target` at all.","solutions":["Set `target: \"draft-2020-12\"` (preferred) in the options object.","Use `target: \"draft-07\"` if downstream tooling requires it.","For OpenAPI or other dialects, generate draft-2020-12 and convert with a separate converter."],"exampleFix":"// before\nstandard.jsonSchema({ io: 'output', target: 'openapi-3.0' }); // throws\n\n// after\nstandard.jsonSchema({ io: 'output', target: 'draft-2020-12' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['draft-2020-12', 'draft-07']);\nif (!SUPPORTED.has(options.target)) {\n  options = { ...options, target: 'draft-2020-12' };\n}\nstandard.jsonSchema({ io, ...options });","typeGuard":"function isSupportedTarget(t) {\n  return t === 'draft-2020-12' || t === 'draft-07';\n}","tryCatchPattern":"try {\n  const js = standard.jsonSchema({ io: 'output', target: opts.target });\n} catch (e) {\n  if (e instanceof OmpTypeError && e.message.includes('not supported')) {\n    const js = standard.jsonSchema({ io: 'output', target: 'draft-2020-12' });\n  } else throw e;\n}","preventionTips":["Default to draft-2020-12 and convert downstream for other dialects.","Type the target field as a union literal so invalid targets fail at compile time.","Check library docs before passing targets from external frameworks."],"tags":["json-schema","standard-schema","unsupported-target"],"backgroundTag":"unsupported-schema-dialect","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}