Gathering detailed insights and metrics for @1szx1/vite-plugin-swagger2ts
Gathering detailed insights and metrics for @1szx1/vite-plugin-swagger2ts
npm install @1szx1/vite-plugin-swagger2ts
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
7,196
Last Day
7
Last Week
72
Last Month
161
Last Year
2,185
1 Stars
44 Commits
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.3.20
Package Id
@1szx1/vite-plugin-swagger2ts@1.3.20
Unpacked Size
49.61 kB
Size
9.27 kB
File Count
18
NPM Version
10.1.0
Node Version
20.9.0
Publised On
16 Oct 2024
Cumulative downloads
Total Downloads
Last day
0%
7
Compared to previous day
Last week
414.3%
72
Compared to previous week
Last month
61%
161
Compared to previous month
Last year
-56.4%
2,185
Compared to previous year
3
20
1# npm i vite-plugin-swagger2ts -D 2# or 3# yarn add vite-plugin-swagger2ts -D 4# or 5pnpm add vite-plugin-swagger2ts -D
vite.config.ts
1// vite.config.ts 2import ViteSwagger2ts from "vite-plugin-swagger2ts"; 3 4export default { 5 plugins: [ 6 ViteSwagger2ts({ 7 swaggerUrl: "url", // swagger-resources URL 8 output: "pathToSave", // not require, default './src/swagger.ts' 9 formatSchema: (schema) => { 10 // not require, deal with schema. such as unwrapper common response 11 if ("properties" in schema) { 12 const properties = schema["properties"]; 13 if ("code" in properties && ("msg" in properties || "message" in properties) && "data" in properties) { 14 return properties["data"]; 15 } 16 } 17 return schema; 18 } 19 }) 20 ] 21};
${baseUrl}/swagger-resources
地址,获取微服务的 resources 地址;1interface SwaggerInterface { 2 // SwaggerInterface start 3 url: { 4 get: { 5 param: { path: { id: string }; query: { status: number }; body: { name: string } }; 6 reponse: { id: string; name: string; status: number }; 7 }; 8 }; 9}
1import { PathsSwaggerInterface } from "./swagger.ts"; 2 3export type UrlKey = keyof PathsSwaggerInterface; 4export type MethodKey<U extends UrlKey> = string & keyof PathsSwaggerInterface[U]; 5 6type SwaggerInterfaceSingle<U extends UrlKey, M extends MethodKey<U>> = PathsSwaggerInterface[U][M]; 7type SwaggerField<U extends UrlKey, M extends MethodKey<U>> = keyof SwaggerInterfaceSingle<U, M>; 8type SwaggerFieldType<U extends UrlKey, M extends MethodKey<U>, F extends SwaggerField<U, M>> = SwaggerInterfaceSingle<U, M>[F]; 9 10export type Param<U extends UrlKey, M extends MethodKey<U>> = SwaggerFieldType<U, M, "param" & SwaggerField<U, M>>; 11export type Response<U extends UrlKey, M extends MethodKey<U>> = SwaggerFieldType<U, M, "response" & SwaggerField<U, M>>;
1import type { PathKey, MethodKey, Param, Respone } from "configfile"; 2 3export function customFetch<P extends PathKey, M extends MethodKey<P>>(path: P, method: M, params: Param<P, M>): Promise<Respone<P, M>> { 4 // custome code 5 return "" as any; 6}
customFetch
进行使用MIT License © 2021 morelearn1990
No vulnerabilities found.
No security vulnerabilities found.