Reputation: 25158
We are developing a Web API RESTful service in C# and UI in React + Typescript.
After I renamed/add/remove some proeprties in C# REstAPI models the web UI stopped to work, because I forgot to rename it in UI.
Futhermore it is for me almost impossible to find all usage of API calls of such objects.
I would like to configure strongly typed, compiled time checked system that typescript object will be mapped somehow to C# object and compiler will check it.
I can image that I (programmer) would mark javascript/typescript object with some metadata (C# namespace and class name).
How can I do that.
Upvotes: 0
Views: 64
Reputation: 445
The key to resolving this issue is to abstract out a level to a configurable multi-language definition. From that definition you will be able generate both c# and typescript object definitions. The two major type descriptive options are Protos , and OpenApi from Google/Microsoft respectively.
This allows your workflow to become:
This ensures the object definitions are always in sync as the C# and Typescript libraries can depend directly on the auto-generated code.
Upvotes: 1