Skip to content

chore: unify api && clean some type ignore#35984

Merged
asukaminato0721 merged 4 commits into
langgenius:mainfrom
asukaminato0721:api-type
May 10, 2026
Merged

chore: unify api && clean some type ignore#35984
asukaminato0721 merged 4 commits into
langgenius:mainfrom
asukaminato0721:api-type

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Copilot AI review requested due to automatic review settings May 9, 2026 18:02
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels May 9, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge May 9, 2026 18:02
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 43.68% +43.68%
Strict coverage 0.00% 43.20% +43.20%
Typed symbols 0 21,954 +21,954
Untyped symbols 0 28,623 +28,623
Modules 0 2547 +2,547

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes how Pydantic models/enums are registered into Flask-RESTX namespaces for Swagger/OpenAPI generation, and removes a number of # type: ignore suppressions around query parsing/validation in API controllers.

Changes:

  • Replaced repeated per-file schema_model(...model_json_schema(ref_template=...)) blocks with shared helpers (register_schema_models, register_enum_models).
  • Removed duplicated DEFAULT_REF_TEMPLATE_SWAGGER_2_0 constants from many controllers.
  • Cleaned up request arg parsing by removing unnecessary # type: ignore on model_validate(request.args.to_dict(...)).

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 31 comments.

Show a summary per file
File Description
api/controllers/service_api/dataset/document.py Removes redundant Swagger ref-template constant.
api/controllers/service_api/dataset/dataset.py Switches enum schema registration to register_enum_models.
api/controllers/files/upload.py Uses shared schema-registration helper; removes type-ignore on query validation.
api/controllers/files/tool_files.py Uses register_schema_models for query model registration.
api/controllers/files/image_preview.py Uses register_schema_models; removes type-ignores on query validation.
api/controllers/console/workspace/workspace.py Replaces local schema registration helper with register_schema_models.
api/controllers/console/workspace/plugin.py Removes type-ignores on query validation.
api/controllers/console/workspace/models.py Consolidates schema registrations; removes type-ignores on query validation.
api/controllers/console/workspace/model_providers.py Replaces local schema registration helper with register_schema_models.
api/controllers/console/workspace/members.py Consolidates payload schema registrations and enum registration.
api/controllers/console/workspace/endpoint.py Uses register_schema_models; removes legacy per-model registration helper.
api/controllers/console/workspace/account.py Consolidates schema registrations; removes type-ignore on query validation.
api/controllers/console/extension.py Removes type-ignore on query validation.
api/controllers/console/explore/trial.py Uses register_schema_models for request model docs.
api/controllers/console/explore/recommended_app.py Removes type-ignore on query validation.
api/controllers/console/datasets/rag_pipeline/datasource_content_preview.py Uses register_schema_models for payload docs.
api/controllers/console/auth/login.py Uses register_schema_models for auth payload docs.
api/controllers/console/auth/forgot_password.py Removes redundant Swagger ref-template constant.
api/controllers/console/auth/email_register.py Uses register_schema_models for register payload docs.
api/controllers/console/auth/data_source_bearer_auth.py Uses register_schema_models for payload docs.
api/controllers/console/auth/activate.py Removes type-ignore on query validation.
api/controllers/console/app/workflow.py Removes redundant Swagger ref-template constant; removes type-ignore on query validation.
api/controllers/console/app/workflow_trigger.py Removes type-ignore on query validation.
api/controllers/console/app/workflow_statistic.py Uses register_schema_models; removes type-ignores on query validation.
api/controllers/console/app/workflow_run.py Removes type-ignores on query validation.
api/controllers/console/app/workflow_draft_variable.py Uses register_schema_models; removes type-ignore on query validation.
api/controllers/console/app/workflow_comment.py Consolidates schema registration into register_schema_models.
api/controllers/console/app/workflow_app_log.py Removes type-ignores on query validation.
api/controllers/console/app/statistic.py Uses register_schema_models; removes type-ignores on query validation.
api/controllers/console/app/ops_trace.py Uses register_schema_models; removes type-ignores on query validation.
api/controllers/console/app/conversation.py Uses register_schema_models; removes duplicated legacy schema_model blocks.
api/controllers/console/app/conversation_variables.py Removes type-ignore on query validation.
api/controllers/console/app/completion.py Uses register_schema_models for request model docs.
api/controllers/console/app/audio.py Removes type-ignore on query validation.
api/controllers/console/app/app.py Removes type-ignore on query validation.
api/controllers/console/app/annotation.py Consolidates schema registration into register_schema_models.
api/controllers/console/app/agent.py Uses register_schema_models; removes type-ignore on query validation.
api/controllers/console/app/advanced_prompt_template.py Removes type-ignore on query validation.
api/controllers/console/admin.py Uses register_schema_models for admin payload docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/controllers/console/workspace/workspace.py Outdated
Comment thread api/controllers/console/workspace/model_providers.py Outdated
Comment thread api/controllers/console/explore/trial.py Outdated
Comment thread api/controllers/files/image_preview.py Outdated
Comment thread api/controllers/files/tool_files.py Outdated
Comment thread api/controllers/files/image_preview.py Outdated
Comment thread api/controllers/files/tool_files.py
Comment thread api/controllers/console/datasets/rag_pipeline/datasource_content_preview.py Outdated
Comment thread api/controllers/console/explore/trial.py
Comment thread api/controllers/service_api/dataset/dataset.py Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-09 18:37:42.662560535 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-09 18:37:31.133512006 +0000
@@ -7,7 +7,7 @@
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]
    --> controllers/console/app/app.py:574:13
 ERROR Argument `str | None` is not assignable to parameter `language` with type `str` in function `services.account_service.AccountService.send_email_register_email` [bad-argument-type]
-  --> controllers/console/auth/email_register.py:75:108
+  --> controllers/console/auth/email_register.py:73:108
 ERROR Object of class `MissingRouter` has no attribute `get` [missing-attribute]
   --> controllers/console/init_validate.py:31:2
 ERROR Object of class `MissingRouter` has no attribute `post` [missing-attribute]

@asukaminato0721 asukaminato0721 added this pull request to the merge queue May 10, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 10, 2026
Merged via the queue into langgenius:main with commit c67ce6f May 10, 2026
27 checks passed
@asukaminato0721 asukaminato0721 deleted the api-type branch May 10, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants