Skip to content

[1.26.x] feat(dashboard): modernize OpenAPI SDK generation - #2989

Draft
wklken wants to merge 58 commits into
TencentBlueKing:masterfrom
wklken:feat/openapi-sdk-generation
Draft

[1.26.x] feat(dashboard): modernize OpenAPI SDK generation#2989
wklken wants to merge 58 commits into
TencentBlueKing:masterfrom
wklken:feat/openapi-sdk-generation

Conversation

@wklken

@wklken wklken commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

for 1.26.x; with delete the whole esb from codebase

Description

Replace the preset SDK templates with asynchronous, database-backed OpenAPI Generator tasks for Python, Java, Go, and JavaScript (TypeScript Fetch client).

Generated packages are always stored in BKRepo Generic. Python can additionally publish to PyPI and Java to Maven when their repositories are configured. Generation and native publication have independent retries; native publication reuses the built package identity saved with the task.

A dedicated SDK worker image contains the pinned toolchains. JavaScript builds install from the checked-in dependency lock using npm ci. Django uses one set of SDK settings, and download responses share a consistent Generic artifact selection rule.

Compatibility notes

  • V1 generate retains HTTP 200 with data: [].
  • The legacy V2 generate endpoint retains HTTP 201 with data: [].
  • New V2 task and Web creation endpoints return HTTP 202 with a queryable task identity/status URL.
  • Legacy version input remains accepted; package versions derive from the resource version.
  • golang remains accepted at API and deployment environment boundaries and is normalized to go.
  • Legacy generation endpoints remain no-ops when SDK generation is disabled; Web/new task endpoints report unavailable. SDK cleanup also skips when generation is disabled.

Verification

  • Focused SDK/config/API suite: 408 passed.
  • Dashboard lint-check passed.
  • Pinned OpenAPI Generator -> JavaScript npm ci (TypeScript 5.9.3) -> build/package -> installed consumer passed.
  • Dashboard uv run make test during SDK remediation: 4231 passed (the local checkout also contained unrelated existing tests).
  • Final uv run make lint-check and git diff --check passed.
  • Frontend polling regression: 12 cases passed, including generation failure, native publication, mixed rows, and unmount.
  • Targeted frontend ESLint and pnpm build-only passed (existing bundle-size warnings).

The related Helm chart work is on feat/apigateway-sdk-worker-1.23 from bk-apigateway-1.23.x: https://git.woa.com/blueking/helm-charts/-/merge_requests/new?merge_request%5Bsource_branch%5D=feat%2Fapigateway-sdk-worker-1.23

Checklist

  • 填写 PR 描述及相关 issue (write PR description and related issue)
  • 代码风格检查通过 (code style check passed)
  • PR 中包含单元测试 (include unit test)
  • 单元测试通过 (unit test passed)
  • 本地开发联调环境验证通过 (local development environment verification passed)

wklken

This comment was marked as outdated.

@wklken
wklken marked this pull request as draft July 13, 2026 01:50
@tencentblueking-adm

tencentblueking-adm commented Jul 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

wklken added 11 commits August 31, 2026 13:12
Why this change was needed:
PR TencentBlueKing#2989 conflicted with the current master branch after the v2 sync API, configuration, and contract tests evolved.

What changed:
- merged upstream/master into feat/openapi-sdk-generation
- preserved the asynchronous SDK generation 202 response contract
- retained master Celery, configuration, API, and test changes
- kept superseded legacy SDK generators and templates deleted

Problem solved:
The PR branch now contains the current master history with all textual and semantic conflicts resolved and verified.
Why this change was needed:
The asynchronous SDK generation APIs did not expose a reliable task lifecycle, and retry, lease, legacy artifact, and native publishing edge cases could produce misleading states or unusable artifact links.

What changed:
- align the frontend and public APIs around observable generation tasks
- harden task status, lease renewal, retry, artifact selection, and publishing recovery
- synchronize OpenAPI definitions and docs with regression coverage

Problem solved:
SDK generation now reports terminal outcomes accurately, preserves compatibility, and recovers safely from partial publication and worker ownership changes.
…generation

# Conflicts:
#	src/dashboard/apigateway/apigateway/tests/conf/test_utils.py
Ignore legacy SDK records in the usage-example endpoint so obsolete clients are not documented with the new OpenAPI Generator API.

Render Java imports from the generated invoker package, and render Go imports with the persisted module path and package name. Add bilingual regression coverage for the corrected examples.
Why this change was needed:
PR review found retry corruption, task-state races, unbounded polling,
and repository credential handling gaps in the new SDK pipeline.

What changed:
- isolate each request and its Generic artifact ownership
- guard lifecycle recovery, cleanup, and repository credentials
- preserve API aliases and document the asynchronous V1 contract
- bound frontend polling and handle usable partial results
- add focused regression coverage for the reviewed failure paths

Problem solved:
SDK generation retries no longer contaminate other requests, deployment
configuration failures are classified correctly, and clients receive a
bounded, compatible generation flow.
Use SDK_GENERATION_ENABLED as the single source for the existing frontend SDK flags. Remove the obsolete Python SDK quota and unused log-size setting, with regression coverage for legacy environment variables.
Prevent stale item writes and inconsistent lock ordering, validate legacy
SDK resource-version ownership, support native publication retries, and
map legacy V2 validation failures correctly.
Use ENABLE_SDK as the only frontend SDK capability flag and remove the obsolete ALLOW_UPLOAD_SDK_TO_REPOSITORY response field, type, defaults, and consumers.
Why this change was needed:
Internal superpowers design artifacts should not be included in the repository or pull request.

What changed:
- Removed the OAS3 resource documentation renderer design file from docs/superpowers

Problem solved:
The implementation remains in the branch without publishing internal planning material.
Comment thread src/dashboard/apigateway/apigateway/apis/open/support/views.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apis/v2/sync/serializers.py
Comment thread src/dashboard/apigateway/apigateway/apis/web/sdk/serializers.py Outdated
Comment thread src/dashboard/apigateway/apigateway/data/apidocs/zh/v2_sync_generate_sdk.md Outdated
Comment thread src/dashboard/apigateway/apigateway/biz/sdk/builders/common.py
Comment thread src/dashboard/apigateway/apigateway/apps/support/models.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apps/support/models.py
Comment thread src/dashboard/apigateway/apigateway/apps/support/models.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apis/web/sdk/views.py Outdated
Why this change was needed:
The SDK worker deployment guide should not be maintained in this repository.

What changed:
- Removed src/dashboard/docs/sdk-worker-deployment.md
- Kept the standalone image smoke gate because it validates generated SDK artifacts across all supported languages

Problem solved:
The pull request no longer publishes deployment documentation while retaining useful image-level validation.
Harden the asynchronous SDK generation workflow after PR review while preserving the legacy V2 response contract.

Unify language handling, centralize serialization, remove model-layer business validation, constrain subprocess execution, simplify fixed worker configuration, and keep the worker image non-root. Update focused tests and SDK smoke coverage accordingly.
Disable generated placeholder tests and share the production generator with
the worker smoke check. Infer missing path parameters and avoid live backend
lookups for historical SDK exports.

Preserve adopted legacy SDK metadata, include the private PyPI index in
installation commands, and use versioned Go module paths for major releases.
Comment thread src/dashboard/apigateway/apigateway/apis/fields.py
Comment thread src/dashboard/apigateway/apigateway/conf/default.py Outdated
Keep package identity and native publication choices stable across queued tasks.
Accept legacy golang configuration, skip cleanup when disabled, and lock JavaScript builds with npm ci.

Centralize artifact selection and retry state updates, remove redundant configuration forwarding, and apply SDK field and setting review renames.
@wklken wklken changed the title feat(dashboard): modernize OpenAPI SDK generation [1.26.x] feat(dashboard): modernize OpenAPI SDK generation Sep 8, 2026
wklken and others added 2 commits September 8, 2026 14:48
Escape OpenAPI prose in resource docs, strip descriptions before code generation, compile Go SDKs with go build, and redact local paths from worker errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/dashboard/apigateway/apigateway/apis/open/support/serializers.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apis/open/support/views.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apis/v2/sync/serializers.py Outdated
Comment thread src/dashboard/apigateway/apigateway/apps/support/constants.py
wklken and others added 2 commits September 8, 2026 17:52
Import and SDK generation now share a visited-set $ref scan, so YAML aliases
cannot hang the checker and remote refs cannot reach the validator.
Dashboard docs also drop <style> bodies that the XSS filter previously kept.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants