ts-json-schema-generator
Version:
Generate JSON schema from your Typescript sources
22 lines (16 loc) • 459 B
text/typescript
import { BaseType } from "./BaseType.js";
export type LiteralValue = string | number | boolean;
export class LiteralType extends BaseType {
public constructor(private value: LiteralValue) {
super();
}
public getId(): string {
return JSON.stringify(this.value);
}
public getValue(): LiteralValue {
return this.value;
}
public isString(): boolean {
return typeof this.value === "string";
}
}