有什么办法可以使用NSwag TypeScript Client将Abstract类作为ANY对象生成?

问题描述

.NET应用程序中有许多抽象类。 我已经在请求和响应中使用了这种抽象。

当我生成TypeScriptClient时,我会看到下一个打字稿代码:

export class IDetectionEngineProfile implements IIDetectionEngineProfile {

    constructor(data?: IIDetectionEngineProfile) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
    }

    static fromJS(data: any): IDetectionEngineProfile {
        data = typeof data === 'object' ? data : {};
        let result = new IDetectionEngineProfile();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        return data; 
    }
}

export interface IIDetectionEngineProfile {
}

当然IDetectionEngineProfile没有任何属性。绝对正确。

但是我会阻止此代码的生成,并且只能使用任何对象。

NSwag可以吗?

P / S:我已经阅读了Inheritance条文章。但这不是我的解决方案。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

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