Git Product home page Git Product logo

createmockbuilder's Introduction

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,
		}
	}
}

createmockbuilder's People

Contributors

nelsonpradoobj avatar nelsonlpco avatar

Stargazers

Diego Augusto avatar Eduardo Azoia de Medeiros avatar Vagner Wentz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.