Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vforteli/dotnet-typescript-model-generator
Generate typescript models from dotnet
https://github.com/vforteli/dotnet-typescript-model-generator
codegen dotnet typescript
Last synced: about 13 hours ago
JSON representation
Generate typescript models from dotnet
- Host: GitHub
- URL: https://github.com/vforteli/dotnet-typescript-model-generator
- Owner: vforteli
- License: mit
- Created: 2024-11-06T14:45:01.000Z (12 days ago)
- Default Branch: main
- Last Pushed: 2024-11-13T20:24:21.000Z (5 days ago)
- Last Synced: 2024-11-13T21:26:49.169Z (5 days ago)
- Topics: codegen, dotnet, typescript
- Language: C#
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TypeScriptModelGenerator
Generate TypeScript types from dotnet models.
This thing probably wont work with all possible types, but for now covers most use cases.## Usage
```csharp
// From a type
var types = new Dictionary();
var typeName = TypeScriptModelGenerator.ParseTypeRecursively(typeof(SomeType), types, false);// From method parameters using ParameterInfo
var types = new Dictionary();
var type = TypeScriptModelGenerator.ParseParameterInfo(someParameterInfo, types);// types will contain a dictionary of all the recognized TypeScript type names and their respective definition
```See tests for more examples of output
Note that it is not possible to determine if a generic parameter is nullable through reflection.
Therefore cases such as Task cannot be detected.Nullability of reference types can be determined when used in method parameters or properties.
## todo
- consider namespaces when processing types
- more types