简体   繁体   English

如何在 ASP.net Core 2.1 中生成动态 API

[英]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:我需要知道如何动态生成 API,让我们假设我们在 XML 文件中有它们的定义,如下所示:

<?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.现在需要做的是阅读上面的内容并从中生成列出的 API。 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}那么我们将生成 API,并且可以像这样从它们的 URL 调用它们 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你在 .yaml 中定义你的 API,它甚至有一个 api-generator-api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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