简体   繁体   中英

How to generate dynamic API's in ASP.net Core 2.1

I need to know how to generate API's dynamically, let's we assume that we have their definitions in an XML file, like the below:

<?xml version="1.0" encoding="UTF-8" ?>
<APIS>
 <API>
  <APIName>getCategories</APIName>
  <APIinputs>
   <categoryName>Politics</categoryName>
   <categoryID>1150</categoryID>
  </APIinputs>
 </API>

 <API>
  <APIName>getEmployees</APIName>
  <APIinputs>
   <DepartmentName>HR</DepartmentName>
   <DepartmentID>1150</DepartmentID>
  </APIinputs>
 </API>


</APIS>

Now what needs to be done, is to to read the above and generate from it the listed API's. So then we would have the APIs generated and they can be called from their URLs like this www.example.com/api/v1/controller/getCategories/{categoryName}/{categoryID}

Can you please provide me some insight of this.

I think you are looking for something like this .

It has generators for servers as well as for clients, link

You define your API in .yaml and it even has an api-generator-api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM