dify/api/tests/unit_tests/controllers/openapi
GareArc f5c5dbaed5
feat(openapi): emit canonical ErrorBody on every /openapi/v1 error path
Install OpenApiErrorFormatter on the openapi blueprint's ExternalApi so
all non-2xx responses from /openapi/v1 carry the canonical ErrorBody shape
(code, message, status, optional details/hint). RFC 8628 device-flow
endpoints are unaffected — their flat {error: ...} shape is passed through
unchanged.

Also: set catch_all_404s=True when a formatter is present so unknown
routes return canonical JSON 404s (not Flask's default HTML 404).
Override _help_on_404 to suppress route suggestions, which would corrupt
the JSON contract and enumerate routes to unauthenticated callers.

Both behaviours are scoped by formatter presence — other blueprints that
construct ExternalApi without error_body_formatter are byte-identical.

Wire-level tests added to TestWireContract (3 tests, 18 total):
- 422 from @accepts validation carries code/status/details
- unknown-route 404 is canonical JSON without route suggestions
- device token POST returns RFC 8628 flat shape untouched by formatter
2026-06-10 02:48:38 -07:00
..
auth feat(api,cli): strict UUID validation for app-id and workspace-id (#37212) 2026-06-09 07:35:18 +00:00
__init__.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
conftest.py fix(api): enforce workspace membership + role checks in auth pipeline (#36931) 2026-06-03 07:31:47 +00:00
test_account.py feat(cli): adopt generated oRPC contract for unary endpoints (#37090) 2026-06-08 08:09:44 +00:00
test_app_describe_query.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_app_list_query.py feat(api,cli): strict UUID validation for app-id and workspace-id (#37212) 2026-06-09 07:35:18 +00:00
test_app_payloads.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_app_run_dispatch.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_app_run_streaming.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
test_apps_permitted_external_query.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_audit_app_run.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_contract.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
test_cors.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_device_approve_deny.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_device_code.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_device_lookup.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_device_sso.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_device_token.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_error_contract.py feat(openapi): emit canonical ErrorBody on every /openapi/v1 error path 2026-06-10 02:48:38 -07:00
test_health.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_human_input_form.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
test_input_schema.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_meta_version.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_models.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_oauth_sso_claims.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_oauth_sso_csrf.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_oauth_sso_host_header.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_pagination_envelope.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
test_workflow_events_openapi.py feat(openapi): redesign auth pipeline with per-token-type routing (#36693) 2026-05-27 12:45:30 +00:00
test_workspaces_members.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
test_workspaces.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00