npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

swaggerconvapi2

v1.0.19

Published

swaggerConvApi2 工厂化 新增配置项,配置文件 新增模板 独立函数解析封装,非开源项目,请见谅

Downloads

4

Readme

useNode

node ./index.cjs JSON config

installGlobalUse

swapi JSON config

swaggerConvApi2

-- 已完成 swaggerConvApi2 工厂化 新增配置项,配置文件 新增模板 独立函数解析封装 ts 迁移

-- 下次迭代 esbuild 打包支持 rollup-plugin-esbuild ts 打包支持 minimist 参数支持 prettier 格式化支持 更友好的错误提示

-- 下下次迭代 线上化


使用说明:需生成 dist 文件使用

源码 index.cjs 运行:

yarn 进行安装。

运行的完整命令

node index.cjs ./JSON/jwai.json ./config/jwai.json 【ps: node index.js {apiJSONPath} [{configJSONPath}]

安装方式运行:

1.组件方式运行: 现可以直接 yarn add swaggerconvapi2 进行安装.npx swapi JSON config 运行

MacOS:安装时文件夹必须含有 package.json,否则会在你的系统目录下生成 node_modules,安装到全局目录环境.
将所需的 JSON 与 config 文件放入该文件夹,执行命令即可。
例如:npx swapi ./JSON/jwai.json ./config/jwai.json

2.全局方式运行: 可进行全局安装 —— yarn global add swaggerconvapi2 执行此命令, 全局安装后,再进行 swapi ./JSON/jwai.json 即可。

【注:需有 config 文件夹,若无,则需指定路径即可如:wapi ./JSON/jwai.json xxx/xxx/config/jwai.json】

ConfigFile

输出用配置

outDir = 'dist'; //主要输出文件夹[string] outMode = 1; //1 单文件模式 single;2 多文件模式 mutile[number] mainPath = ''; //输出到的路径/目录[string] main = 'index'; //主要标志命名[string] paramsPath = ''; //type[params]路径/目录[string] paramsMain = ''; //type[params]文件名称前缀[string] modelPath = ''; //model[type]路径/目录[string] modelMain = ''; //model[type]路径文件名称[string]

基础配置

baseUrl = ''; //默认路径 baseUrlMode = 1; //1 忽略模式将会忽略 path 中的 baseUrl;2 统一添加模式将会统一添加 baseUrl

模板

_ paramsLocation //params 的位置不存在时不设置修改后改为特定的 option 值
_ bodyLocation // bodyLocation 不存在时会尝试清理{body},替换{body}
_ template //模板用字符串
_ 模板说明大括号连续将进行覆盖覆盖会进行替换覆盖完后不含大括号!!!
_ {apiKey} 工具名不是很重要
_ {name} 接口名位置 formatPath 格式化
_ {arg} 传参位置
_ {request} 返回类型位置
_ {protocol} 协议类型不是很重要
_ {path} 路径位置
_ {option} 扩展配置位置
_ {body} body 位置

topReference = TopReference; //文件顶部注入的字符串模板 getTemplate = GetTemplate; //get 协议的模板 postTemplate = PostTemplate; //post 协议的模板 putTemplate = PutTemplate; //put 协议的模板 deleteTemplate = DeleteTemplate; //del 协议的模板

钩子

formatPath = undefined; //格式化 api 路径 formatInterfaceName = undefined; //格式化接口名称

API 相关配置

ignoreParams = []; //需要忽略处理的字段列表 DefaultOption = {}; //API 对象默认的 options

特殊处理路径

bufferPath = []; //手动定义为 bufferRequest 的路径

API 解析相关

apiKey = 'api'; //api 的默认引用 version = '3'; //解析的 openApi 版本 tagsKey = 'tags'; //openapi 的 Tags 对象 key pathsKey = 'paths'; //openapi 的 PathsKey 对象 key classTypesPath = undefined; //openapi 的 ClassTypes 对象 key,api.components.schemas(v3)\api.definitions(v2)默认不传入自动识别 defaultResponseBody = 'form'; //默认主体类型 json(application/json)form(multipart/form-data)