in src/jsii2schema.ts [333:377]
function schemaForEnumLikeClass(type: jsiiReflect.Type | undefined, ctx: SchemaContext) {
if (type) {
ctx = ctx.child('enum-like', type.toString());
}
if (!type || !(type instanceof jsiiReflect.ClassType)) {
return undefined;
}
const enumLikeProps = enumLikeClassProperties(type);
const enumLikeMethods = enumLikeClassMethods(type);
if (enumLikeProps.length === 0 && enumLikeMethods.length === 0) {
return undefined;
}
const anyOf = new Array<any>();
if (enumLikeProps.length > 0) {
anyOf.push({ enum: enumLikeProps.map(m => m.name) });
}
for (const method of enumLikeMethods) {
const s = methodSchema(method, ctx);
if (!s) {
continue;
}
anyOf.push({
type: 'object',
additionalProperties: false,
properties: {
[method.name]: methodSchema(method, ctx),
},
});
}
if (anyOf.length === 0) {
return undefined;
}
return ctx.define(type.fqn, () => {
return { anyOf };
});
}