I need to know how to create API's dynamically by calling another API then passing [API name]
and [API parameters]
, let's we assume that we have this API, like the one shown here:
[HttpPost("GenerateApi")]
[ProducesResponseType(200)]
[ProducesResponseType(500)]
public IActionResult GenerateApi(RootObject ro)
{
//Here I need piece of code to create API dynamically
return Ok(new { ro.apiName, ro.parameters });
}
Here are the models:
public class RootObject
{
public string apiName { get; set; }
public List<parameter> parameters { get; set; }
}
public class parameter
{
public string parameterName { get; set; }
public dynamic parameterType { get; set; }
}
Now what needs to be done, is to create dynamic API in controller.
So then we would have the API created they can be called from their URL like this
www.example.com/api/v1/[controller]/[apiName]/{[parameter1_value]}/{[parameter2_value]}
Can you please provide me some insight of this.