JSPM

openapi3-typescript

0.0.2
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3
    • Score
      100M100P100Q23493F
    • License ISC

    openapi3 generate typescript types

    Package Exports

    • openapi3-typescript
    • openapi3-typescript/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openapi3-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    openapi协议解析

    通过解析远程或者本地的openapi的json文件信息,生成供接口使用的返回值ts类型 目前仅支持 openapi3协议 的 post请求解析

    export type Modal = {
      /**
       *
       */
      "post/user/updateById": {
        req: {
          /**
           * ID
           */
          id: number;
    
          /**
           * 用户名
           */
          name: string;
    
          /**
           * 年龄
           */
          age: number;
    
          /**
           * 性别 1:男  2:女
           */
          gender: number;
    
          /**
           * 头像
           */
          avatar: string;
    
          /**
           * 创建时间
           */
          createTime: string;
    
          /**
           * 修改时间
           */
          updateTime: string;
        };
        res: {
          /**
           *
           */
          code: number;
    
          /**
           *
           */
          msg: string;
    
          /**
           *
           */
          data: {
            /** ID */ id: number;
            /** 用户名 */ name: string;
            /** 年龄 */ age: number;
            /** 性别 1:男  2:女 */ gender: number;
            /** 头像 */ avatar: string;
            /** 创建时间 */ createTime: string;
            /** 修改时间 */ updateTime: string;
          };
        };
      }
    }
    

    安装

    pnpm i  openapi3-typescript -D

    生成

    远程openapi

    执行

    openapi3-typescript http://localhost:8080/v3/api-docs/default

    本地openapi

    openapi3-typescript openapi.json

    使用

    const result:Modal["post/user/updateById"]["res"]  = await axios.post("http://localhost:8080/user/updateById")
    

    更新日志

    0.0.1 发布使用