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

bd-port

v1.1.2

Published

北斗Swagger文档自动生成接口文档

Downloads

5

Readme

描述

基于北斗 Swagger 生成的 json 文件生成 TS 语言的 Api 脚本

依赖

  • Axios
  • md5
  • prettier

Install

npm install bd-port

or

yarn add bd-port

Usage

//执行
npx port
//会在项目根目录生成create-bd-api.js
//可以自由配置一些生成相关内容

create-bd-api.js 配置项

具体配置项介绍如下:

| 参数 | 值类型 | 描述 | 默认值 | | ---------------- | -------- | ----------------------------------------------- | ---------------- | | outputDir | string | 生成代码的存放路径 | /src/client | | enumSign | string | 用什么标记改类型是枚举 | enum | | enumIsUnify | boolean | 枚举是否统一存放 | true | | baseUrl | string | Swagger 请求地址 | localhost:3000 | | list | string[] | Swagger 请求地址。最终的 url 是 baseUrl+list[i] | [] | | cache | boolean | 是否缓存,true 会生成 port.lock.json | false | | version | string | Swagger 版本 V2/V3 | V2 | | platform | string | 目标平台 PC或者App或者WeChat | ToB/PC | | prettierUrl | string | 生成文件格式化规则 | /.prettierrc.yml | | GenerateClass | class | 自定义 Code 生成器 | 脚本生成 |

GenerateClass 配置项

具体配置项介绍如下:

apiTemplate

描述:生成单个 Api 文件的模板

| 参数 | 描述 | | ------------- | ------------------- | | api | 接口信息 | | usedModel? | 接口依赖模型 | | usedEnum? | 接口依赖枚举 | | moduleName? | 当前 Api 所在模块名 | | swaggerjson? | Swagger 全部信息 |

apiIndexFile

描述:生成模块 Api 主入口

| 参数 | 描述 | | ------------ | ------------ | | apis | 所有接口信息 | | moduleName? | 模块名 | | usedModel? | 依赖模型 | | usedEnum? | 依赖枚举 |

getRequest

描述:生成单个 Api 文件的模板中的 Request

| 参数 | 描述 | | ------- | --------------------- | | request | 当前接口 Request 信息 |

transformData

描述:生成单个 Api 文件的模板中的 Params

| 参数 | 描述 | | ---- | -------- | | api | 接口信息 |

aliasModelName

描述:type 和 menu 的重命名

| 参数 | 描述 | | ---- | ----------------------- | | name | type 或 menu 的原始名称 |