can1357/oh-my-pi · error · OmpTypeError
JSONSchema target '${options.target}' is not supported (must
Error message
JSONSchema target '${options.target}' is not supported (must be "draft-2020-12" or "draft-07") What it means
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.
Source
Thrown at packages/omptype/src/type.ts:1066
Object.defineProperty(typeMethods, "json", {
get(this: InternalType): unknown {
return arkJsonOf(this.ir);
},
});
Object.defineProperty(typeMethods, "props", {
get(this: InternalType): readonly TypeProperty[] {
const object = requireObject(this.ir, "props");
return object.props.map(prop => propertyFromIR(prop));
},
});
Object.defineProperty(typeMethods, "~standard", {
get(this: InternalType): StandardSchemaV1.Props {
const jsonSchema = (io: "input" | "output", options: StandardJsonSchemaOptions) => {
if (options.target !== "draft-2020-12" && options.target !== "draft-07") {
throw new OmpTypeError(
`JSONSchema target '${options.target}' is not supported (must be "draft-2020-12" or "draft-07")`,
);
}
return this.toJsonSchema({ ...options.libraryOptions, target: options.target, io });
};
return {
version: 1,
vendor: "omptype",
validate: (value: unknown): StandardSchemaV1.Result<unknown> => {
const out = this.run(value);
return out instanceof OmpErrors
? { issues: out as unknown as readonly StandardSchemaV1.Issue[] }
: { value: out };
},
jsonSchema: {
input: options => jsonSchema("input", options),
output: options => jsonSchema("output", options),
},View on GitHub (pinned to 9690622007)
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.
Example fix
// before
standard.jsonSchema({ io: 'output', target: 'openapi-3.0' }); // throws
// after
standard.jsonSchema({ io: 'output', target: 'draft-2020-12' }); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = new Set(['draft-2020-12', 'draft-07']);
if (!SUPPORTED.has(options.target)) {
options = { ...options, target: 'draft-2020-12' };
}
standard.jsonSchema({ io, ...options }); Type guard
function isSupportedTarget(t) {
return t === 'draft-2020-12' || t === 'draft-07';
} Try / catch
try {
const js = standard.jsonSchema({ io: 'output', target: opts.target });
} catch (e) {
if (e instanceof OmpTypeError && e.message.includes('not supported')) {
const js = standard.jsonSchema({ io: 'output', target: 'draft-2020-12' });
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Schema contains a circular object graph — cannot enforce str
- Schema node has no type, combinator, or $ref — cannot enforc
- Host tool "${name}" must provide a JSON Schema object
- Invalid ${scope} output schema: ${error}
- schema contains unresolved $ref after dereferencing
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/5634bbbaf366e9e1.
Report an issue: GitHub.