From 0848175951aa1c837d861c5347ba1deaadf16894 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 9 Jun 2026 18:52:25 +0530 Subject: [PATCH] Add project path auth scheme to specs (#12554) --- src/Appwrite/Platform/Tasks/Specs.php | 18 ++++++++-- .../SDK/Specification/Format/OpenAPI3.php | 36 ++++++++----------- .../SDK/Specification/Format/Swagger2.php | 36 ++++++++----------- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 8717ae742e..4db9e99e58 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -139,11 +139,15 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], - 'ProjectQuery' => [ + 'ProjectPath' => [ 'type' => 'apiKey', 'name' => 'project', 'description' => 'Your project ID', 'in' => 'query', + 'x-appwrite' => [ + 'location' => 'path', + 'param' => 'project_id', + ], ], 'JWT' => [ 'type' => 'apiKey', @@ -201,11 +205,15 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], - 'ProjectQuery' => [ + 'ProjectPath' => [ 'type' => 'apiKey', 'name' => 'project', 'description' => 'Your project ID', 'in' => 'query', + 'x-appwrite' => [ + 'location' => 'path', + 'param' => 'project_id', + ], ], 'Key' => [ 'type' => 'apiKey', @@ -275,11 +283,15 @@ class Specs extends Action 'description' => 'Your project ID', 'in' => 'header', ], - 'ProjectQuery' => [ + 'ProjectPath' => [ 'type' => 'apiKey', 'name' => 'project', 'description' => 'Your project ID', 'in' => 'query', + 'x-appwrite' => [ + 'location' => 'path', + 'param' => 'project_id', + ], ], 'Key' => [ 'type' => 'apiKey', diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 670f9f9f5f..8b36c45176 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -81,28 +81,20 @@ class OpenAPI3 extends Format ], ]; - if (isset($output['components']['securitySchemes']['Project'])) { - $output['components']['securitySchemes']['Project']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['components']['securitySchemes']['ProjectQuery'])) { - $output['components']['securitySchemes']['ProjectQuery']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['components']['securitySchemes']['Key'])) { - $output['components']['securitySchemes']['Key']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['components']['securitySchemes']['JWT'])) { - $output['components']['securitySchemes']['JWT']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['components']['securitySchemes']['Locale'])) { - $output['components']['securitySchemes']['Locale']['x-appwrite'] = ['demo' => 'en']; - } - - if (isset($output['components']['securitySchemes']['Mode'])) { - $output['components']['securitySchemes']['Mode']['x-appwrite'] = ['demo' => '']; + foreach ([ + 'Project' => '', + 'ProjectPath' => '', + 'Key' => '', + 'JWT' => '', + 'Locale' => 'en', + 'Mode' => '', + ] as $key => $demo) { + if (isset($output['components']['securitySchemes'][$key])) { + $output['components']['securitySchemes'][$key]['x-appwrite'] = \array_merge( + $output['components']['securitySchemes'][$key]['x-appwrite'] ?? [], + ['demo' => $demo] + ); + } } $usedModels = []; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index e5f240dde3..7b4c6791c1 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -70,28 +70,20 @@ class Swagger2 extends Format ], ]; - if (isset($output['securityDefinitions']['Project'])) { - $output['securityDefinitions']['Project']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['securityDefinitions']['ProjectQuery'])) { - $output['securityDefinitions']['ProjectQuery']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['securityDefinitions']['Key'])) { - $output['securityDefinitions']['Key']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['securityDefinitions']['JWT'])) { - $output['securityDefinitions']['JWT']['x-appwrite'] = ['demo' => '']; - } - - if (isset($output['securityDefinitions']['Locale'])) { - $output['securityDefinitions']['Locale']['x-appwrite'] = ['demo' => 'en']; - } - - if (isset($output['securityDefinitions']['Mode'])) { - $output['securityDefinitions']['Mode']['x-appwrite'] = ['demo' => '']; + foreach ([ + 'Project' => '', + 'ProjectPath' => '', + 'Key' => '', + 'JWT' => '', + 'Locale' => 'en', + 'Mode' => '', + ] as $key => $demo) { + if (isset($output['securityDefinitions'][$key])) { + $output['securityDefinitions'][$key]['x-appwrite'] = \array_merge( + $output['securityDefinitions'][$key]['x-appwrite'] ?? [], + ['demo' => $demo] + ); + } } $usedModels = [];