Skip to content

nelsonlpco/createmockbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cod cov

createmockbuilder

Command line tool to convert json files to typescript/javascript mockBuilder classes.


basic usage:

createmockbuilder -f=./author.json -o=./outputdir
Params
flag value action
-f ./sample.json path to input json file
-o ./output path to output class files, default ./
-t js / ts template, default ts

Example

input: author.json

{
	"name": "Nelson Oliveira",
	"active": true,
	"contact": {
		"email": "[email protected]"
	}
}

output: AuthorBuilder.ts

class AuthorBuilder {
	Name: string;
	Active: boolean;
	Contact: any;

	constructor() { 
		Name = "";
		Active = false;
		Contact = {};
	}

	withName(value: string) { 
		this.Name = value;
		return this;
	}

	withActive(value: boolean) { 
		this.Active = valuel;
		return this;
	}

	withContact(value: any) { 
		this.Contact = value;
		return this;
	}

	withDefaultValues() {
		this.Name = "Nelson Oliveira";
		this.Active = true;
		this.Contact = {};
	}

	build() { 
		return { 
			name: this.Name,
			active: this.active,
			contact: this.Contact,
		}
	}
}

class ContactBuilder { 
	Email: string;

	constructor() { 
		this.Email = "";
	}

	withEmail(value: string) { 
		this.Email = value;
		return this;
	}

	withDefaultValues() { 
		this.Email = "[email protected]";

		return this;
	}

	build() { 
		return { 
			email: this.Email,
		}
	}
}

About

ferramenta para gerar builders js/ts a partir de arquivos JSON

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages