- Notifications
You must be signed in to change notification settings - Fork2
A code generator for Runtypes types. Perfect to create tooling to generate code for Runtypes!
License
NotificationsYou must be signed in to change notification settings
simenandre/generate-runtypes
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This library aims to provide an intuitive and easy way to generateRuntypes types. This package aims to be a great utility for aconversion package (e.g. JSON Schema to Runtypes).
We are thankful for all help with adding new functionality, fixing issues, orimprove the package. Feel free to open issues and pull requests ❤️
Apart from this README, you can find details and examples of using the SDK inthe following places:
import{generateRuntypes}from'generate-runtypes';constsourceCode=generateRuntypes([{name:'Comment',type:{kind:'record',fields:[{name:'author',type:{kind:'string'}},{name:'body',type:{kind:'string'}},{name:'timestamp',type:{kind:'number'}},],},},{name:'Post',export:true,type:{kind:'record',fields:[{name:'title',type:{kind:'string'}},{name:'body',type:{kind:'string'}},{name:'author',type:{kind:'string'}},{name:'comments',type:{kind:'array',type:{kind:'named',name:'Comment'}},},],},},]);
The generated code looks like this after formatting:
import*asrtfrom'runtypes';constComment=rt.Record({author:rt.String,body:rt.String,timestamp:rt.Number,});exportconstPost=rt.Record({title:rt.String,body:rt.String,author:rt.String,comments:rt.Array(Comment),});
About
A code generator for Runtypes types. Perfect to create tooling to generate code for Runtypes!
Topics
Resources
License
Code of conduct
Stars
Watchers
Forks
Packages0
No packages published