GithubHelp home page GithubHelp logo

jamesloyd / csharp-models-to-typescript Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svenheden/csharp-models-to-typescript

0.0 1.0 1.0 43 KB

C# models to TypeScript

JavaScript 44.89% C# 55.11%

csharp-models-to-typescript's Introduction

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.

For example

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

is translated into

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

export interface MyExample extends IExample {
    SomeValue: SomePropClass;
}

Dependencies

Install

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

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

csharp-models-to-typescript's People

Contributors

adnandervisevic avatar eriktoyra avatar jamesloyd avatar lacroixdavid1 avatar svenheden avatar

Watchers

 avatar

Forkers

atgfr8

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.