Skip to main content

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

  • 可以直接访问 swagger_url (http://ip:port/v2/api-doc) 不需要登录的,使用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 做得更好。

Metadata

Release files for swaggerjmx 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swaggerjmx 1.1.2
File Size Uploaded
swaggerjmx-1.1.2.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swaggerjmx 1.1.2
File Interpreter ABI Platform
swaggerjmx-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / swaggerjmx-1.1.2.tar.gz

Download URL swaggerjmx-1.1.2.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
57113b096cacb42f738e6103bcf5ba4d1f2b1c44d976f63aa2b163f5cea78cb4
BLAKE2b-256 checksum
How to use checksums
d72522eb04d6b6dad51259ad76980497a997361cac3a55dddf2a2ed4e59c7cff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / swaggerjmx-1.1.2-py3-none-any.whl

Download URL swaggerjmx-1.1.2-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eaf133495591033d5540975f2905e68733628532a19852fc89aa1a884aa3830c
BLAKE2b-256 checksum
How to use checksums
3f784f42095343cfa87885e6f1761e376e32cc97e28bf1d6ad8def416c4260f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page