Skip to content

[F] resolveEncodedName

function resolveEncodedName(
program,
target,
mimeType): string

Resolve the encoded name for the given type when serialized to the given mime type. If a specific value was provided by @encodedName decorator for that mime type it will return that otherwise it will return the name of the type.

Parameters

ParameterType
programProgram
targetType & object
mimeTypestring

Returns

string

Example

For the given

model Certificate {
@encodedName("application/json", "exp")
@encodedName("application/xml", "expiry")
expireAt: utcDateTime;
}
resolveEncodedName(program, type, "application/json") // exp
resolveEncodedName(program, type, "application/merge-patch+json") // exp
resolveEncodedName(program, type, "application/xml") // expireAt
resolveEncodedName(program, type, "application/yaml") // expiry