gpt4 book ai didi

模型名称中的 NSwag 命名空间

转载 作者:行者123 更新时间:2023-12-04 15:07:32 25 4
gpt4 key购买 nike

是否可以生成客户端代码,以便模型的类名具有完整的命名空间作为前缀?

这应该避免相同的类名冲突。

例子



com.foo.MyClass 



it.foo.MyClass

到现在我得到的是 MyClassMyClass2那没有多大意义。

应该更好,以防名称冲突, ComFooMyClassItFooMyClass .

最佳答案

让我更新 shadowsheep 对更新版本的 NSwag 的回答:

services.AddSwaggerDocument(cfg => { cfg.SchemaNameGenerator = new CustomSchemaNameGenerator(); });

和:
internal class CustomSchemaNameGenerator : ISchemaNameGenerator
{
public string Generate(Type type)
{
return type.FullName.Replace(".", "_");
}
}

关于模型名称中的 NSwag 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45241177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com