Skip to content
/ py2ng Public

Convert Marshmallow schemas to TypeScript interfaces

Notifications You must be signed in to change notification settings

apryor6/py2ng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Py2ng

Converts a Marshmallow Schema to TypeScript interface

Usage

First, pip install py2ng

Then

py2ng path/to/file/with/schema.py

This will print out the converted interface. If you want the outputted keys to be in lowerCamelCase, pass the --camel-case flag

py2ng path/to/file/with/schema.py --camel-case

Example output

py2ng app/api/doodads/widget.py --camel-case

Where app/api/doodads/widget.py contains

class WidgetSchema(ma.Schema):
    an_int = ma.fields.Integer()
    a_float = ma.fields.Float()
    a_str = ma.fields.String(256)

Results in

export interface WidgetInterface {
    anInt: number,
    aFloat: number,
    aStr: string,
}
    

About

Convert Marshmallow schemas to TypeScript interfaces

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages