重命名OpenAPI的参考生成的swagger.json

问题描述

我想知道如何重命名生成的swagger.json

enter image description here

当我通过“添加新的OpenAPI服务引用”选项向Visual Studio 2019中的项目添加OpenAPI服务引用时。

enter image description here

我认为应该像使用“ ClassName”一样。

<ItemGroup>
    <OpenApiReference Include="OpenAPIs\swagger.json" CodeGenerator="NSwagCSharp" Namespace="PetStore.Client">
      <SourceUri>https://petstore.swagger.io/v2/swagger.json</SourceUri>
      <ClassName>PetStoreClient</ClassName>
      <OutputPath>PetStoreClient.cs</OutputPath>
      <Options>/GenerateClientInterfaces:true /ClientBaseClass:ClientBase</Options>
    </OpenApiReference>
</ItemGroup>

解决方法

要更改此设置,只需将 Include<OpenApiReference /> 参数更改为另一个路径。然后刷新服务引用。

refresh button

这可能需要手动清理解决方案(出于某种原因,binobj 中的 OpenApi 相关内容有时不会自行清理)。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...