提交 96a0e9db 作者: 方治民

feat(api): swagger v3 pont 适配

上级 e7499b6e
{
"originType": "SwaggerV2",
"originUrl": "http://127.0.0.1:8081/api/v2/api-docs",
"originType": "SwaggerV3",
"originUrl": "http://127.0.0.1:8081/api/v3/api-docs",
"templateType": "fetch",
"templatePath": "./pont-template",
"transformPath": "./pont-transform",
"outDir": "./src/api/services",
"surrounding": "typeScript",
"usingOperationId": true,
"mocks": {
"enable": true,
"basePath": "",
......
import * as Pont from 'pont-engine'
// import * as Pont from 'pont-engine'
import { Interface, BaseClass, Property, CodeGenerator } from 'pont-engine'
// 接口 API 前缀
// 通常与项目的 env 配置中的 VITE_GLOB_API_URL_PREFIX 相同
const API_URL_PREFIX = '/api'
export class FileStructures extends Pont.FileStructures {
getModsDeclaration(originCode: string): string {
return originCode
}
}
export default class BasicGenerator extends CodeGenerator {
checkJsonParam(inter: Interface, paramsCode: string): boolean {
const prettier = require('prettier')
......@@ -21,6 +15,7 @@ export default class BasicGenerator extends CodeGenerator {
// 认为没有返回值的接口表示下载(通常是)
isDownload(inter: Interface): boolean {
console.log(inter.name, inter.responseType)
return inter.responseType === 'any'
}
......@@ -88,7 +83,8 @@ export default class BasicGenerator extends CodeGenerator {
const method = inter.method.toUpperCase()
const paramsCode = inter.getParamsCode('Params', this.surrounding)
const requestParams = this.getParams(inter, paramsCode)
const undef = inter.response.getInitialValue() === 'undefined'
const initValue = inter.response.getInitialValue(true)
const undef = initValue === 'undefined' || initValue === `''`
const isBody = this.checkJsonParam(inter, paramsCode)
// TODO
......@@ -105,7 +101,7 @@ export default class BasicGenerator extends CodeGenerator {
${isBody ? '' : `export ${paramsCode}`}
${undef ? '' : `export const init = ${inter.response.getInitialValue(true)};`}
${undef ? '' : `export const init = ${initValue};`}
export function request(${requestParams}) {
return defHttp.request({
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -24,6 +24,9 @@ export class MenuVo {
/** 重定向 */
redirect = ''
/** 唯一标识 */
uid = ''
}
export class PageParam {
......@@ -40,7 +43,40 @@ export class PageParam {
sortOrder = 'ASC'
}
export class PageVo {
export class PageVoPermissionVo {
/** 数据 */
data = []
/** 数据最新时间 */
latest = ''
/** 数据总数 */
total = undefined
}
export class PageVoRoleVo {
/** 数据 */
data = []
/** 数据最新时间 */
latest = ''
/** 数据总数 */
total = undefined
}
export class PageVoString {
/** 数据 */
data = []
/** 数据最新时间 */
latest = ''
/** 数据总数 */
total = undefined
}
export class PageVoUserVo {
/** 数据 */
data = []
......@@ -52,48 +88,178 @@ export class PageVo {
}
export class PermissionVo {
/** 子权限 */
/** children */
children = []
/** 组件 */
/** component */
component = ''
/** 是否启用 */
/** enable */
enable = false
/** 是否隐藏 */
/** hidden */
hidden = false
/** 图标 */
/** icon */
icon = ''
/** 主键 */
/** id */
id = ''
/** 元数据 */
/** meta */
meta = undefined
/** 名称 */
/** name */
name = ''
/** 路径 */
/** path */
path = ''
/** 父级ID */
/** pid */
pid = ''
/** 序号 */
/** serial */
serial = undefined
/** 权限类型 */
/** type */
type = 'DIR'
/** 标识 */
/** uid */
uid = ''
}
export class Result {
export class ResultArrayListMenuVo {
/** 内容 */
body = []
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultArrayListPermissionVo {
/** 内容 */
body = []
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultArrayListRoleVo {
/** 内容 */
body = []
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultArrayListString {
/** 内容 */
body = []
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultBoolean {
/** 内容 */
body = false
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultLoginVo {
/** body */
body = new LoginVo()
/** 业务标识码 */
......@@ -118,6 +284,240 @@ export class Result {
timestamp = ''
}
export class ResultPageVoPermissionVo {
/** body */
body = new PageVoPermissionVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPageVoRoleVo {
/** body */
body = new PageVoRoleVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPageVoString {
/** body */
body = new PageVoString()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPageVoUserVo {
/** body */
body = new PageVoUserVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultPermissionVo {
/** body */
body = new PermissionVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultRoleVo {
/** body */
body = new RoleVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultString {
/** 内容 */
body = ''
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultUserExtensionVo {
/** body */
body = new UserExtensionVo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class ResultUserInfo {
/** body */
body = new UserInfo()
/** 业务标识码 */
code = undefined
/** 详细信息 */
details = ''
/** 异常信息 */
error = ''
/** 消息 */
message = ''
/** 状态码 */
status = undefined
/** 耗时 */
times = ''
/** 响应时间 */
timestamp = ''
}
export class RoleVo {
/** 主键 */
id = ''
......@@ -138,6 +538,9 @@ export class UserExtensionVo {
/** 性别 */
gender = undefined
/** 简介 */
introduction = ''
}
export class UserInfo {
......
......@@ -4,6 +4,7 @@
import * as login from './login'
import * as logout from './logout'
import * as register from './register'
import * as safe from './safe'
import * as valid from './valid'
export { login, logout, register, valid }
export { login, logout, register, safe, valid }
......@@ -12,7 +12,7 @@ export class Params {
password: string
}
export const init = new defs.Result()
export const init = new defs.ResultLoginVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,25 +6,25 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 用户名 */
username: string
/** 密码 */
password: string
/** 真实姓名 */
realName: string
/** 手机号 */
mobile: string
/** 头像 */
avatar?: string
/** 邮箱 */
email?: string
/** 是否启用 */
enable?: boolean
/** 简介 */
introduction?: string
/** 手机号 */
mobile: string
/** 密码 */
password: string
/** 真实姓名 */
realName: string
/** 用户名 */
username: string
/** 是否启用 */
enable?: boolean
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
/**
* @desc 安全验证
*/
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 密码 */
password: string
}
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/auth/safe',
method: 'GET',
params,
...config,
},
options,
)
}
/**
* @desc 检查登录状态
* @desc 检查登录
*/
import * as defs from '../../baseClass'
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultBoolean()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultUserExtensionVo()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -5,7 +5,7 @@
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export const init = new defs.Result()
export const init = new defs.ResultPageVoString()
export function request(
body: defs.PageParam,
......
......@@ -6,17 +6,17 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */
/** pageSize */
pageSize: number
/** pageNo */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC'
sortOrder?: string
}
export const init = new defs.Result()
export const init = new defs.ResultPageVoString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -5,22 +5,15 @@
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.ResultString()
export const init = new defs.Result()
export function request(
params: Params,
form: FormData,
config?: http.RequestConfig<Params | FormData>,
options?: http.RequestOptions,
) {
export function request(body: object, config?: http.RequestConfig<object>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/common/file/upload',
method: 'POST',
data: form || params,
headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' },
data: body,
headers: { 'Content-Type': 'application/json' },
...config,
},
......
......@@ -5,19 +5,15 @@
import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** Base64 图片信息 */
base64Image: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
export function request(body: string, config?: http.RequestConfig<string>, options?: http.RequestOptions) {
return defHttp.request(
{
url: '/common/file/uploadBase64Image',
method: 'POST',
data: params,
data: body,
headers: { 'Content-Type': 'application/json' },
...config,
},
......
......@@ -6,33 +6,35 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 组件 */
component?: string
/** 是否启用 */
enable?: boolean
/** 是否隐藏 */
hidden?: boolean
/** 图标 */
icon?: string
/** 元数据 */
meta?: string
/** id */
id: string
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 序号 */
serial?: number
/** 标识 */
uid: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 父级ID */
pid?: string
/** 重定向 */
redirect?: string
/** 序号 */
serial?: number
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 标识 */
uid: string
/** 组件 */
component?: string
/** 图标 */
icon?: string
/** 是否隐藏 */
hidden?: boolean
/** 是否启用 */
enable?: boolean
/** 父级ID */
pid?: string
/** 元数据 */
meta?: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -10,7 +10,7 @@ export class Params {
id: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -10,7 +10,7 @@ export class Params {
id: string
}
export const init = new defs.Result()
export const init = new defs.ResultPermissionVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,35 +6,35 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 组件 */
component?: string
/** 是否启用 */
enable?: boolean
/** 是否隐藏 */
hidden?: boolean
/** 图标 */
icon?: string
/** id */
id: string
/** 元数据 */
meta?: string
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 序号 */
serial?: number
/** 标识 */
uid: string
/** 名称 */
name: string
/** 路径 */
path?: string
/** 父级ID */
pid?: string
/** 重定向 */
redirect?: string
/** 序号 */
serial?: number
/** 权限类型 */
type: 'DIR' | 'MENU' | 'BUTTON'
/** 标识 */
uid: string
/** 组件 */
component?: string
/** 图标 */
icon?: string
/** 是否隐藏 */
hidden?: boolean
/** 是否启用 */
enable?: boolean
/** 父级ID */
pid?: string
/** 元数据 */
meta?: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,17 +6,17 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */
/** pageSize */
pageSize: number
/** pageNo */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC'
sortOrder?: string
}
export const init = new defs.Result()
export const init = new defs.ResultPageVoPermissionVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,10 +7,10 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {
/** pid */
pid?: string
pid: string
}
export const init = new defs.Result()
export const init = new defs.ResultArrayListPermissionVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,13 +6,15 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 名称 */
name: string
/** id */
id: string
/** 标识 */
uid: string
/** 名称 */
name: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -12,7 +12,7 @@ export class Params {
ids: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -10,7 +10,7 @@ export class Params {
ids: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -10,7 +10,7 @@ export class Params {
id: string
}
export const init = new defs.Result()
export const init = new defs.ResultRoleVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -8,13 +8,13 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {
/** id */
id: string
/** 名称 */
name: string
/** 标识 */
uid: string
/** 名称 */
name: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,17 +6,17 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */
/** pageSize */
pageSize: number
/** pageNo */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC'
sortOrder?: string
}
export const init = new defs.Result()
export const init = new defs.ResultPageVoRoleVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultArrayListRoleVo()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -12,7 +12,7 @@ export class Params {
ids: string
}
export const init = new defs.Result()
export const init = new defs.ResultString()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -6,17 +6,17 @@ import * as defs from '../../baseClass'
import { defHttp } from '/@/utils/http/axios'
export class Params {
/** 当前页数 */
pageNo: number
/** 分页条数 */
/** pageSize */
pageSize: number
/** pageNo */
pageNo: number
/** 排序字段 */
sortField?: string
/** 排序方向(ASC|DESC) */
sortOrder?: 'ASC' | 'DESC'
sortOrder?: string
}
export const init = new defs.Result()
export const init = new defs.ResultPageVoUserVo()
export function request(params: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultArrayListMenuVo()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultArrayListString()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
......@@ -7,7 +7,7 @@ import { defHttp } from '/@/utils/http/axios'
export class Params {}
export const init = new defs.Result()
export const init = new defs.ResultUserInfo()
export function request(params?: Params, config?: http.RequestConfig<Params>, options?: http.RequestOptions) {
return defHttp.request(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论