1.0.2 • Published 5 years ago

csharp-models-to-typescript-enhanced v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

C# models to TypeScript

This is a soft fork of Jonathan Persson's csharp-models-to-typescript npm package. The main difference is that we do auto import of dependent classes and interfaces in csharp classes. In order to facilitate this, you are required to append your types with "Model".

For example

public class MyExampleModel: IExample
{
    public SomePropClass SomeValue {get; set; }
}

is translated into

import {IExample} from "./IExample"
import { SomePropClass } from "./SomePropClass";

export interface MyExampleModel extends IExample {
    SomeValue: SomePropClass;
}

Dependencies

Install

$ npm install --save csharp-models-to-typescript-enhance

How to use

  1. Add a config file to your project that contains for example...
{
    "include": [
        "./models/**/*.cs",
        "./enums/**/*.cs"
    ],
    "exclude": [
        "./models/foo/bar.cs"
    ],
    "namespace": "Api",
    "output": "./models",
    "camelCase": false,
    "camelCaseEnums": false,
    "numericEnums": false,
    "stringLiteralTypesInsteadOfEnums": false,
    "customTypeTranslations": {
        "ProductName": "string",
        "ProductNumber": "string"
    }
}
  1. Add a npm script to your package.json that references your config file...
"scripts": {
    "generate-types": "csharp-models-to-typescript-enhanced --config=your-config-file.json"
},
  1. Run the npm script generate-types and the output file specified in your config should be created and populated with your models.

License

MIT © Jonathan Persson, Armstrong DevTeam

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.15.9

5 years ago

0.15.8

5 years ago

0.15.7

5 years ago

0.15.6

5 years ago

0.15.5

5 years ago

0.15.4

5 years ago

0.15.3

5 years ago

0.15.2

5 years ago

0.15.1

5 years ago

0.15.0

5 years ago