Pocoglot - Typescript
Pocoglot is a simple command line application that takes an entity definition file and generates code in one of many supported languages. If you are writing multi-tier applications in multiple languages this tool can save you from a lot of repeated typing and out-of-sync models.
Create definition file document.yaml
:
name: Document
props:
- name: user_id
type: integer
nullable: true
- name: visibility
type: string
default: "'private'"
- name: parent_id
type: integer
nullable: true
- name: parent_type
type: string
nullable: true
- name: content
type: string
nullable: true
- name: title
type: string
nullable: true
Invoke command to generate document.ts
:
$ pocoglot -from document.yaml -to document.ts -lang typescript
18:00:12.019 INFO Generating code in "typescript" from "document.yaml" to "document.ts"
18:00:12.025 INFO Done!
The file document.ts
now contains:
interface DocumentInterface {
user_id?: number;
visibility: string;
parent_id?: number;
parent_type?: string;
content?: string;
title?: string;
}
/**
* Autogenerated file, do not edit manually. @see https://github.com/reconmap/pocoglot-definitions
*/
const Document : DocumentInterface = {
visibility: 'private',
}
export default Document;