[英]NSwagStudio add custom typescript imports/lines
在我的項目中,我通過 NSwagStudio 生成打字稿客戶端。
要添加憑據,我有一個實現transformOptions
的 BaseClient 類。
export class MyClient extends BaseClient{...
現在我需要在每個生成的腳本的開頭添加以下幾行:
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { BaseClient } from 'my-components-lib';
這可以通過 NSwagStudio-Configuration 完成嗎,如果,如何完成?
對於openApiToTypeScriptClient
代碼生成器,您可以配置設置extensionCode
設置以使用外部模板。
這是我如何使用它
"extensionCode": "nswag.imports.ts"
這就是我的 nswag.imports.ts 文件的樣子
import BaseClient from './MyComponent.base';
最終 NSwag 生成的代碼看起來像這樣
/* tslint:disable */
/* eslint-disable */
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------
// ReSharper disable InconsistentNaming
import BaseClient from './MyComponent.base';
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, CancelToken } from 'axios';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.