Skip to main content

swagger convert jmx

Project description

swaggerjmx

codecov PyPI PyPI - Python Version GitHub top language Downloads GitHub stars https://blog.csdn.net/flower_drop

English Document

Logo

logo

安装

pip install -U swaggerjmx

仓库地址

社区地址

适用场景

  1. 由于接口测试脚本编写耗时,而且需要持续维护,耗时耗力,使用此工具可以一键生成接口测试脚本。
  2. swagger-ui接口文档一键生成jmx文件供jmeter使用。
  3. yapi接口文档一键生成jmx文件供jmeter使用。

功能

  1. 将swagger-ui文档转换为jmx文件。
  2. 将yapi文档转换为jmx文件。

代码方式

Demo_1

# -*- coding: utf-8 -*-

from swaggerjmx.convert import conversion
from swaggerjmx.settings import Settings as ST
#  swagger_url
ST.swagger_url = 'http://ip:port/v2/api-docs'
#  report_path
ST.report_path = 'jmx'
# 开始转换
conversion()

Demo_2

  • 需要登录才能访问的,可以复制swagger_url页面上的json信息,保存json文件,使用Demo_2方式转换
# -*- coding: utf-8 -*-

from swaggerjmx.convert import conversion
from swaggerjmx.settings import Settings as ST
#  swagger_url_json_path 
ST.swagger_url_json_path = 'test.json'
#  report_path
ST.report_path = 'jmx'
# 开始转换
conversion()

命令行方式

预置参数

(venv) lijiawei@bogon swaggerjmx % swaggerjmx -h
usage: swaggerjmx [-h] -i INPUT [-o OUTPUT]

Swagger or YApi convert jmx tool! Created: Lijiawei. Version 1.1.0

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        The input swagger json file or swagger url.
  -o OUTPUT, --output OUTPUT
                        The output jmx file path(default jmx). If it exists, new endpoints will be overwrite.

使用方式

swaggerjmx -i <path_to_swagger_json_or_swagger_url> -o <path_to_output_jmx>

swagger json example

swaggerjmx -i tests/data/swagger.json -o jmx

swagger url example

swaggerjmx -i https://ip:port/v2/api-docs -o jmx

截图:

  1. 传入红框中的swagger-ui 地址

image

  1. 生成的jmx文件

image

  1. jmeter中显示

image

趋势图

Stargazers over time

Contributors

贡献

git clone git@github.com:Pactortester/swaggerjmx.git
cd swaggerjmx
pip install -e .

以上便是 swaggerjmx 的基本用法介绍。

如果您有发现错误,或者您对 swaggerjmx 有任何建议,欢迎到 swaggerjmx Issues 发表,非常感谢您的支持。您的反馈和建议非常宝贵,希望您的参与能帮助 swaggerjmx 做得更好。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swaggerjmx-1.1.1.tar.gz (10.1 kB view hashes)

Uploaded Source

Built Distribution

swaggerjmx-1.1.1-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page