(FRONT) FRONT (2022)

Processing Backend result in Angular frontend as typed data

In order to receive similar code in Angular.



We need to prepare all interfaces of Backend API, unfortunately this is not simple task. Preparing input interfaces is simple task, we can only processing swagger specification Scaffolding Angular Client From Swagger.json, but this is not possible for output of BackendApi. Firstly Backend is usually has similar structure with one positive exit and a lot of negative exit, for example.



And not always result of negative exit fit to similar output.

And secondary, result can be build in sophisticated way of with anonymous function.



Bast possible way will to add something attribute to Backand API like <OutputSchema()>, based on JsonSchema. It this way we will receive all possible output data format in Swagger.Json and than will receive Angular interface as input for API. But unfortunately, no. There are nothing interface to pass JsonSchema to Swagger specification.

So, we have only one way - testing BackendApi, receive Backend result with various type and build Angular interface step by step, one API after another.



In order to do this, I have created assets for all my Backend API.



And I describe each API as Request and Parameters (automatically by my Swagger.Json parser), Response (manually as Fiddler result) and Angular Interface.



For converting Output Json to Interfaces I use perfect VS Code plugin https://marketplace.visualstudio.com/items?itemName=MariusAlchimavicius.json-to-ts.





Comments ( )
Link to this page: http://www.vb-net.com/AngularBackendResult/Index.htm
< THANKS ME>