Docs@skmtc/core

Models

FUNCTION

toModelGeneratorKey

@skmtc/core 0.63.4

Creates a model generator key from generator ID, schema reference name, and variant.

Model generator keys uniquely identify generators processing specific OpenAPI schema models for a given variant. The key format is: generatorId|modelKey|variant: a component's refName, or the whole pointer of any other target, with % and | escaped.

Signature

import { toModelGeneratorKey } from '@skmtc/core'

toModelGeneratorKey(args: ToModelGeneratorKeyArgs): ModelGeneratorKey

Parameters

args, ToModelGeneratorKeyArgs required

Model generator key arguments

generatorId, string required

Unique identifier for the generator

ref, RefParts required

The model's ref. A component's key holds its refName; any other target's key holds its whole pointer (toModelKey), so two targets that share a refName get two keys.

variant, string

Model variant name - omitted means 'main'

Example
const key = toModelGeneratorKey({
  generatorId: 'typescript-interfaces',
  ref: { refName: 'User', refPath: '#/components/schemas' },
  variant: 'main'
});
// Result: 'typescript-interfaces|User|main' (branded)

const coercive = toModelGeneratorKey({
  generatorId: 'zod-schemas',
  ref: { refName: 'CreateUserRequest', refPath: '#/components/schemas' },
  variant: 'coercive'
});
// Result: 'zod-schemas|CreateUserRequest|coercive' (branded)

Returns

ModelGeneratorKey

A branded ModelGeneratorKey