Introduction

DeepSeek Harness (DSH) follows the “everything is a plugin” philosophy and modularizes the development workflow. In API development and testing, manually writing repetitive interface test skeletons is often time-consuming and error-prone. The dsh-api-testgen plugin aims to solve this problem by parsing OpenAPI 3.x specifications and automatically generating test code skeletons that cover multiple exception scenarios, lowering the barrier to entry for API testing.

Plugin Overview

Name: dsh-api-testgen
Owner: uckkk
Purpose: Parse OpenAPI 3.x (JSON/YAML) and generate pytest/vitest API test skeletons covering success/missing-parameter/invalid-enum cases.
License: MIT

Core Features

  1. OpenAPI Parsing: Supports parsing JSON or YAML files in OpenAPI 3.x format.
  2. Test Case Generation: Automatically generates three types of test cases for each API endpoint:
    - Success cases (status code 2xx)
    - Missing parameter cases (covering all required path parameters being missing)
    - Invalid enum cases (covering invalid values for all enum parameters)
  3. Multi-language Support: Outputs Python (pytest + requests) or TypeScript (vitest + fetch) test files.
  4. Local Execution: Pure Node implementation, no network connection required, and no dependency on external services.

Installation and Enablement

Run the following command to install the plugin:

dsh plugin add github:uckkk/dsh-api-testgen

After installation, add the plugin to the dsh.profile.bundles configuration in the project’s package.json:

{
  "dsh": {
    "profile": {
      "bundles": [
        "dsh-api-testgen"
      ]
    }
  }
}

Usage Examples

After successful installation, call the gen_tests tool in a DSH session.

Generate a Python test skeleton:

gen_tests(spec='openapi.yaml', lang='python')

Generate a TypeScript test skeleton:

gen_tests(spec='openapi.yaml', lang='typescript', outDir='./src/__tests__')

Applicable Scenarios and Considerations

Applicable Scenarios:
- You need to quickly build an automated API testing system.
- You already have an OpenAPI specification document and want to reduce repetitive test code writing.

Considerations:
1. Skeleton nature: Generated test cases only include status code assertions; specific business logic assertions need to be added as needed.
2. Environment configuration: Before running tests, manually update BASE_URL in the generated test files to the actual service address.
3. Ecosystem integration: It can be used together with dsh-api-contract (client) and dsh-api-mock (Mock server) to form an API development trio.
4. Code audit: Installation runs third-party code locally; please review the source code and license yourself.

Summary

dsh-api-testgen provides a standardized skeleton generation solution for API testing. By parsing OpenAPI specifications, it quickly produces code frameworks that meet test coverage requirements, helping developers focus on validating business logic.