翼度科技»论坛 编程开发 .net 查看内容

学习Source Generators之从swagger中生成类

6

主题

6

帖子

18

积分

新手上路

Rank: 1

积分
18
前面学习了一些Source Generators的基础只是,接下来就来实践一下,用这个来生成我们所需要的代码。
本文将通过读取swagger.json的内容,解析并生成对应的请求响应类的代码。
创建项目

首先还是先创建两个项目,一个控制台程序,一个类库。

添加swagger文件

在控制台程序中添加Files目录,并把swagger文件放进去。别忘了还需要添加AdditionalFiles。
  1. <ItemGroup>
  2.   <AdditionalFiles Include="Files\swagger.json" />
  3. </ItemGroup>
复制代码

实现ClassFromSwaggerGenerator

安装依赖

由于我们需要解析swagger,所以需要安装一下JSON相关的包。这里我们安装了Newtonsoft.Json。
需要注意的是,依赖第三方包的时候需要在项目文件添加下面内容:
  1. <ItemGroup>
  2.   <AdditionalFiles Include="Files\swagger.json" />
  3. </ItemGroup>$(GetTargetPathDependsOn);GetDependencyTargetPaths<ItemGroup>
  4.   <AdditionalFiles Include="Files\swagger.json" />
  5. </ItemGroup><ItemGroup>
  6.   <AdditionalFiles Include="Files\swagger.json" />
  7. </ItemGroup><ItemGroup>
  8.   <AdditionalFiles Include="Files\swagger.json" />
  9. </ItemGroup><ItemGroup>
  10.   <AdditionalFiles Include="Files\swagger.json" />
  11. </ItemGroup>
复制代码
否则编译时会出现FileNotFound的异常。
构建管道

这里我们通过AdditionalTextsProvider筛选以及过滤我们的swagger文件。
  1. var pipeline = context.AdditionalTextsProvider.Select(static (text, cancellationToken) =><ItemGroup>
  2.   <AdditionalFiles Include="Files\swagger.json" />
  3. </ItemGroup>{<ItemGroup>
  4.   <AdditionalFiles Include="Files\swagger.json" />
  5. </ItemGroup><ItemGroup>
  6.   <AdditionalFiles Include="Files\swagger.json" />
  7. </ItemGroup><ItemGroup>
  8.   <AdditionalFiles Include="Files\swagger.json" />
  9. </ItemGroup>if (!text.Path.EndsWith("swagger.json", StringComparison.OrdinalIgnoreCase))<ItemGroup>
  10.   <AdditionalFiles Include="Files\swagger.json" />
  11. </ItemGroup><ItemGroup>
  12.   <AdditionalFiles Include="Files\swagger.json" />
  13. </ItemGroup><ItemGroup>
  14.   <AdditionalFiles Include="Files\swagger.json" />
  15. </ItemGroup>{<ItemGroup>
  16.   <AdditionalFiles Include="Files\swagger.json" />
  17. </ItemGroup><ItemGroup>
  18.   <AdditionalFiles Include="Files\swagger.json" />
  19. </ItemGroup><ItemGroup>
  20.   <AdditionalFiles Include="Files\swagger.json" />
  21. </ItemGroup><ItemGroup>
  22.   <AdditionalFiles Include="Files\swagger.json" />
  23. </ItemGroup><ItemGroup>
  24.   <AdditionalFiles Include="Files\swagger.json" />
  25. </ItemGroup>return default;<ItemGroup>
  26.   <AdditionalFiles Include="Files\swagger.json" />
  27. </ItemGroup><ItemGroup>
  28.   <AdditionalFiles Include="Files\swagger.json" />
  29. </ItemGroup><ItemGroup>
  30.   <AdditionalFiles Include="Files\swagger.json" />
  31. </ItemGroup>}<ItemGroup>
  32.   <AdditionalFiles Include="Files\swagger.json" />
  33. </ItemGroup><ItemGroup>
  34.   <AdditionalFiles Include="Files\swagger.json" />
  35. </ItemGroup><ItemGroup>
  36.   <AdditionalFiles Include="Files\swagger.json" />
  37. </ItemGroup>return JObject.Parse(text.GetText(cancellationToken)!.ToString());<ItemGroup>
  38.   <AdditionalFiles Include="Files\swagger.json" />
  39. </ItemGroup>})<ItemGroup>
  40.   <AdditionalFiles Include="Files\swagger.json" />
  41. </ItemGroup><ItemGroup>
  42.   <AdditionalFiles Include="Files\swagger.json" />
  43. </ItemGroup>.Where((pair) => pair is not null);
复制代码
实现生成代码逻辑

接下来我们就解析Swagger中的内容,并且动态拼接代码内容。主要代码部分如下:
  1. context.RegisterSourceOutput(pipeline, static (context, swagger) => {<ItemGroup>
  2.   <AdditionalFiles Include="Files\swagger.json" />
  3. </ItemGroup><ItemGroup>
  4.   <AdditionalFiles Include="Files\swagger.json" />
  5. </ItemGroup> List sources = new List();<ItemGroup>
  6.   <AdditionalFiles Include="Files\swagger.json" />
  7. </ItemGroup><ItemGroup>
  8.   <AdditionalFiles Include="Files\swagger.json" />
  9. </ItemGroup> #region 生成实体<ItemGroup>
  10.   <AdditionalFiles Include="Files\swagger.json" />
  11. </ItemGroup><ItemGroup>
  12.   <AdditionalFiles Include="Files\swagger.json" />
  13. </ItemGroup> var schemas = (JObject)swagger["components"]!["schemas"]!;<ItemGroup>
  14.   <AdditionalFiles Include="Files\swagger.json" />
  15. </ItemGroup><ItemGroup>
  16.   <AdditionalFiles Include="Files\swagger.json" />
  17. </ItemGroup> foreach (JProperty item in schemas.Properties())<ItemGroup>
  18.   <AdditionalFiles Include="Files\swagger.json" />
  19. </ItemGroup><ItemGroup>
  20.   <AdditionalFiles Include="Files\swagger.json" />
  21. </ItemGroup> {<ItemGroup>
  22.   <AdditionalFiles Include="Files\swagger.json" />
  23. </ItemGroup><ItemGroup>
  24.   <AdditionalFiles Include="Files\swagger.json" />
  25. </ItemGroup><ItemGroup>
  26.   <AdditionalFiles Include="Files\swagger.json" />
  27. </ItemGroup><ItemGroup>
  28.   <AdditionalFiles Include="Files\swagger.json" />
  29. </ItemGroup> if (item != null)<ItemGroup>
  30.   <AdditionalFiles Include="Files\swagger.json" />
  31. </ItemGroup><ItemGroup>
  32.   <AdditionalFiles Include="Files\swagger.json" />
  33. </ItemGroup><ItemGroup>
  34.   <AdditionalFiles Include="Files\swagger.json" />
  35. </ItemGroup><ItemGroup>
  36.   <AdditionalFiles Include="Files\swagger.json" />
  37. </ItemGroup> {<ItemGroup>
  38.   <AdditionalFiles Include="Files\swagger.json" />
  39. </ItemGroup><ItemGroup>
  40.   <AdditionalFiles Include="Files\swagger.json" />
  41. </ItemGroup><ItemGroup>
  42.   <AdditionalFiles Include="Files\swagger.json" />
  43. </ItemGroup><ItemGroup>
  44.   <AdditionalFiles Include="Files\swagger.json" />
  45. </ItemGroup><ItemGroup>
  46.   <AdditionalFiles Include="Files\swagger.json" />
  47. </ItemGroup><ItemGroup>
  48.   <AdditionalFiles Include="Files\swagger.json" />
  49. </ItemGroup> sources.Add((HandleClassName(item.Name), $@"#nullable enableusing System;using System.Collections.Generic;namespace SwaggerEntities;public {ClassOrEnum((JObject)item.Value)} {HandleClassName(item.Name)} {{<ItemGroup>
  50.   <AdditionalFiles Include="Files\swagger.json" />
  51. </ItemGroup><ItemGroup>
  52.   <AdditionalFiles Include="Files\swagger.json" />
  53. </ItemGroup>{BuildProperty((JObject)item.Value)}}}"));<ItemGroup>
  54.   <AdditionalFiles Include="Files\swagger.json" />
  55. </ItemGroup><ItemGroup>
  56.   <AdditionalFiles Include="Files\swagger.json" />
  57. </ItemGroup><ItemGroup>
  58.   <AdditionalFiles Include="Files\swagger.json" />
  59. </ItemGroup><ItemGroup>
  60.   <AdditionalFiles Include="Files\swagger.json" />
  61. </ItemGroup> }<ItemGroup>
  62.   <AdditionalFiles Include="Files\swagger.json" />
  63. </ItemGroup><ItemGroup>
  64.   <AdditionalFiles Include="Files\swagger.json" />
  65. </ItemGroup> }<ItemGroup>
  66.   <AdditionalFiles Include="Files\swagger.json" />
  67. </ItemGroup><ItemGroup>
  68.   <AdditionalFiles Include="Files\swagger.json" />
  69. </ItemGroup> foreach (var (name, sourceString) in sources)<ItemGroup>
  70.   <AdditionalFiles Include="Files\swagger.json" />
  71. </ItemGroup><ItemGroup>
  72.   <AdditionalFiles Include="Files\swagger.json" />
  73. </ItemGroup> {<ItemGroup>
  74.   <AdditionalFiles Include="Files\swagger.json" />
  75. </ItemGroup><ItemGroup>
  76.   <AdditionalFiles Include="Files\swagger.json" />
  77. </ItemGroup><ItemGroup>
  78.   <AdditionalFiles Include="Files\swagger.json" />
  79. </ItemGroup><ItemGroup>
  80.   <AdditionalFiles Include="Files\swagger.json" />
  81. </ItemGroup> var sourceText = SourceText.From(sourceString, Encoding.UTF8);<ItemGroup>
  82.   <AdditionalFiles Include="Files\swagger.json" />
  83. </ItemGroup><ItemGroup>
  84.   <AdditionalFiles Include="Files\swagger.json" />
  85. </ItemGroup><ItemGroup>
  86.   <AdditionalFiles Include="Files\swagger.json" />
  87. </ItemGroup><ItemGroup>
  88.   <AdditionalFiles Include="Files\swagger.json" />
  89. </ItemGroup> context.AddSource($"{name}.g.cs", sourceText);<ItemGroup>
  90.   <AdditionalFiles Include="Files\swagger.json" />
  91. </ItemGroup><ItemGroup>
  92.   <AdditionalFiles Include="Files\swagger.json" />
  93. </ItemGroup> }<ItemGroup>
  94.   <AdditionalFiles Include="Files\swagger.json" />
  95. </ItemGroup><ItemGroup>
  96.   <AdditionalFiles Include="Files\swagger.json" />
  97. </ItemGroup> #endregion<ItemGroup>
  98.   <AdditionalFiles Include="Files\swagger.json" />
  99. </ItemGroup><ItemGroup>
  100.   <AdditionalFiles Include="Files\swagger.json" />
  101. </ItemGroup> });
复制代码
完整的代码如下:
  1. using Microsoft.CodeAnalysis;using Microsoft.CodeAnalysis.Text;using Newtonsoft.Json;using Newtonsoft.Json.Linq;using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Text;namespace GenerateClassFromSwagger.Analysis{<ItemGroup>
  2.   <AdditionalFiles Include="Files\swagger.json" />
  3. </ItemGroup><ItemGroup>
  4.   <AdditionalFiles Include="Files\swagger.json" />
  5. </ItemGroup>[Generator]<ItemGroup>
  6.   <AdditionalFiles Include="Files\swagger.json" />
  7. </ItemGroup><ItemGroup>
  8.   <AdditionalFiles Include="Files\swagger.json" />
  9. </ItemGroup>public class ClassFromSwaggerGenerator : IIncrementalGenerator<ItemGroup>
  10.   <AdditionalFiles Include="Files\swagger.json" />
  11. </ItemGroup><ItemGroup>
  12.   <AdditionalFiles Include="Files\swagger.json" />
  13. </ItemGroup>{<ItemGroup>
  14.   <AdditionalFiles Include="Files\swagger.json" />
  15. </ItemGroup><ItemGroup>
  16.   <AdditionalFiles Include="Files\swagger.json" />
  17. </ItemGroup><ItemGroup>
  18.   <AdditionalFiles Include="Files\swagger.json" />
  19. </ItemGroup><ItemGroup>
  20.   <AdditionalFiles Include="Files\swagger.json" />
  21. </ItemGroup>public void Initialize(IncrementalGeneratorInitializationContext context)<ItemGroup>
  22.   <AdditionalFiles Include="Files\swagger.json" />
  23. </ItemGroup><ItemGroup>
  24.   <AdditionalFiles Include="Files\swagger.json" />
  25. </ItemGroup><ItemGroup>
  26.   <AdditionalFiles Include="Files\swagger.json" />
  27. </ItemGroup><ItemGroup>
  28.   <AdditionalFiles Include="Files\swagger.json" />
  29. </ItemGroup>{<ItemGroup>
  30.   <AdditionalFiles Include="Files\swagger.json" />
  31. </ItemGroup><ItemGroup>
  32.   <AdditionalFiles Include="Files\swagger.json" />
  33. </ItemGroup><ItemGroup>
  34.   <AdditionalFiles Include="Files\swagger.json" />
  35. </ItemGroup><ItemGroup>
  36.   <AdditionalFiles Include="Files\swagger.json" />
  37. </ItemGroup><ItemGroup>
  38.   <AdditionalFiles Include="Files\swagger.json" />
  39. </ItemGroup><ItemGroup>
  40.   <AdditionalFiles Include="Files\swagger.json" />
  41. </ItemGroup>var pipeline = context.AdditionalTextsProvider.Select(static (text, cancellationToken) =><ItemGroup>
  42.   <AdditionalFiles Include="Files\swagger.json" />
  43. </ItemGroup><ItemGroup>
  44.   <AdditionalFiles Include="Files\swagger.json" />
  45. </ItemGroup><ItemGroup>
  46.   <AdditionalFiles Include="Files\swagger.json" />
  47. </ItemGroup><ItemGroup>
  48.   <AdditionalFiles Include="Files\swagger.json" />
  49. </ItemGroup><ItemGroup>
  50.   <AdditionalFiles Include="Files\swagger.json" />
  51. </ItemGroup><ItemGroup>
  52.   <AdditionalFiles Include="Files\swagger.json" />
  53. </ItemGroup>{<ItemGroup>
  54.   <AdditionalFiles Include="Files\swagger.json" />
  55. </ItemGroup><ItemGroup>
  56.   <AdditionalFiles Include="Files\swagger.json" />
  57. </ItemGroup><ItemGroup>
  58.   <AdditionalFiles Include="Files\swagger.json" />
  59. </ItemGroup><ItemGroup>
  60.   <AdditionalFiles Include="Files\swagger.json" />
  61. </ItemGroup><ItemGroup>
  62.   <AdditionalFiles Include="Files\swagger.json" />
  63. </ItemGroup><ItemGroup>
  64.   <AdditionalFiles Include="Files\swagger.json" />
  65. </ItemGroup><ItemGroup>
  66.   <AdditionalFiles Include="Files\swagger.json" />
  67. </ItemGroup><ItemGroup>
  68.   <AdditionalFiles Include="Files\swagger.json" />
  69. </ItemGroup>if (!text.Path.EndsWith("swagger.json", StringComparison.OrdinalIgnoreCase))<ItemGroup>
  70.   <AdditionalFiles Include="Files\swagger.json" />
  71. </ItemGroup><ItemGroup>
  72.   <AdditionalFiles Include="Files\swagger.json" />
  73. </ItemGroup><ItemGroup>
  74.   <AdditionalFiles Include="Files\swagger.json" />
  75. </ItemGroup><ItemGroup>
  76.   <AdditionalFiles Include="Files\swagger.json" />
  77. </ItemGroup><ItemGroup>
  78.   <AdditionalFiles Include="Files\swagger.json" />
  79. </ItemGroup><ItemGroup>
  80.   <AdditionalFiles Include="Files\swagger.json" />
  81. </ItemGroup><ItemGroup>
  82.   <AdditionalFiles Include="Files\swagger.json" />
  83. </ItemGroup><ItemGroup>
  84.   <AdditionalFiles Include="Files\swagger.json" />
  85. </ItemGroup>{<ItemGroup>
  86.   <AdditionalFiles Include="Files\swagger.json" />
  87. </ItemGroup><ItemGroup>
  88.   <AdditionalFiles Include="Files\swagger.json" />
  89. </ItemGroup><ItemGroup>
  90.   <AdditionalFiles Include="Files\swagger.json" />
  91. </ItemGroup><ItemGroup>
  92.   <AdditionalFiles Include="Files\swagger.json" />
  93. </ItemGroup><ItemGroup>
  94.   <AdditionalFiles Include="Files\swagger.json" />
  95. </ItemGroup><ItemGroup>
  96.   <AdditionalFiles Include="Files\swagger.json" />
  97. </ItemGroup><ItemGroup>
  98.   <AdditionalFiles Include="Files\swagger.json" />
  99. </ItemGroup><ItemGroup>
  100.   <AdditionalFiles Include="Files\swagger.json" />
  101. </ItemGroup><ItemGroup>
  102.   <AdditionalFiles Include="Files\swagger.json" />
  103. </ItemGroup><ItemGroup>
  104.   <AdditionalFiles Include="Files\swagger.json" />
  105. </ItemGroup>return default;<ItemGroup>
  106.   <AdditionalFiles Include="Files\swagger.json" />
  107. </ItemGroup><ItemGroup>
  108.   <AdditionalFiles Include="Files\swagger.json" />
  109. </ItemGroup><ItemGroup>
  110.   <AdditionalFiles Include="Files\swagger.json" />
  111. </ItemGroup><ItemGroup>
  112.   <AdditionalFiles Include="Files\swagger.json" />
  113. </ItemGroup><ItemGroup>
  114.   <AdditionalFiles Include="Files\swagger.json" />
  115. </ItemGroup><ItemGroup>
  116.   <AdditionalFiles Include="Files\swagger.json" />
  117. </ItemGroup><ItemGroup>
  118.   <AdditionalFiles Include="Files\swagger.json" />
  119. </ItemGroup><ItemGroup>
  120.   <AdditionalFiles Include="Files\swagger.json" />
  121. </ItemGroup>}<ItemGroup>
  122.   <AdditionalFiles Include="Files\swagger.json" />
  123. </ItemGroup><ItemGroup>
  124.   <AdditionalFiles Include="Files\swagger.json" />
  125. </ItemGroup><ItemGroup>
  126.   <AdditionalFiles Include="Files\swagger.json" />
  127. </ItemGroup><ItemGroup>
  128.   <AdditionalFiles Include="Files\swagger.json" />
  129. </ItemGroup><ItemGroup>
  130.   <AdditionalFiles Include="Files\swagger.json" />
  131. </ItemGroup><ItemGroup>
  132.   <AdditionalFiles Include="Files\swagger.json" />
  133. </ItemGroup><ItemGroup>
  134.   <AdditionalFiles Include="Files\swagger.json" />
  135. </ItemGroup><ItemGroup>
  136.   <AdditionalFiles Include="Files\swagger.json" />
  137. </ItemGroup>return JObject.Parse(text.GetText(cancellationToken)!.ToString());<ItemGroup>
  138.   <AdditionalFiles Include="Files\swagger.json" />
  139. </ItemGroup><ItemGroup>
  140.   <AdditionalFiles Include="Files\swagger.json" />
  141. </ItemGroup><ItemGroup>
  142.   <AdditionalFiles Include="Files\swagger.json" />
  143. </ItemGroup><ItemGroup>
  144.   <AdditionalFiles Include="Files\swagger.json" />
  145. </ItemGroup><ItemGroup>
  146.   <AdditionalFiles Include="Files\swagger.json" />
  147. </ItemGroup><ItemGroup>
  148.   <AdditionalFiles Include="Files\swagger.json" />
  149. </ItemGroup>})<ItemGroup>
  150.   <AdditionalFiles Include="Files\swagger.json" />
  151. </ItemGroup><ItemGroup>
  152.   <AdditionalFiles Include="Files\swagger.json" />
  153. </ItemGroup><ItemGroup>
  154.   <AdditionalFiles Include="Files\swagger.json" />
  155. </ItemGroup><ItemGroup>
  156.   <AdditionalFiles Include="Files\swagger.json" />
  157. </ItemGroup><ItemGroup>
  158.   <AdditionalFiles Include="Files\swagger.json" />
  159. </ItemGroup><ItemGroup>
  160.   <AdditionalFiles Include="Files\swagger.json" />
  161. </ItemGroup>.Where((pair) => pair is not null);<ItemGroup>
  162.   <AdditionalFiles Include="Files\swagger.json" />
  163. </ItemGroup><ItemGroup>
  164.   <AdditionalFiles Include="Files\swagger.json" />
  165. </ItemGroup><ItemGroup>
  166.   <AdditionalFiles Include="Files\swagger.json" />
  167. </ItemGroup><ItemGroup>
  168.   <AdditionalFiles Include="Files\swagger.json" />
  169. </ItemGroup><ItemGroup>
  170.   <AdditionalFiles Include="Files\swagger.json" />
  171. </ItemGroup><ItemGroup>
  172.   <AdditionalFiles Include="Files\swagger.json" />
  173. </ItemGroup>context.RegisterSourceOutput(pipeline, static (context, swagger) =><ItemGroup>
  174.   <AdditionalFiles Include="Files\swagger.json" />
  175. </ItemGroup><ItemGroup>
  176.   <AdditionalFiles Include="Files\swagger.json" />
  177. </ItemGroup><ItemGroup>
  178.   <AdditionalFiles Include="Files\swagger.json" />
  179. </ItemGroup><ItemGroup>
  180.   <AdditionalFiles Include="Files\swagger.json" />
  181. </ItemGroup><ItemGroup>
  182.   <AdditionalFiles Include="Files\swagger.json" />
  183. </ItemGroup><ItemGroup>
  184.   <AdditionalFiles Include="Files\swagger.json" />
  185. </ItemGroup>{<ItemGroup>
  186.   <AdditionalFiles Include="Files\swagger.json" />
  187. </ItemGroup><ItemGroup>
  188.   <AdditionalFiles Include="Files\swagger.json" />
  189. </ItemGroup><ItemGroup>
  190.   <AdditionalFiles Include="Files\swagger.json" />
  191. </ItemGroup><ItemGroup>
  192.   <AdditionalFiles Include="Files\swagger.json" />
  193. </ItemGroup><ItemGroup>
  194.   <AdditionalFiles Include="Files\swagger.json" />
  195. </ItemGroup><ItemGroup>
  196.   <AdditionalFiles Include="Files\swagger.json" />
  197. </ItemGroup><ItemGroup>
  198.   <AdditionalFiles Include="Files\swagger.json" />
  199. </ItemGroup><ItemGroup>
  200.   <AdditionalFiles Include="Files\swagger.json" />
  201. </ItemGroup>List sources = new List();<ItemGroup>
  202.   <AdditionalFiles Include="Files\swagger.json" />
  203. </ItemGroup><ItemGroup>
  204.   <AdditionalFiles Include="Files\swagger.json" />
  205. </ItemGroup><ItemGroup>
  206.   <AdditionalFiles Include="Files\swagger.json" />
  207. </ItemGroup><ItemGroup>
  208.   <AdditionalFiles Include="Files\swagger.json" />
  209. </ItemGroup><ItemGroup>
  210.   <AdditionalFiles Include="Files\swagger.json" />
  211. </ItemGroup><ItemGroup>
  212.   <AdditionalFiles Include="Files\swagger.json" />
  213. </ItemGroup><ItemGroup>
  214.   <AdditionalFiles Include="Files\swagger.json" />
  215. </ItemGroup><ItemGroup>
  216.   <AdditionalFiles Include="Files\swagger.json" />
  217. </ItemGroup>#region 生成实体<ItemGroup>
  218.   <AdditionalFiles Include="Files\swagger.json" />
  219. </ItemGroup><ItemGroup>
  220.   <AdditionalFiles Include="Files\swagger.json" />
  221. </ItemGroup><ItemGroup>
  222.   <AdditionalFiles Include="Files\swagger.json" />
  223. </ItemGroup><ItemGroup>
  224.   <AdditionalFiles Include="Files\swagger.json" />
  225. </ItemGroup><ItemGroup>
  226.   <AdditionalFiles Include="Files\swagger.json" />
  227. </ItemGroup><ItemGroup>
  228.   <AdditionalFiles Include="Files\swagger.json" />
  229. </ItemGroup><ItemGroup>
  230.   <AdditionalFiles Include="Files\swagger.json" />
  231. </ItemGroup><ItemGroup>
  232.   <AdditionalFiles Include="Files\swagger.json" />
  233. </ItemGroup>var schemas = (JObject)swagger["components"]!["schemas"]!;<ItemGroup>
  234.   <AdditionalFiles Include="Files\swagger.json" />
  235. </ItemGroup><ItemGroup>
  236.   <AdditionalFiles Include="Files\swagger.json" />
  237. </ItemGroup><ItemGroup>
  238.   <AdditionalFiles Include="Files\swagger.json" />
  239. </ItemGroup><ItemGroup>
  240.   <AdditionalFiles Include="Files\swagger.json" />
  241. </ItemGroup><ItemGroup>
  242.   <AdditionalFiles Include="Files\swagger.json" />
  243. </ItemGroup><ItemGroup>
  244.   <AdditionalFiles Include="Files\swagger.json" />
  245. </ItemGroup><ItemGroup>
  246.   <AdditionalFiles Include="Files\swagger.json" />
  247. </ItemGroup><ItemGroup>
  248.   <AdditionalFiles Include="Files\swagger.json" />
  249. </ItemGroup>foreach (JProperty item in schemas.Properties())<ItemGroup>
  250.   <AdditionalFiles Include="Files\swagger.json" />
  251. </ItemGroup><ItemGroup>
  252.   <AdditionalFiles Include="Files\swagger.json" />
  253. </ItemGroup><ItemGroup>
  254.   <AdditionalFiles Include="Files\swagger.json" />
  255. </ItemGroup><ItemGroup>
  256.   <AdditionalFiles Include="Files\swagger.json" />
  257. </ItemGroup><ItemGroup>
  258.   <AdditionalFiles Include="Files\swagger.json" />
  259. </ItemGroup><ItemGroup>
  260.   <AdditionalFiles Include="Files\swagger.json" />
  261. </ItemGroup><ItemGroup>
  262.   <AdditionalFiles Include="Files\swagger.json" />
  263. </ItemGroup><ItemGroup>
  264.   <AdditionalFiles Include="Files\swagger.json" />
  265. </ItemGroup>{<ItemGroup>
  266.   <AdditionalFiles Include="Files\swagger.json" />
  267. </ItemGroup><ItemGroup>
  268.   <AdditionalFiles Include="Files\swagger.json" />
  269. </ItemGroup><ItemGroup>
  270.   <AdditionalFiles Include="Files\swagger.json" />
  271. </ItemGroup><ItemGroup>
  272.   <AdditionalFiles Include="Files\swagger.json" />
  273. </ItemGroup><ItemGroup>
  274.   <AdditionalFiles Include="Files\swagger.json" />
  275. </ItemGroup><ItemGroup>
  276.   <AdditionalFiles Include="Files\swagger.json" />
  277. </ItemGroup><ItemGroup>
  278.   <AdditionalFiles Include="Files\swagger.json" />
  279. </ItemGroup><ItemGroup>
  280.   <AdditionalFiles Include="Files\swagger.json" />
  281. </ItemGroup><ItemGroup>
  282.   <AdditionalFiles Include="Files\swagger.json" />
  283. </ItemGroup><ItemGroup>
  284.   <AdditionalFiles Include="Files\swagger.json" />
  285. </ItemGroup>if (item != null)<ItemGroup>
  286.   <AdditionalFiles Include="Files\swagger.json" />
  287. </ItemGroup><ItemGroup>
  288.   <AdditionalFiles Include="Files\swagger.json" />
  289. </ItemGroup><ItemGroup>
  290.   <AdditionalFiles Include="Files\swagger.json" />
  291. </ItemGroup><ItemGroup>
  292.   <AdditionalFiles Include="Files\swagger.json" />
  293. </ItemGroup><ItemGroup>
  294.   <AdditionalFiles Include="Files\swagger.json" />
  295. </ItemGroup><ItemGroup>
  296.   <AdditionalFiles Include="Files\swagger.json" />
  297. </ItemGroup><ItemGroup>
  298.   <AdditionalFiles Include="Files\swagger.json" />
  299. </ItemGroup><ItemGroup>
  300.   <AdditionalFiles Include="Files\swagger.json" />
  301. </ItemGroup><ItemGroup>
  302.   <AdditionalFiles Include="Files\swagger.json" />
  303. </ItemGroup><ItemGroup>
  304.   <AdditionalFiles Include="Files\swagger.json" />
  305. </ItemGroup>{<ItemGroup>
  306.   <AdditionalFiles Include="Files\swagger.json" />
  307. </ItemGroup><ItemGroup>
  308.   <AdditionalFiles Include="Files\swagger.json" />
  309. </ItemGroup><ItemGroup>
  310.   <AdditionalFiles Include="Files\swagger.json" />
  311. </ItemGroup><ItemGroup>
  312.   <AdditionalFiles Include="Files\swagger.json" />
  313. </ItemGroup><ItemGroup>
  314.   <AdditionalFiles Include="Files\swagger.json" />
  315. </ItemGroup><ItemGroup>
  316.   <AdditionalFiles Include="Files\swagger.json" />
  317. </ItemGroup><ItemGroup>
  318.   <AdditionalFiles Include="Files\swagger.json" />
  319. </ItemGroup><ItemGroup>
  320.   <AdditionalFiles Include="Files\swagger.json" />
  321. </ItemGroup><ItemGroup>
  322.   <AdditionalFiles Include="Files\swagger.json" />
  323. </ItemGroup><ItemGroup>
  324.   <AdditionalFiles Include="Files\swagger.json" />
  325. </ItemGroup><ItemGroup>
  326.   <AdditionalFiles Include="Files\swagger.json" />
  327. </ItemGroup><ItemGroup>
  328.   <AdditionalFiles Include="Files\swagger.json" />
  329. </ItemGroup>sources.Add((HandleClassName(item.Name), $@"#nullable enableusing System;using System.Collections.Generic;namespace SwaggerEntities;public {ClassOrEnum((JObject)item.Value)} {HandleClassName(item.Name)} {{<ItemGroup>
  330.   <AdditionalFiles Include="Files\swagger.json" />
  331. </ItemGroup><ItemGroup>
  332.   <AdditionalFiles Include="Files\swagger.json" />
  333. </ItemGroup>{BuildProperty((JObject)item.Value)}}}<ItemGroup>
  334.   <AdditionalFiles Include="Files\swagger.json" />
  335. </ItemGroup><ItemGroup>
  336.   <AdditionalFiles Include="Files\swagger.json" />
  337. </ItemGroup><ItemGroup>
  338.   <AdditionalFiles Include="Files\swagger.json" />
  339. </ItemGroup><ItemGroup>
  340.   <AdditionalFiles Include="Files\swagger.json" />
  341. </ItemGroup><ItemGroup>
  342.   <AdditionalFiles Include="Files\swagger.json" />
  343. </ItemGroup><ItemGroup>
  344.   <AdditionalFiles Include="Files\swagger.json" />
  345. </ItemGroup><ItemGroup>
  346.   <AdditionalFiles Include="Files\swagger.json" />
  347. </ItemGroup><ItemGroup>
  348.   <AdditionalFiles Include="Files\swagger.json" />
  349. </ItemGroup>"));<ItemGroup>
  350.   <AdditionalFiles Include="Files\swagger.json" />
  351. </ItemGroup><ItemGroup>
  352.   <AdditionalFiles Include="Files\swagger.json" />
  353. </ItemGroup><ItemGroup>
  354.   <AdditionalFiles Include="Files\swagger.json" />
  355. </ItemGroup><ItemGroup>
  356.   <AdditionalFiles Include="Files\swagger.json" />
  357. </ItemGroup><ItemGroup>
  358.   <AdditionalFiles Include="Files\swagger.json" />
  359. </ItemGroup><ItemGroup>
  360.   <AdditionalFiles Include="Files\swagger.json" />
  361. </ItemGroup><ItemGroup>
  362.   <AdditionalFiles Include="Files\swagger.json" />
  363. </ItemGroup><ItemGroup>
  364.   <AdditionalFiles Include="Files\swagger.json" />
  365. </ItemGroup><ItemGroup>
  366.   <AdditionalFiles Include="Files\swagger.json" />
  367. </ItemGroup><ItemGroup>
  368.   <AdditionalFiles Include="Files\swagger.json" />
  369. </ItemGroup>}<ItemGroup>
  370.   <AdditionalFiles Include="Files\swagger.json" />
  371. </ItemGroup><ItemGroup>
  372.   <AdditionalFiles Include="Files\swagger.json" />
  373. </ItemGroup><ItemGroup>
  374.   <AdditionalFiles Include="Files\swagger.json" />
  375. </ItemGroup><ItemGroup>
  376.   <AdditionalFiles Include="Files\swagger.json" />
  377. </ItemGroup><ItemGroup>
  378.   <AdditionalFiles Include="Files\swagger.json" />
  379. </ItemGroup><ItemGroup>
  380.   <AdditionalFiles Include="Files\swagger.json" />
  381. </ItemGroup><ItemGroup>
  382.   <AdditionalFiles Include="Files\swagger.json" />
  383. </ItemGroup><ItemGroup>
  384.   <AdditionalFiles Include="Files\swagger.json" />
  385. </ItemGroup>}<ItemGroup>
  386.   <AdditionalFiles Include="Files\swagger.json" />
  387. </ItemGroup><ItemGroup>
  388.   <AdditionalFiles Include="Files\swagger.json" />
  389. </ItemGroup><ItemGroup>
  390.   <AdditionalFiles Include="Files\swagger.json" />
  391. </ItemGroup><ItemGroup>
  392.   <AdditionalFiles Include="Files\swagger.json" />
  393. </ItemGroup><ItemGroup>
  394.   <AdditionalFiles Include="Files\swagger.json" />
  395. </ItemGroup><ItemGroup>
  396.   <AdditionalFiles Include="Files\swagger.json" />
  397. </ItemGroup><ItemGroup>
  398.   <AdditionalFiles Include="Files\swagger.json" />
  399. </ItemGroup><ItemGroup>
  400.   <AdditionalFiles Include="Files\swagger.json" />
  401. </ItemGroup>foreach (var (name, sourceString) in sources)<ItemGroup>
  402.   <AdditionalFiles Include="Files\swagger.json" />
  403. </ItemGroup><ItemGroup>
  404.   <AdditionalFiles Include="Files\swagger.json" />
  405. </ItemGroup><ItemGroup>
  406.   <AdditionalFiles Include="Files\swagger.json" />
  407. </ItemGroup><ItemGroup>
  408.   <AdditionalFiles Include="Files\swagger.json" />
  409. </ItemGroup><ItemGroup>
  410.   <AdditionalFiles Include="Files\swagger.json" />
  411. </ItemGroup><ItemGroup>
  412.   <AdditionalFiles Include="Files\swagger.json" />
  413. </ItemGroup><ItemGroup>
  414.   <AdditionalFiles Include="Files\swagger.json" />
  415. </ItemGroup><ItemGroup>
  416.   <AdditionalFiles Include="Files\swagger.json" />
  417. </ItemGroup>{<ItemGroup>
  418.   <AdditionalFiles Include="Files\swagger.json" />
  419. </ItemGroup><ItemGroup>
  420.   <AdditionalFiles Include="Files\swagger.json" />
  421. </ItemGroup><ItemGroup>
  422.   <AdditionalFiles Include="Files\swagger.json" />
  423. </ItemGroup><ItemGroup>
  424.   <AdditionalFiles Include="Files\swagger.json" />
  425. </ItemGroup><ItemGroup>
  426.   <AdditionalFiles Include="Files\swagger.json" />
  427. </ItemGroup><ItemGroup>
  428.   <AdditionalFiles Include="Files\swagger.json" />
  429. </ItemGroup><ItemGroup>
  430.   <AdditionalFiles Include="Files\swagger.json" />
  431. </ItemGroup><ItemGroup>
  432.   <AdditionalFiles Include="Files\swagger.json" />
  433. </ItemGroup><ItemGroup>
  434.   <AdditionalFiles Include="Files\swagger.json" />
  435. </ItemGroup><ItemGroup>
  436.   <AdditionalFiles Include="Files\swagger.json" />
  437. </ItemGroup>var sourceText = SourceText.From(sourceString, Encoding.UTF8);<ItemGroup>
  438.   <AdditionalFiles Include="Files\swagger.json" />
  439. </ItemGroup><ItemGroup>
  440.   <AdditionalFiles Include="Files\swagger.json" />
  441. </ItemGroup><ItemGroup>
  442.   <AdditionalFiles Include="Files\swagger.json" />
  443. </ItemGroup><ItemGroup>
  444.   <AdditionalFiles Include="Files\swagger.json" />
  445. </ItemGroup><ItemGroup>
  446.   <AdditionalFiles Include="Files\swagger.json" />
  447. </ItemGroup><ItemGroup>
  448.   <AdditionalFiles Include="Files\swagger.json" />
  449. </ItemGroup><ItemGroup>
  450.   <AdditionalFiles Include="Files\swagger.json" />
  451. </ItemGroup><ItemGroup>
  452.   <AdditionalFiles Include="Files\swagger.json" />
  453. </ItemGroup><ItemGroup>
  454.   <AdditionalFiles Include="Files\swagger.json" />
  455. </ItemGroup><ItemGroup>
  456.   <AdditionalFiles Include="Files\swagger.json" />
  457. </ItemGroup>context.AddSource($"{name}.g.cs", sourceText);<ItemGroup>
  458.   <AdditionalFiles Include="Files\swagger.json" />
  459. </ItemGroup><ItemGroup>
  460.   <AdditionalFiles Include="Files\swagger.json" />
  461. </ItemGroup><ItemGroup>
  462.   <AdditionalFiles Include="Files\swagger.json" />
  463. </ItemGroup><ItemGroup>
  464.   <AdditionalFiles Include="Files\swagger.json" />
  465. </ItemGroup><ItemGroup>
  466.   <AdditionalFiles Include="Files\swagger.json" />
  467. </ItemGroup><ItemGroup>
  468.   <AdditionalFiles Include="Files\swagger.json" />
  469. </ItemGroup><ItemGroup>
  470.   <AdditionalFiles Include="Files\swagger.json" />
  471. </ItemGroup><ItemGroup>
  472.   <AdditionalFiles Include="Files\swagger.json" />
  473. </ItemGroup>}<ItemGroup>
  474.   <AdditionalFiles Include="Files\swagger.json" />
  475. </ItemGroup><ItemGroup>
  476.   <AdditionalFiles Include="Files\swagger.json" />
  477. </ItemGroup><ItemGroup>
  478.   <AdditionalFiles Include="Files\swagger.json" />
  479. </ItemGroup><ItemGroup>
  480.   <AdditionalFiles Include="Files\swagger.json" />
  481. </ItemGroup><ItemGroup>
  482.   <AdditionalFiles Include="Files\swagger.json" />
  483. </ItemGroup><ItemGroup>
  484.   <AdditionalFiles Include="Files\swagger.json" />
  485. </ItemGroup><ItemGroup>
  486.   <AdditionalFiles Include="Files\swagger.json" />
  487. </ItemGroup><ItemGroup>
  488.   <AdditionalFiles Include="Files\swagger.json" />
  489. </ItemGroup>#endregion<ItemGroup>
  490.   <AdditionalFiles Include="Files\swagger.json" />
  491. </ItemGroup><ItemGroup>
  492.   <AdditionalFiles Include="Files\swagger.json" />
  493. </ItemGroup><ItemGroup>
  494.   <AdditionalFiles Include="Files\swagger.json" />
  495. </ItemGroup><ItemGroup>
  496.   <AdditionalFiles Include="Files\swagger.json" />
  497. </ItemGroup><ItemGroup>
  498.   <AdditionalFiles Include="Files\swagger.json" />
  499. </ItemGroup><ItemGroup>
  500.   <AdditionalFiles Include="Files\swagger.json" />
  501. </ItemGroup>});<ItemGroup>
  502.   <AdditionalFiles Include="Files\swagger.json" />
  503. </ItemGroup><ItemGroup>
  504.   <AdditionalFiles Include="Files\swagger.json" />
  505. </ItemGroup><ItemGroup>
  506.   <AdditionalFiles Include="Files\swagger.json" />
  507. </ItemGroup><ItemGroup>
  508.   <AdditionalFiles Include="Files\swagger.json" />
  509. </ItemGroup>}<ItemGroup>
  510.   <AdditionalFiles Include="Files\swagger.json" />
  511. </ItemGroup><ItemGroup>
  512.   <AdditionalFiles Include="Files\swagger.json" />
  513. </ItemGroup><ItemGroup>
  514.   <AdditionalFiles Include="Files\swagger.json" />
  515. </ItemGroup><ItemGroup>
  516.   <AdditionalFiles Include="Files\swagger.json" />
  517. </ItemGroup>static string HandleClassName(string name)<ItemGroup>
  518.   <AdditionalFiles Include="Files\swagger.json" />
  519. </ItemGroup><ItemGroup>
  520.   <AdditionalFiles Include="Files\swagger.json" />
  521. </ItemGroup><ItemGroup>
  522.   <AdditionalFiles Include="Files\swagger.json" />
  523. </ItemGroup><ItemGroup>
  524.   <AdditionalFiles Include="Files\swagger.json" />
  525. </ItemGroup>{<ItemGroup>
  526.   <AdditionalFiles Include="Files\swagger.json" />
  527. </ItemGroup><ItemGroup>
  528.   <AdditionalFiles Include="Files\swagger.json" />
  529. </ItemGroup><ItemGroup>
  530.   <AdditionalFiles Include="Files\swagger.json" />
  531. </ItemGroup><ItemGroup>
  532.   <AdditionalFiles Include="Files\swagger.json" />
  533. </ItemGroup><ItemGroup>
  534.   <AdditionalFiles Include="Files\swagger.json" />
  535. </ItemGroup><ItemGroup>
  536.   <AdditionalFiles Include="Files\swagger.json" />
  537. </ItemGroup>return name.Split('.').Last().Replace("", "").Replace(",", "");<ItemGroup>
  538.   <AdditionalFiles Include="Files\swagger.json" />
  539. </ItemGroup><ItemGroup>
  540.   <AdditionalFiles Include="Files\swagger.json" />
  541. </ItemGroup><ItemGroup>
  542.   <AdditionalFiles Include="Files\swagger.json" />
  543. </ItemGroup><ItemGroup>
  544.   <AdditionalFiles Include="Files\swagger.json" />
  545. </ItemGroup>}<ItemGroup>
  546.   <AdditionalFiles Include="Files\swagger.json" />
  547. </ItemGroup><ItemGroup>
  548.   <AdditionalFiles Include="Files\swagger.json" />
  549. </ItemGroup><ItemGroup>
  550.   <AdditionalFiles Include="Files\swagger.json" />
  551. </ItemGroup><ItemGroup>
  552.   <AdditionalFiles Include="Files\swagger.json" />
  553. </ItemGroup>static string ClassOrEnum(JObject value)<ItemGroup>
  554.   <AdditionalFiles Include="Files\swagger.json" />
  555. </ItemGroup><ItemGroup>
  556.   <AdditionalFiles Include="Files\swagger.json" />
  557. </ItemGroup><ItemGroup>
  558.   <AdditionalFiles Include="Files\swagger.json" />
  559. </ItemGroup><ItemGroup>
  560.   <AdditionalFiles Include="Files\swagger.json" />
  561. </ItemGroup>{<ItemGroup>
  562.   <AdditionalFiles Include="Files\swagger.json" />
  563. </ItemGroup><ItemGroup>
  564.   <AdditionalFiles Include="Files\swagger.json" />
  565. </ItemGroup><ItemGroup>
  566.   <AdditionalFiles Include="Files\swagger.json" />
  567. </ItemGroup><ItemGroup>
  568.   <AdditionalFiles Include="Files\swagger.json" />
  569. </ItemGroup><ItemGroup>
  570.   <AdditionalFiles Include="Files\swagger.json" />
  571. </ItemGroup><ItemGroup>
  572.   <AdditionalFiles Include="Files\swagger.json" />
  573. </ItemGroup>return value.ContainsKey("enum") ? "enum" : "partial class";<ItemGroup>
  574.   <AdditionalFiles Include="Files\swagger.json" />
  575. </ItemGroup><ItemGroup>
  576.   <AdditionalFiles Include="Files\swagger.json" />
  577. </ItemGroup><ItemGroup>
  578.   <AdditionalFiles Include="Files\swagger.json" />
  579. </ItemGroup><ItemGroup>
  580.   <AdditionalFiles Include="Files\swagger.json" />
  581. </ItemGroup>}<ItemGroup>
  582.   <AdditionalFiles Include="Files\swagger.json" />
  583. </ItemGroup><ItemGroup>
  584.   <AdditionalFiles Include="Files\swagger.json" />
  585. </ItemGroup><ItemGroup>
  586.   <AdditionalFiles Include="Files\swagger.json" />
  587. </ItemGroup><ItemGroup>
  588.   <AdditionalFiles Include="Files\swagger.json" />
  589. </ItemGroup>static string BuildProperty(JObject value)<ItemGroup>
  590.   <AdditionalFiles Include="Files\swagger.json" />
  591. </ItemGroup><ItemGroup>
  592.   <AdditionalFiles Include="Files\swagger.json" />
  593. </ItemGroup><ItemGroup>
  594.   <AdditionalFiles Include="Files\swagger.json" />
  595. </ItemGroup><ItemGroup>
  596.   <AdditionalFiles Include="Files\swagger.json" />
  597. </ItemGroup>{<ItemGroup>
  598.   <AdditionalFiles Include="Files\swagger.json" />
  599. </ItemGroup><ItemGroup>
  600.   <AdditionalFiles Include="Files\swagger.json" />
  601. </ItemGroup><ItemGroup>
  602.   <AdditionalFiles Include="Files\swagger.json" />
  603. </ItemGroup><ItemGroup>
  604.   <AdditionalFiles Include="Files\swagger.json" />
  605. </ItemGroup><ItemGroup>
  606.   <AdditionalFiles Include="Files\swagger.json" />
  607. </ItemGroup><ItemGroup>
  608.   <AdditionalFiles Include="Files\swagger.json" />
  609. </ItemGroup>var sb = new StringBuilder();<ItemGroup>
  610.   <AdditionalFiles Include="Files\swagger.json" />
  611. </ItemGroup><ItemGroup>
  612.   <AdditionalFiles Include="Files\swagger.json" />
  613. </ItemGroup><ItemGroup>
  614.   <AdditionalFiles Include="Files\swagger.json" />
  615. </ItemGroup><ItemGroup>
  616.   <AdditionalFiles Include="Files\swagger.json" />
  617. </ItemGroup><ItemGroup>
  618.   <AdditionalFiles Include="Files\swagger.json" />
  619. </ItemGroup><ItemGroup>
  620.   <AdditionalFiles Include="Files\swagger.json" />
  621. </ItemGroup>if (value.ContainsKey("properties"))<ItemGroup>
  622.   <AdditionalFiles Include="Files\swagger.json" />
  623. </ItemGroup><ItemGroup>
  624.   <AdditionalFiles Include="Files\swagger.json" />
  625. </ItemGroup><ItemGroup>
  626.   <AdditionalFiles Include="Files\swagger.json" />
  627. </ItemGroup><ItemGroup>
  628.   <AdditionalFiles Include="Files\swagger.json" />
  629. </ItemGroup><ItemGroup>
  630.   <AdditionalFiles Include="Files\swagger.json" />
  631. </ItemGroup><ItemGroup>
  632.   <AdditionalFiles Include="Files\swagger.json" />
  633. </ItemGroup>{<ItemGroup>
  634.   <AdditionalFiles Include="Files\swagger.json" />
  635. </ItemGroup><ItemGroup>
  636.   <AdditionalFiles Include="Files\swagger.json" />
  637. </ItemGroup><ItemGroup>
  638.   <AdditionalFiles Include="Files\swagger.json" />
  639. </ItemGroup><ItemGroup>
  640.   <AdditionalFiles Include="Files\swagger.json" />
  641. </ItemGroup><ItemGroup>
  642.   <AdditionalFiles Include="Files\swagger.json" />
  643. </ItemGroup><ItemGroup>
  644.   <AdditionalFiles Include="Files\swagger.json" />
  645. </ItemGroup><ItemGroup>
  646.   <AdditionalFiles Include="Files\swagger.json" />
  647. </ItemGroup><ItemGroup>
  648.   <AdditionalFiles Include="Files\swagger.json" />
  649. </ItemGroup>var propertys = (JObject)value["properties"]!;<ItemGroup>
  650.   <AdditionalFiles Include="Files\swagger.json" />
  651. </ItemGroup><ItemGroup>
  652.   <AdditionalFiles Include="Files\swagger.json" />
  653. </ItemGroup><ItemGroup>
  654.   <AdditionalFiles Include="Files\swagger.json" />
  655. </ItemGroup><ItemGroup>
  656.   <AdditionalFiles Include="Files\swagger.json" />
  657. </ItemGroup><ItemGroup>
  658.   <AdditionalFiles Include="Files\swagger.json" />
  659. </ItemGroup><ItemGroup>
  660.   <AdditionalFiles Include="Files\swagger.json" />
  661. </ItemGroup><ItemGroup>
  662.   <AdditionalFiles Include="Files\swagger.json" />
  663. </ItemGroup><ItemGroup>
  664.   <AdditionalFiles Include="Files\swagger.json" />
  665. </ItemGroup>foreach (JProperty item in propertys!.Properties())<ItemGroup>
  666.   <AdditionalFiles Include="Files\swagger.json" />
  667. </ItemGroup><ItemGroup>
  668.   <AdditionalFiles Include="Files\swagger.json" />
  669. </ItemGroup><ItemGroup>
  670.   <AdditionalFiles Include="Files\swagger.json" />
  671. </ItemGroup><ItemGroup>
  672.   <AdditionalFiles Include="Files\swagger.json" />
  673. </ItemGroup><ItemGroup>
  674.   <AdditionalFiles Include="Files\swagger.json" />
  675. </ItemGroup><ItemGroup>
  676.   <AdditionalFiles Include="Files\swagger.json" />
  677. </ItemGroup><ItemGroup>
  678.   <AdditionalFiles Include="Files\swagger.json" />
  679. </ItemGroup><ItemGroup>
  680.   <AdditionalFiles Include="Files\swagger.json" />
  681. </ItemGroup>{<ItemGroup>
  682.   <AdditionalFiles Include="Files\swagger.json" />
  683. </ItemGroup><ItemGroup>
  684.   <AdditionalFiles Include="Files\swagger.json" />
  685. </ItemGroup><ItemGroup>
  686.   <AdditionalFiles Include="Files\swagger.json" />
  687. </ItemGroup><ItemGroup>
  688.   <AdditionalFiles Include="Files\swagger.json" />
  689. </ItemGroup><ItemGroup>
  690.   <AdditionalFiles Include="Files\swagger.json" />
  691. </ItemGroup><ItemGroup>
  692.   <AdditionalFiles Include="Files\swagger.json" />
  693. </ItemGroup><ItemGroup>
  694.   <AdditionalFiles Include="Files\swagger.json" />
  695. </ItemGroup><ItemGroup>
  696.   <AdditionalFiles Include="Files\swagger.json" />
  697. </ItemGroup><ItemGroup>
  698.   <AdditionalFiles Include="Files\swagger.json" />
  699. </ItemGroup><ItemGroup>
  700.   <AdditionalFiles Include="Files\swagger.json" />
  701. </ItemGroup>sb.AppendLine($@"<ItemGroup>
  702.   <AdditionalFiles Include="Files\swagger.json" />
  703. </ItemGroup><ItemGroup>
  704.   <AdditionalFiles Include="Files\swagger.json" />
  705. </ItemGroup>public {BuildProertyType((JObject)item.Value)} {ToUpperFirst(item.Name)}<ItemGroup>
  706.   <AdditionalFiles Include="Files\swagger.json" />
  707. </ItemGroup>{{ get; set; }}");<ItemGroup>
  708.   <AdditionalFiles Include="Files\swagger.json" />
  709. </ItemGroup><ItemGroup>
  710.   <AdditionalFiles Include="Files\swagger.json" />
  711. </ItemGroup><ItemGroup>
  712.   <AdditionalFiles Include="Files\swagger.json" />
  713. </ItemGroup><ItemGroup>
  714.   <AdditionalFiles Include="Files\swagger.json" />
  715. </ItemGroup><ItemGroup>
  716.   <AdditionalFiles Include="Files\swagger.json" />
  717. </ItemGroup><ItemGroup>
  718.   <AdditionalFiles Include="Files\swagger.json" />
  719. </ItemGroup><ItemGroup>
  720.   <AdditionalFiles Include="Files\swagger.json" />
  721. </ItemGroup><ItemGroup>
  722.   <AdditionalFiles Include="Files\swagger.json" />
  723. </ItemGroup>}<ItemGroup>
  724.   <AdditionalFiles Include="Files\swagger.json" />
  725. </ItemGroup><ItemGroup>
  726.   <AdditionalFiles Include="Files\swagger.json" />
  727. </ItemGroup><ItemGroup>
  728.   <AdditionalFiles Include="Files\swagger.json" />
  729. </ItemGroup><ItemGroup>
  730.   <AdditionalFiles Include="Files\swagger.json" />
  731. </ItemGroup><ItemGroup>
  732.   <AdditionalFiles Include="Files\swagger.json" />
  733. </ItemGroup><ItemGroup>
  734.   <AdditionalFiles Include="Files\swagger.json" />
  735. </ItemGroup>}<ItemGroup>
  736.   <AdditionalFiles Include="Files\swagger.json" />
  737. </ItemGroup><ItemGroup>
  738.   <AdditionalFiles Include="Files\swagger.json" />
  739. </ItemGroup><ItemGroup>
  740.   <AdditionalFiles Include="Files\swagger.json" />
  741. </ItemGroup><ItemGroup>
  742.   <AdditionalFiles Include="Files\swagger.json" />
  743. </ItemGroup><ItemGroup>
  744.   <AdditionalFiles Include="Files\swagger.json" />
  745. </ItemGroup><ItemGroup>
  746.   <AdditionalFiles Include="Files\swagger.json" />
  747. </ItemGroup>if (value.ContainsKey("enum"))<ItemGroup>
  748.   <AdditionalFiles Include="Files\swagger.json" />
  749. </ItemGroup><ItemGroup>
  750.   <AdditionalFiles Include="Files\swagger.json" />
  751. </ItemGroup><ItemGroup>
  752.   <AdditionalFiles Include="Files\swagger.json" />
  753. </ItemGroup><ItemGroup>
  754.   <AdditionalFiles Include="Files\swagger.json" />
  755. </ItemGroup><ItemGroup>
  756.   <AdditionalFiles Include="Files\swagger.json" />
  757. </ItemGroup><ItemGroup>
  758.   <AdditionalFiles Include="Files\swagger.json" />
  759. </ItemGroup>{<ItemGroup>
  760.   <AdditionalFiles Include="Files\swagger.json" />
  761. </ItemGroup><ItemGroup>
  762.   <AdditionalFiles Include="Files\swagger.json" />
  763. </ItemGroup><ItemGroup>
  764.   <AdditionalFiles Include="Files\swagger.json" />
  765. </ItemGroup><ItemGroup>
  766.   <AdditionalFiles Include="Files\swagger.json" />
  767. </ItemGroup><ItemGroup>
  768.   <AdditionalFiles Include="Files\swagger.json" />
  769. </ItemGroup><ItemGroup>
  770.   <AdditionalFiles Include="Files\swagger.json" />
  771. </ItemGroup><ItemGroup>
  772.   <AdditionalFiles Include="Files\swagger.json" />
  773. </ItemGroup><ItemGroup>
  774.   <AdditionalFiles Include="Files\swagger.json" />
  775. </ItemGroup>foreach (var item in JsonConvert.DeserializeObject(value["enum"]!.ToString())!)<ItemGroup>
  776.   <AdditionalFiles Include="Files\swagger.json" />
  777. </ItemGroup><ItemGroup>
  778.   <AdditionalFiles Include="Files\swagger.json" />
  779. </ItemGroup><ItemGroup>
  780.   <AdditionalFiles Include="Files\swagger.json" />
  781. </ItemGroup><ItemGroup>
  782.   <AdditionalFiles Include="Files\swagger.json" />
  783. </ItemGroup><ItemGroup>
  784.   <AdditionalFiles Include="Files\swagger.json" />
  785. </ItemGroup><ItemGroup>
  786.   <AdditionalFiles Include="Files\swagger.json" />
  787. </ItemGroup><ItemGroup>
  788.   <AdditionalFiles Include="Files\swagger.json" />
  789. </ItemGroup><ItemGroup>
  790.   <AdditionalFiles Include="Files\swagger.json" />
  791. </ItemGroup>{<ItemGroup>
  792.   <AdditionalFiles Include="Files\swagger.json" />
  793. </ItemGroup><ItemGroup>
  794.   <AdditionalFiles Include="Files\swagger.json" />
  795. </ItemGroup><ItemGroup>
  796.   <AdditionalFiles Include="Files\swagger.json" />
  797. </ItemGroup><ItemGroup>
  798.   <AdditionalFiles Include="Files\swagger.json" />
  799. </ItemGroup><ItemGroup>
  800.   <AdditionalFiles Include="Files\swagger.json" />
  801. </ItemGroup><ItemGroup>
  802.   <AdditionalFiles Include="Files\swagger.json" />
  803. </ItemGroup><ItemGroup>
  804.   <AdditionalFiles Include="Files\swagger.json" />
  805. </ItemGroup><ItemGroup>
  806.   <AdditionalFiles Include="Files\swagger.json" />
  807. </ItemGroup><ItemGroup>
  808.   <AdditionalFiles Include="Files\swagger.json" />
  809. </ItemGroup><ItemGroup>
  810.   <AdditionalFiles Include="Files\swagger.json" />
  811. </ItemGroup>sb.Append($@"<ItemGroup>
  812.   <AdditionalFiles Include="Files\swagger.json" />
  813. </ItemGroup><ItemGroup>
  814.   <AdditionalFiles Include="Files\swagger.json" />
  815. </ItemGroup>_{item},");<ItemGroup>
  816.   <AdditionalFiles Include="Files\swagger.json" />
  817. </ItemGroup><ItemGroup>
  818.   <AdditionalFiles Include="Files\swagger.json" />
  819. </ItemGroup><ItemGroup>
  820.   <AdditionalFiles Include="Files\swagger.json" />
  821. </ItemGroup><ItemGroup>
  822.   <AdditionalFiles Include="Files\swagger.json" />
  823. </ItemGroup><ItemGroup>
  824.   <AdditionalFiles Include="Files\swagger.json" />
  825. </ItemGroup><ItemGroup>
  826.   <AdditionalFiles Include="Files\swagger.json" />
  827. </ItemGroup><ItemGroup>
  828.   <AdditionalFiles Include="Files\swagger.json" />
  829. </ItemGroup><ItemGroup>
  830.   <AdditionalFiles Include="Files\swagger.json" />
  831. </ItemGroup>}<ItemGroup>
  832.   <AdditionalFiles Include="Files\swagger.json" />
  833. </ItemGroup><ItemGroup>
  834.   <AdditionalFiles Include="Files\swagger.json" />
  835. </ItemGroup><ItemGroup>
  836.   <AdditionalFiles Include="Files\swagger.json" />
  837. </ItemGroup><ItemGroup>
  838.   <AdditionalFiles Include="Files\swagger.json" />
  839. </ItemGroup><ItemGroup>
  840.   <AdditionalFiles Include="Files\swagger.json" />
  841. </ItemGroup><ItemGroup>
  842.   <AdditionalFiles Include="Files\swagger.json" />
  843. </ItemGroup><ItemGroup>
  844.   <AdditionalFiles Include="Files\swagger.json" />
  845. </ItemGroup><ItemGroup>
  846.   <AdditionalFiles Include="Files\swagger.json" />
  847. </ItemGroup>sb.Remove(sb.Length - 1, 1);<ItemGroup>
  848.   <AdditionalFiles Include="Files\swagger.json" />
  849. </ItemGroup><ItemGroup>
  850.   <AdditionalFiles Include="Files\swagger.json" />
  851. </ItemGroup><ItemGroup>
  852.   <AdditionalFiles Include="Files\swagger.json" />
  853. </ItemGroup><ItemGroup>
  854.   <AdditionalFiles Include="Files\swagger.json" />
  855. </ItemGroup><ItemGroup>
  856.   <AdditionalFiles Include="Files\swagger.json" />
  857. </ItemGroup><ItemGroup>
  858.   <AdditionalFiles Include="Files\swagger.json" />
  859. </ItemGroup>}<ItemGroup>
  860.   <AdditionalFiles Include="Files\swagger.json" />
  861. </ItemGroup><ItemGroup>
  862.   <AdditionalFiles Include="Files\swagger.json" />
  863. </ItemGroup><ItemGroup>
  864.   <AdditionalFiles Include="Files\swagger.json" />
  865. </ItemGroup><ItemGroup>
  866.   <AdditionalFiles Include="Files\swagger.json" />
  867. </ItemGroup><ItemGroup>
  868.   <AdditionalFiles Include="Files\swagger.json" />
  869. </ItemGroup><ItemGroup>
  870.   <AdditionalFiles Include="Files\swagger.json" />
  871. </ItemGroup>return sb.ToString();<ItemGroup>
  872.   <AdditionalFiles Include="Files\swagger.json" />
  873. </ItemGroup><ItemGroup>
  874.   <AdditionalFiles Include="Files\swagger.json" />
  875. </ItemGroup><ItemGroup>
  876.   <AdditionalFiles Include="Files\swagger.json" />
  877. </ItemGroup><ItemGroup>
  878.   <AdditionalFiles Include="Files\swagger.json" />
  879. </ItemGroup>}<ItemGroup>
  880.   <AdditionalFiles Include="Files\swagger.json" />
  881. </ItemGroup><ItemGroup>
  882.   <AdditionalFiles Include="Files\swagger.json" />
  883. </ItemGroup><ItemGroup>
  884.   <AdditionalFiles Include="Files\swagger.json" />
  885. </ItemGroup><ItemGroup>
  886.   <AdditionalFiles Include="Files\swagger.json" />
  887. </ItemGroup>static string BuildProertyType(JObject value)<ItemGroup>
  888.   <AdditionalFiles Include="Files\swagger.json" />
  889. </ItemGroup><ItemGroup>
  890.   <AdditionalFiles Include="Files\swagger.json" />
  891. </ItemGroup><ItemGroup>
  892.   <AdditionalFiles Include="Files\swagger.json" />
  893. </ItemGroup><ItemGroup>
  894.   <AdditionalFiles Include="Files\swagger.json" />
  895. </ItemGroup>{<ItemGroup>
  896.   <AdditionalFiles Include="Files\swagger.json" />
  897. </ItemGroup><ItemGroup>
  898.   <AdditionalFiles Include="Files\swagger.json" />
  899. </ItemGroup><ItemGroup>
  900.   <AdditionalFiles Include="Files\swagger.json" />
  901. </ItemGroup><ItemGroup>
  902.   <AdditionalFiles Include="Files\swagger.json" />
  903. </ItemGroup><ItemGroup>
  904.   <AdditionalFiles Include="Files\swagger.json" />
  905. </ItemGroup><ItemGroup>
  906.   <AdditionalFiles Include="Files\swagger.json" />
  907. </ItemGroup>;<ItemGroup>
  908.   <AdditionalFiles Include="Files\swagger.json" />
  909. </ItemGroup><ItemGroup>
  910.   <AdditionalFiles Include="Files\swagger.json" />
  911. </ItemGroup><ItemGroup>
  912.   <AdditionalFiles Include="Files\swagger.json" />
  913. </ItemGroup><ItemGroup>
  914.   <AdditionalFiles Include="Files\swagger.json" />
  915. </ItemGroup><ItemGroup>
  916.   <AdditionalFiles Include="Files\swagger.json" />
  917. </ItemGroup><ItemGroup>
  918.   <AdditionalFiles Include="Files\swagger.json" />
  919. </ItemGroup>var type = GetType(value);<ItemGroup>
  920.   <AdditionalFiles Include="Files\swagger.json" />
  921. </ItemGroup><ItemGroup>
  922.   <AdditionalFiles Include="Files\swagger.json" />
  923. </ItemGroup><ItemGroup>
  924.   <AdditionalFiles Include="Files\swagger.json" />
  925. </ItemGroup><ItemGroup>
  926.   <AdditionalFiles Include="Files\swagger.json" />
  927. </ItemGroup><ItemGroup>
  928.   <AdditionalFiles Include="Files\swagger.json" />
  929. </ItemGroup><ItemGroup>
  930.   <AdditionalFiles Include="Files\swagger.json" />
  931. </ItemGroup>var nullable = value.ContainsKey("nullable") ? value["nullable"]!.Value() switch<ItemGroup>
  932.   <AdditionalFiles Include="Files\swagger.json" />
  933. </ItemGroup><ItemGroup>
  934.   <AdditionalFiles Include="Files\swagger.json" />
  935. </ItemGroup><ItemGroup>
  936.   <AdditionalFiles Include="Files\swagger.json" />
  937. </ItemGroup><ItemGroup>
  938.   <AdditionalFiles Include="Files\swagger.json" />
  939. </ItemGroup><ItemGroup>
  940.   <AdditionalFiles Include="Files\swagger.json" />
  941. </ItemGroup><ItemGroup>
  942.   <AdditionalFiles Include="Files\swagger.json" />
  943. </ItemGroup>{<ItemGroup>
  944.   <AdditionalFiles Include="Files\swagger.json" />
  945. </ItemGroup><ItemGroup>
  946.   <AdditionalFiles Include="Files\swagger.json" />
  947. </ItemGroup><ItemGroup>
  948.   <AdditionalFiles Include="Files\swagger.json" />
  949. </ItemGroup><ItemGroup>
  950.   <AdditionalFiles Include="Files\swagger.json" />
  951. </ItemGroup><ItemGroup>
  952.   <AdditionalFiles Include="Files\swagger.json" />
  953. </ItemGroup><ItemGroup>
  954.   <AdditionalFiles Include="Files\swagger.json" />
  955. </ItemGroup><ItemGroup>
  956.   <AdditionalFiles Include="Files\swagger.json" />
  957. </ItemGroup><ItemGroup>
  958.   <AdditionalFiles Include="Files\swagger.json" />
  959. </ItemGroup>true => "?",<ItemGroup>
  960.   <AdditionalFiles Include="Files\swagger.json" />
  961. </ItemGroup><ItemGroup>
  962.   <AdditionalFiles Include="Files\swagger.json" />
  963. </ItemGroup><ItemGroup>
  964.   <AdditionalFiles Include="Files\swagger.json" />
  965. </ItemGroup><ItemGroup>
  966.   <AdditionalFiles Include="Files\swagger.json" />
  967. </ItemGroup><ItemGroup>
  968.   <AdditionalFiles Include="Files\swagger.json" />
  969. </ItemGroup><ItemGroup>
  970.   <AdditionalFiles Include="Files\swagger.json" />
  971. </ItemGroup><ItemGroup>
  972.   <AdditionalFiles Include="Files\swagger.json" />
  973. </ItemGroup><ItemGroup>
  974.   <AdditionalFiles Include="Files\swagger.json" />
  975. </ItemGroup>false => "",<ItemGroup>
  976.   <AdditionalFiles Include="Files\swagger.json" />
  977. </ItemGroup><ItemGroup>
  978.   <AdditionalFiles Include="Files\swagger.json" />
  979. </ItemGroup><ItemGroup>
  980.   <AdditionalFiles Include="Files\swagger.json" />
  981. </ItemGroup><ItemGroup>
  982.   <AdditionalFiles Include="Files\swagger.json" />
  983. </ItemGroup><ItemGroup>
  984.   <AdditionalFiles Include="Files\swagger.json" />
  985. </ItemGroup><ItemGroup>
  986.   <AdditionalFiles Include="Files\swagger.json" />
  987. </ItemGroup><ItemGroup>
  988.   <AdditionalFiles Include="Files\swagger.json" />
  989. </ItemGroup><ItemGroup>
  990.   <AdditionalFiles Include="Files\swagger.json" />
  991. </ItemGroup>_ => ""<ItemGroup>
  992.   <AdditionalFiles Include="Files\swagger.json" />
  993. </ItemGroup><ItemGroup>
  994.   <AdditionalFiles Include="Files\swagger.json" />
  995. </ItemGroup><ItemGroup>
  996.   <AdditionalFiles Include="Files\swagger.json" />
  997. </ItemGroup><ItemGroup>
  998.   <AdditionalFiles Include="Files\swagger.json" />
  999. </ItemGroup><ItemGroup>
  1000.   <AdditionalFiles Include="Files\swagger.json" />
  1001. </ItemGroup><ItemGroup>
  1002.   <AdditionalFiles Include="Files\swagger.json" />
  1003. </ItemGroup>} : "";<ItemGroup>
  1004.   <AdditionalFiles Include="Files\swagger.json" />
  1005. </ItemGroup><ItemGroup>
  1006.   <AdditionalFiles Include="Files\swagger.json" />
  1007. </ItemGroup><ItemGroup>
  1008.   <AdditionalFiles Include="Files\swagger.json" />
  1009. </ItemGroup><ItemGroup>
  1010.   <AdditionalFiles Include="Files\swagger.json" />
  1011. </ItemGroup><ItemGroup>
  1012.   <AdditionalFiles Include="Files\swagger.json" />
  1013. </ItemGroup><ItemGroup>
  1014.   <AdditionalFiles Include="Files\swagger.json" />
  1015. </ItemGroup>return type + nullable;<ItemGroup>
  1016.   <AdditionalFiles Include="Files\swagger.json" />
  1017. </ItemGroup><ItemGroup>
  1018.   <AdditionalFiles Include="Files\swagger.json" />
  1019. </ItemGroup><ItemGroup>
  1020.   <AdditionalFiles Include="Files\swagger.json" />
  1021. </ItemGroup><ItemGroup>
  1022.   <AdditionalFiles Include="Files\swagger.json" />
  1023. </ItemGroup>}<ItemGroup>
  1024.   <AdditionalFiles Include="Files\swagger.json" />
  1025. </ItemGroup><ItemGroup>
  1026.   <AdditionalFiles Include="Files\swagger.json" />
  1027. </ItemGroup><ItemGroup>
  1028.   <AdditionalFiles Include="Files\swagger.json" />
  1029. </ItemGroup><ItemGroup>
  1030.   <AdditionalFiles Include="Files\swagger.json" />
  1031. </ItemGroup>static string GetType(JObject value)<ItemGroup>
  1032.   <AdditionalFiles Include="Files\swagger.json" />
  1033. </ItemGroup><ItemGroup>
  1034.   <AdditionalFiles Include="Files\swagger.json" />
  1035. </ItemGroup><ItemGroup>
  1036.   <AdditionalFiles Include="Files\swagger.json" />
  1037. </ItemGroup><ItemGroup>
  1038.   <AdditionalFiles Include="Files\swagger.json" />
  1039. </ItemGroup>{<ItemGroup>
  1040.   <AdditionalFiles Include="Files\swagger.json" />
  1041. </ItemGroup><ItemGroup>
  1042.   <AdditionalFiles Include="Files\swagger.json" />
  1043. </ItemGroup><ItemGroup>
  1044.   <AdditionalFiles Include="Files\swagger.json" />
  1045. </ItemGroup><ItemGroup>
  1046.   <AdditionalFiles Include="Files\swagger.json" />
  1047. </ItemGroup><ItemGroup>
  1048.   <AdditionalFiles Include="Files\swagger.json" />
  1049. </ItemGroup><ItemGroup>
  1050.   <AdditionalFiles Include="Files\swagger.json" />
  1051. </ItemGroup>return value.ContainsKey("type") ? value["type"]!.Value() switch<ItemGroup>
  1052.   <AdditionalFiles Include="Files\swagger.json" />
  1053. </ItemGroup><ItemGroup>
  1054.   <AdditionalFiles Include="Files\swagger.json" />
  1055. </ItemGroup><ItemGroup>
  1056.   <AdditionalFiles Include="Files\swagger.json" />
  1057. </ItemGroup><ItemGroup>
  1058.   <AdditionalFiles Include="Files\swagger.json" />
  1059. </ItemGroup><ItemGroup>
  1060.   <AdditionalFiles Include="Files\swagger.json" />
  1061. </ItemGroup><ItemGroup>
  1062.   <AdditionalFiles Include="Files\swagger.json" />
  1063. </ItemGroup>{<ItemGroup>
  1064.   <AdditionalFiles Include="Files\swagger.json" />
  1065. </ItemGroup><ItemGroup>
  1066.   <AdditionalFiles Include="Files\swagger.json" />
  1067. </ItemGroup><ItemGroup>
  1068.   <AdditionalFiles Include="Files\swagger.json" />
  1069. </ItemGroup><ItemGroup>
  1070.   <AdditionalFiles Include="Files\swagger.json" />
  1071. </ItemGroup><ItemGroup>
  1072.   <AdditionalFiles Include="Files\swagger.json" />
  1073. </ItemGroup><ItemGroup>
  1074.   <AdditionalFiles Include="Files\swagger.json" />
  1075. </ItemGroup><ItemGroup>
  1076.   <AdditionalFiles Include="Files\swagger.json" />
  1077. </ItemGroup><ItemGroup>
  1078.   <AdditionalFiles Include="Files\swagger.json" />
  1079. </ItemGroup>"string" => "string",<ItemGroup>
  1080.   <AdditionalFiles Include="Files\swagger.json" />
  1081. </ItemGroup><ItemGroup>
  1082.   <AdditionalFiles Include="Files\swagger.json" />
  1083. </ItemGroup><ItemGroup>
  1084.   <AdditionalFiles Include="Files\swagger.json" />
  1085. </ItemGroup><ItemGroup>
  1086.   <AdditionalFiles Include="Files\swagger.json" />
  1087. </ItemGroup><ItemGroup>
  1088.   <AdditionalFiles Include="Files\swagger.json" />
  1089. </ItemGroup><ItemGroup>
  1090.   <AdditionalFiles Include="Files\swagger.json" />
  1091. </ItemGroup><ItemGroup>
  1092.   <AdditionalFiles Include="Files\swagger.json" />
  1093. </ItemGroup><ItemGroup>
  1094.   <AdditionalFiles Include="Files\swagger.json" />
  1095. </ItemGroup>"boolean" => "bool",<ItemGroup>
  1096.   <AdditionalFiles Include="Files\swagger.json" />
  1097. </ItemGroup><ItemGroup>
  1098.   <AdditionalFiles Include="Files\swagger.json" />
  1099. </ItemGroup><ItemGroup>
  1100.   <AdditionalFiles Include="Files\swagger.json" />
  1101. </ItemGroup><ItemGroup>
  1102.   <AdditionalFiles Include="Files\swagger.json" />
  1103. </ItemGroup><ItemGroup>
  1104.   <AdditionalFiles Include="Files\swagger.json" />
  1105. </ItemGroup><ItemGroup>
  1106.   <AdditionalFiles Include="Files\swagger.json" />
  1107. </ItemGroup><ItemGroup>
  1108.   <AdditionalFiles Include="Files\swagger.json" />
  1109. </ItemGroup><ItemGroup>
  1110.   <AdditionalFiles Include="Files\swagger.json" />
  1111. </ItemGroup>"number" => value["format"]!.Value() == "float" ? "float" : "double",<ItemGroup>
  1112.   <AdditionalFiles Include="Files\swagger.json" />
  1113. </ItemGroup><ItemGroup>
  1114.   <AdditionalFiles Include="Files\swagger.json" />
  1115. </ItemGroup><ItemGroup>
  1116.   <AdditionalFiles Include="Files\swagger.json" />
  1117. </ItemGroup><ItemGroup>
  1118.   <AdditionalFiles Include="Files\swagger.json" />
  1119. </ItemGroup><ItemGroup>
  1120.   <AdditionalFiles Include="Files\swagger.json" />
  1121. </ItemGroup><ItemGroup>
  1122.   <AdditionalFiles Include="Files\swagger.json" />
  1123. </ItemGroup><ItemGroup>
  1124.   <AdditionalFiles Include="Files\swagger.json" />
  1125. </ItemGroup><ItemGroup>
  1126.   <AdditionalFiles Include="Files\swagger.json" />
  1127. </ItemGroup>"integer" => value["format"]!.Value() == "int32" ? "int" : "long",<ItemGroup>
  1128.   <AdditionalFiles Include="Files\swagger.json" />
  1129. </ItemGroup><ItemGroup>
  1130.   <AdditionalFiles Include="Files\swagger.json" />
  1131. </ItemGroup><ItemGroup>
  1132.   <AdditionalFiles Include="Files\swagger.json" />
  1133. </ItemGroup><ItemGroup>
  1134.   <AdditionalFiles Include="Files\swagger.json" />
  1135. </ItemGroup><ItemGroup>
  1136.   <AdditionalFiles Include="Files\swagger.json" />
  1137. </ItemGroup><ItemGroup>
  1138.   <AdditionalFiles Include="Files\swagger.json" />
  1139. </ItemGroup><ItemGroup>
  1140.   <AdditionalFiles Include="Files\swagger.json" />
  1141. </ItemGroup><ItemGroup>
  1142.   <AdditionalFiles Include="Files\swagger.json" />
  1143. </ItemGroup>"array" => ((JObject)value["items"]!).ContainsKey("items") ?<ItemGroup>
  1144.   <AdditionalFiles Include="Files\swagger.json" />
  1145. </ItemGroup><ItemGroup>
  1146.   <AdditionalFiles Include="Files\swagger.json" />
  1147. </ItemGroup><ItemGroup>
  1148.   <AdditionalFiles Include="Files\swagger.json" />
  1149. </ItemGroup><ItemGroup>
  1150.   <AdditionalFiles Include="Files\swagger.json" />
  1151. </ItemGroup><ItemGroup>
  1152.   <AdditionalFiles Include="Files\swagger.json" />
  1153. </ItemGroup><ItemGroup>
  1154.   <AdditionalFiles Include="Files\swagger.json" />
  1155. </ItemGroup><ItemGroup>
  1156.   <AdditionalFiles Include="Files\swagger.json" />
  1157. </ItemGroup><ItemGroup>
  1158.   <AdditionalFiles Include="Files\swagger.json" />
  1159. </ItemGroup>$"List"<ItemGroup>
  1160.   <AdditionalFiles Include="Files\swagger.json" />
  1161. </ItemGroup><ItemGroup>
  1162.   <AdditionalFiles Include="Files\swagger.json" />
  1163. </ItemGroup><ItemGroup>
  1164.   <AdditionalFiles Include="Files\swagger.json" />
  1165. </ItemGroup><ItemGroup>
  1166.   <AdditionalFiles Include="Files\swagger.json" />
  1167. </ItemGroup><ItemGroup>
  1168.   <AdditionalFiles Include="Files\swagger.json" />
  1169. </ItemGroup><ItemGroup>
  1170.   <AdditionalFiles Include="Files\swagger.json" />
  1171. </ItemGroup><ItemGroup>
  1172.   <AdditionalFiles Include="Files\swagger.json" />
  1173. </ItemGroup><ItemGroup>
  1174.   <AdditionalFiles Include="Files\swagger.json" />
  1175. </ItemGroup>: $"List",<ItemGroup>
  1176.   <AdditionalFiles Include="Files\swagger.json" />
  1177. </ItemGroup><ItemGroup>
  1178.   <AdditionalFiles Include="Files\swagger.json" />
  1179. </ItemGroup><ItemGroup>
  1180.   <AdditionalFiles Include="Files\swagger.json" />
  1181. </ItemGroup><ItemGroup>
  1182.   <AdditionalFiles Include="Files\swagger.json" />
  1183. </ItemGroup><ItemGroup>
  1184.   <AdditionalFiles Include="Files\swagger.json" />
  1185. </ItemGroup><ItemGroup>
  1186.   <AdditionalFiles Include="Files\swagger.json" />
  1187. </ItemGroup><ItemGroup>
  1188.   <AdditionalFiles Include="Files\swagger.json" />
  1189. </ItemGroup><ItemGroup>
  1190.   <AdditionalFiles Include="Files\swagger.json" />
  1191. </ItemGroup>"object" => value.ContainsKey("additionalProperties") ? $"Dictionary" : "object",<ItemGroup>
  1192.   <AdditionalFiles Include="Files\swagger.json" />
  1193. </ItemGroup><ItemGroup>
  1194.   <AdditionalFiles Include="Files\swagger.json" />
  1195. </ItemGroup><ItemGroup>
  1196.   <AdditionalFiles Include="Files\swagger.json" />
  1197. </ItemGroup><ItemGroup>
  1198.   <AdditionalFiles Include="Files\swagger.json" />
  1199. </ItemGroup><ItemGroup>
  1200.   <AdditionalFiles Include="Files\swagger.json" />
  1201. </ItemGroup><ItemGroup>
  1202.   <AdditionalFiles Include="Files\swagger.json" />
  1203. </ItemGroup><ItemGroup>
  1204.   <AdditionalFiles Include="Files\swagger.json" />
  1205. </ItemGroup><ItemGroup>
  1206.   <AdditionalFiles Include="Files\swagger.json" />
  1207. </ItemGroup>_ => "object"<ItemGroup>
  1208.   <AdditionalFiles Include="Files\swagger.json" />
  1209. </ItemGroup><ItemGroup>
  1210.   <AdditionalFiles Include="Files\swagger.json" />
  1211. </ItemGroup><ItemGroup>
  1212.   <AdditionalFiles Include="Files\swagger.json" />
  1213. </ItemGroup><ItemGroup>
  1214.   <AdditionalFiles Include="Files\swagger.json" />
  1215. </ItemGroup><ItemGroup>
  1216.   <AdditionalFiles Include="Files\swagger.json" />
  1217. </ItemGroup><ItemGroup>
  1218.   <AdditionalFiles Include="Files\swagger.json" />
  1219. </ItemGroup>} : value.ContainsKey("$ref") ? HandleClassName(value["$ref"]!.Value()!) : "object";<ItemGroup>
  1220.   <AdditionalFiles Include="Files\swagger.json" />
  1221. </ItemGroup><ItemGroup>
  1222.   <AdditionalFiles Include="Files\swagger.json" />
  1223. </ItemGroup><ItemGroup>
  1224.   <AdditionalFiles Include="Files\swagger.json" />
  1225. </ItemGroup><ItemGroup>
  1226.   <AdditionalFiles Include="Files\swagger.json" />
  1227. </ItemGroup>}<ItemGroup>
  1228.   <AdditionalFiles Include="Files\swagger.json" />
  1229. </ItemGroup><ItemGroup>
  1230.   <AdditionalFiles Include="Files\swagger.json" />
  1231. </ItemGroup><ItemGroup>
  1232.   <AdditionalFiles Include="Files\swagger.json" />
  1233. </ItemGroup><ItemGroup>
  1234.   <AdditionalFiles Include="Files\swagger.json" />
  1235. </ItemGroup>static unsafe string ToUpperFirst(string str)<ItemGroup>
  1236.   <AdditionalFiles Include="Files\swagger.json" />
  1237. </ItemGroup><ItemGroup>
  1238.   <AdditionalFiles Include="Files\swagger.json" />
  1239. </ItemGroup><ItemGroup>
  1240.   <AdditionalFiles Include="Files\swagger.json" />
  1241. </ItemGroup><ItemGroup>
  1242.   <AdditionalFiles Include="Files\swagger.json" />
  1243. </ItemGroup>{<ItemGroup>
  1244.   <AdditionalFiles Include="Files\swagger.json" />
  1245. </ItemGroup><ItemGroup>
  1246.   <AdditionalFiles Include="Files\swagger.json" />
  1247. </ItemGroup><ItemGroup>
  1248.   <AdditionalFiles Include="Files\swagger.json" />
  1249. </ItemGroup><ItemGroup>
  1250.   <AdditionalFiles Include="Files\swagger.json" />
  1251. </ItemGroup><ItemGroup>
  1252.   <AdditionalFiles Include="Files\swagger.json" />
  1253. </ItemGroup><ItemGroup>
  1254.   <AdditionalFiles Include="Files\swagger.json" />
  1255. </ItemGroup>if (str == null) return null;<ItemGroup>
  1256.   <AdditionalFiles Include="Files\swagger.json" />
  1257. </ItemGroup><ItemGroup>
  1258.   <AdditionalFiles Include="Files\swagger.json" />
  1259. </ItemGroup><ItemGroup>
  1260.   <AdditionalFiles Include="Files\swagger.json" />
  1261. </ItemGroup><ItemGroup>
  1262.   <AdditionalFiles Include="Files\swagger.json" />
  1263. </ItemGroup><ItemGroup>
  1264.   <AdditionalFiles Include="Files\swagger.json" />
  1265. </ItemGroup><ItemGroup>
  1266.   <AdditionalFiles Include="Files\swagger.json" />
  1267. </ItemGroup>string ret = string.Copy(str);<ItemGroup>
  1268.   <AdditionalFiles Include="Files\swagger.json" />
  1269. </ItemGroup><ItemGroup>
  1270.   <AdditionalFiles Include="Files\swagger.json" />
  1271. </ItemGroup><ItemGroup>
  1272.   <AdditionalFiles Include="Files\swagger.json" />
  1273. </ItemGroup><ItemGroup>
  1274.   <AdditionalFiles Include="Files\swagger.json" />
  1275. </ItemGroup><ItemGroup>
  1276.   <AdditionalFiles Include="Files\swagger.json" />
  1277. </ItemGroup><ItemGroup>
  1278.   <AdditionalFiles Include="Files\swagger.json" />
  1279. </ItemGroup>fixed (char* ptr = ret)<ItemGroup>
  1280.   <AdditionalFiles Include="Files\swagger.json" />
  1281. </ItemGroup><ItemGroup>
  1282.   <AdditionalFiles Include="Files\swagger.json" />
  1283. </ItemGroup><ItemGroup>
  1284.   <AdditionalFiles Include="Files\swagger.json" />
  1285. </ItemGroup><ItemGroup>
  1286.   <AdditionalFiles Include="Files\swagger.json" />
  1287. </ItemGroup><ItemGroup>
  1288.   <AdditionalFiles Include="Files\swagger.json" />
  1289. </ItemGroup><ItemGroup>
  1290.   <AdditionalFiles Include="Files\swagger.json" />
  1291. </ItemGroup><ItemGroup>
  1292.   <AdditionalFiles Include="Files\swagger.json" />
  1293. </ItemGroup><ItemGroup>
  1294.   <AdditionalFiles Include="Files\swagger.json" />
  1295. </ItemGroup>*ptr = char.ToUpper(*ptr);<ItemGroup>
  1296.   <AdditionalFiles Include="Files\swagger.json" />
  1297. </ItemGroup><ItemGroup>
  1298.   <AdditionalFiles Include="Files\swagger.json" />
  1299. </ItemGroup><ItemGroup>
  1300.   <AdditionalFiles Include="Files\swagger.json" />
  1301. </ItemGroup><ItemGroup>
  1302.   <AdditionalFiles Include="Files\swagger.json" />
  1303. </ItemGroup><ItemGroup>
  1304.   <AdditionalFiles Include="Files\swagger.json" />
  1305. </ItemGroup><ItemGroup>
  1306.   <AdditionalFiles Include="Files\swagger.json" />
  1307. </ItemGroup>return ret;<ItemGroup>
  1308.   <AdditionalFiles Include="Files\swagger.json" />
  1309. </ItemGroup><ItemGroup>
  1310.   <AdditionalFiles Include="Files\swagger.json" />
  1311. </ItemGroup><ItemGroup>
  1312.   <AdditionalFiles Include="Files\swagger.json" />
  1313. </ItemGroup><ItemGroup>
  1314.   <AdditionalFiles Include="Files\swagger.json" />
  1315. </ItemGroup>}<ItemGroup>
  1316.   <AdditionalFiles Include="Files\swagger.json" />
  1317. </ItemGroup><ItemGroup>
  1318.   <AdditionalFiles Include="Files\swagger.json" />
  1319. </ItemGroup>}}
复制代码
详细的处理过程大家可以仔细看看代码,这里就不一一解释了。
启动编译

接下来编译控制台程序。编译成功后可以看到生成了很多cs的代码。若是看不见,可以重启VS。

点开一个文件,可以看到内容,并且在上方提示自动生成,无法编辑。

到这我们就完成了通过swagger来生成我们的请求和响应类的功能。
结语

本文章应用SourceGenerator,在编译时读取swagger.json的内容并解析,成功生成了我们API的请求和响应类的代码。
我们可以发现,代码生成没有问题,无法移动或者编辑生成的代码。
下一篇文章我们就来学习下如何输出SourceGenerator生成的代码文件到我们的文件目录。
本文代码仓库地址https://github.com/fanslead/Learn-SourceGenerator

来源:https://www.cnblogs.com/fanshaoO/p/18109928
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具