Summary : Swagger Codegen is an open source project for generating server stubs, client libraries, and API documentation from OpenAPI specification (formerly known as Swagger specification) files. It supports multiple programming languages and frameworks, including Python, Java, Ruby, Go, and more.
History Raiders:
unittest: parameterized ddt use cases
installation steps:
**1. **Make sure you have installed Java. You can check by typing java -version on the command line. If Java is not installed, please download and install Java JDK from Oracle official website.
**2. **Download the executable jar file of Swagger Codegen. You can download it from the releases page of Swagger Codegen's GitHub repository: https://github.com/swagger-api/swagger-codegen/releases, for this example we will use swagger-codegen-cli-3.0.29.jar. Please choose the appropriate version according to your needs.
**3.** Put the downloaded jar file in a location you like, for example: C:\swagger-codegen\swagger-codegen-cli.jar.
Open a command prompt, and generate code with the following command:
java -jar C:\swagger-codegen\swagger-codegen-cli.jar generate -i myapi.json -l python -o output
Where C:\swagger-codegen\swagger-codegen-cli.jar is the path to the jar file you just downloaded, myapi.json is your Swagger API definition file, python is the target language, and output is the output directory. myapi.json can use sanic_openapi in historical strategy - swagger
operation result:
Generated code : useless, just pass placeholder information
# coding: utf-8
"""
异步平台 API文档
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: v0.0.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import swagger_client
from swagger_client.api.default_api import DefaultApi # noqa: E501
from swagger_client.rest import ApiException
class TestDefaultApi(unittest.TestCase):
"""DefaultApi unit test stubs"""
def setUp(self):
self.api = DefaultApi() # noqa: E501
def tearDown(self):
pass
def test_get_get_class(self):
"""Test case for get_get_class
获取班级信息 # noqa: E501
"""
pass
def test_get_get_student(self):
"""Test case for get_get_student
获取学生信息 # noqa: E501
"""
pass
def test_post_add_student(self):
"""Test case for post_add_student
新增学生信息 # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()
Note : Please note that the generated test cases may need further optimization and modification to suit your specific needs and test scenarios. Swagger Codegen provides you with a basic test case template that you can extend and customize as needed.