ABP 集成 nswag 到 VUE 项目, 自动生成操作类代码
记录日期: 2019-9-22 23:12:39
原文链接:https://www.cnblogs.com/Qbit/p/11569906.html
集成记录:
npm install nswag --save-dev
复制 NSwag\src\NSwag.CodeGeneration.TypeScript\Templates 目录下的所有文件到 ts 项目的 nswag 目录下,nswag 源码下载困难,人肉拷贝吧 https://github.com/RicoSuter/NSwag/tree/master/src/NSwag.CodeGeneration.TypeScript/Templates
修改 service.config.nswag 中的 templateDirectory 为: "templateDirectory": "./Templates",
至此,可以随意调整复制过来的 liquid 模板,比如增加clientBaseClass 的引用 我的 完整配置如下:
{
"runtime": "Default",
"defaultVariables": null,
"documentGenerator": {
"fromDocument": {
"json": "",
"url": "http://localhost:21021/swagger/v1/swagger.json",
"output": null
}
},
"codeGenerators": {
"openApiToTypeScriptClient": {
"className": "{controller}ServiceProxy",
"moduleName": "",
"namespace": "",
"typeScriptVersion": 2.7,
"template": "Axios",
"promiseType": "Promise",
"httpClass": "HttpClient",
"useSingletonProvider": false,
"injectionTokenType": "InjectionToken",
"rxJsVersion": 6.0,
"dateTimeType": "Date",
"nullValue": "Null",
"generateClientClasses": true,
"generateClientInterfaces": false,
"generateOptionalParameters": false,
"exportTypes": true,
"wrapDtoExceptions": false,
"exceptionClass": "ApiException",
"clientBaseClass": "AbpServiceBase",
"wrapResponses": false,
"wrapResponseMethods": [],
"generateResponseClasses": true,
"responseClass": "SwaggerResponse",
"protectedMethods": [],
"configurationClass": null,
"useTransformOptionsMethod": false,
"useTransformResultMethod": true,
"generateDtoTypes": true,
"operationGenerationMode": "MultipleClientsFromPathSegments",
"markOptionalProperties": false,
"generateCloneMethod": false,
"typeStyle": "Class",
"classTypes": [],
"extendedClasses": [],
"extensionCode": "",
"generateDefaultValues": true,
"excludedTypeNames": [],
"excludedParameterNames": [],
"handleReferences": true,
"generateConstructorInterface": false,
"convertConstructorInterfaceData": true,
"importRequiredTypes": true,
"useGetBaseUrlMethod": false,
"baseUrlTokenName": "API_BASE_URL",
"queryNullValue": "",
"inlineNamedDictionaries": false,
"inlineNamedAny": false,
"templateDirectory": "./Templates",
"typeNameGeneratorType": null,
"propertyNameGeneratorType": null,
"enumNameGeneratorType": null,
"serviceHost": null,
"serviceSchemes": null,
"output": "../src/api/abp-service-proxies.ts"
}
}
}
ABP 的swagger 必须使用这种方式获取data.result
修改 Client.ProcessResponse.ReadBodyStart.liquid
import { AxiosResponse } from "axios";
export class AbpServiceBase {
protected transformResult(url: string, response: AxiosResponse, processor: (response: AxiosResponse) => Promise<any>): Promise<any> {
// if(response.data.result){
// response.data=response.data.result;
// }
console.log(response)
return processor(response);
}
}
修改 File.liquid 文件,在48行增加 :
ABP 集成 nswag 到 VUE 项目, 自动生成操作类代码的更多相关文章
- SpringBoot整合Mybatis 使用generator自动生成实体类代码、Mapper代码、dao层代码
1.新建一个SpringBoot项目,并引入Mybatis和mybatis-generator相关的依赖. <dependency> <groupId>org.springfr ...
- C# 连接SQLServer数据库自动生成model类代码
Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading ...
- 用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档.
- java实现的一个maven多模块项目自动生成工具
平时在做spring mvc web新项目时,都需要自己去搭建spring mvc的项目框架,包括基本pom 依赖引入,基本配置文件(web.xml,spring-mvc.xml,数据库配置文件等等) ...
- webpack打包vue项目之后生成的dist文件该怎么启动运行
亲测,webpack打包vue项目之后生成的dist文件可以部署到 express 服务器上运行. 我的vue项目结构如下: 1. 进入该vue项目目录,打开git bash,执行:npm run b ...
- 自动生成Code First代码
自动生成Code First代码 在前面的文章中我们提到Entity Framework的“Code First”模式也同样可以基于现有数据库进行开发.今天就让我们一起看一下使用Entity Fram ...
- Mybatis自动生成实体类
Maven自动生成实体类需要的jar包 一.pom.xml中 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns ...
- Springboot mybatis generate 自动生成实体类和Mapper
https://github.com/JasmineQian/SpringDemo_2019/tree/master/mybatis Springboot让java开发变得方便,Springboot中 ...
- 使用MyBatis Generator自动生成MyBatis的代码
这两天需要用到MyBatis的代码自动生成的功能,由于MyBatis属于一种半自动的ORM框架,所以主要的工作就是配置Mapping映射文件,但是由于手写映射文件很容易出错,所以可利用MyBatis生 ...
随机推荐
- idea查看源码没有注释的问题
进入idea的设置 勾选这两个 然后重新导入 页面的右上角有个下载download source的提示,点击下载即可 然后页面就要源码注释了
- IPD术语
集成产品开发(Integrated Product Development,简称IPD)是一套产品开发的模式.理念与方法. ABC 基于活动的成本核算 ABM 基于活动的管理 ADCP 可获得性决策 ...
- 阿里云ECS服务器 java JDK安装和配置 mysql安装和配置
最近配置了一下阿里云ecs服务的服务器环境,主要对java jdk环境的安装和配置,以及数据库mysql的安装和配置,趁着热乎,记录一下! 服务器用的系统是ubuntu_16_04_64的,版本16. ...
- storm group 的介绍与使用
一.stream group分组介绍 Stream 的分组分为随机分组.字段分组.全部分组.全局分组.无分组.直接分组,自定义分组 二.group的介绍 1.Shuffle grouping:通过tu ...
- 实时监控服务器某个端口状态TCPing
在给客户做运维服务期间,发现了一个奇怪的现象:备份系统(第三方国产)告警日志显示,每天晚上备份服务器的客户端在3点左右离线然后上线,再离线再上线,每晚两次,很是诡异. 联系了厂家技术支持,前后花了两天 ...
- 【Jmeter源码解读】001——目录结构
1.顶层目录 bin - 包含.bat 和 . sh 这些文件用于启动JMeter.同时也包含了ApacheJmeter.jar 和 相关的配置文件 build - build 脚本创建的目录,存放一 ...
- InnoDB 中的锁实现
InnoDB 中的锁实现 原贴:InnoDB 锁系统及死锁检测实现分析 InnoDB 中,所有事务加的行锁通过一个全局的 hash 表 lock_sys 维护: /* The lock system ...
- oracle多表关联删除的两种方法
oracle多表关联删除的两种方法 第一种使用exists方法 delete from tableA where exits ( select 1 from tableB Where tableA.i ...
- 针对Web的信息搜集
信息收集(Information Gathering),信息收集是指通过各种方式获取所需要的信息,在整个渗透测试环节中,信息搜集是整个渗透过程中最为重要的一环,信息搜集可占据整个渗透测试80%左右的工 ...
- Inversion 多校签到题
存下值和下标后排序,每次从坐后面开始取就可以了. ac代码: #include <algorithm> #include <cstdio> #include <cstri ...