Add query project auth scheme to specs (#12481)

This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-06-03 16:16:34 +05:30
1 parent 3006c98646
commit c4bdc0f9f0
4 files changed
+42 -5

No files matched your search

+18
View File
@@ -139,6 +139,12 @@ class Specs extends Action
'description' => 'Your project ID',
'in' => 'header',
],
'ProjectQuery' => [
'type' => 'apiKey',
'name' => 'project',
'description' => 'Your project ID',
'in' => 'query',
],
'JWT' => [
'type' => 'apiKey',
'name' => 'X-Appwrite-JWT',
@@ -195,6 +201,12 @@ class Specs extends Action
'description' => 'Your project ID',
'in' => 'header',
],
'ProjectQuery' => [
'type' => 'apiKey',
'name' => 'project',
'description' => 'Your project ID',
'in' => 'query',
],
'Key' => [
'type' => 'apiKey',
'name' => 'X-Appwrite-Key',
@@ -263,6 +275,12 @@ class Specs extends Action
'description' => 'Your project ID',
'in' => 'header',
],
'ProjectQuery' => [
'type' => 'apiKey',
'name' => 'project',
'description' => 'Your project ID',
'in' => 'query',
],
'Key' => [
'type' => 'apiKey',
'name' => 'X-Appwrite-Key',
+12 -1
View File
@@ -32,6 +32,7 @@ class Method
* @param array $additionalParameters
* @param string $desc
* @param bool $public Whether this method should be rendered on the website/documentation
* @param string $projectAuth Project authentication security scheme to use in specs
*/
public function __construct(
protected string $namespace,
@@ -49,12 +50,17 @@ class Method
protected array $parameters = [],
protected array $additionalParameters = [],
protected string $desc = '',
protected bool $public = true
protected bool $public = true,
protected string $projectAuth = 'Project'
) {
$this->validateMethod($name, $namespace);
$this->validateAuthTypes($auth);
$this->validateDesc($description);
if (!\in_array($projectAuth, ['Project', 'ProjectQuery'], true)) {
self::$errors[] = "Error with {$this->getRouteName()} method: Invalid project auth scheme";
}
foreach ($responses as $response) {
$this->validateResponseModel($response->getModel());
$this->validateNoContent($response);
@@ -223,6 +229,11 @@ class Method
return $this->additionalParameters;
}
public function getProjectAuth(): string
{
return $this->projectAuth;
}
public function setNamespace(string $namespace): self
{
$this->namespace = $namespace;
@@ -85,6 +85,10 @@ class OpenAPI3 extends Format
$output['components']['securitySchemes']['Project']['x-appwrite'] = ['demo' => '<YOUR_PROJECT_ID>'];
}
if (isset($output['components']['securitySchemes']['ProjectQuery'])) {
$output['components']['securitySchemes']['ProjectQuery']['x-appwrite'] = ['demo' => '<YOUR_PROJECT_ID>'];
}
if (isset($output['components']['securitySchemes']['Key'])) {
$output['components']['securitySchemes']['Key']['x-appwrite'] = ['demo' => '<YOUR_API_KEY>'];
}
@@ -184,7 +188,7 @@ class OpenAPI3 extends Format
continue;
}
$methodSecurities = ['Project' => []];
$methodSecurities = [$methodObj->getProjectAuth() => []];
foreach ($methodObj->getAuth() as $security) {
if (\array_key_exists($security->value, $this->keys)) {
$methodSecurities[$security->value] = [];
@@ -370,7 +374,7 @@ class OpenAPI3 extends Format
}
if (!empty($scope)) {
$securities = ['Project' => []];
$securities = [$sdk->getProjectAuth() => []];
foreach ($sdk->getAuth() as $security) {
/** @var AuthType $security */
@@ -74,6 +74,10 @@ class Swagger2 extends Format
$output['securityDefinitions']['Project']['x-appwrite'] = ['demo' => '<YOUR_PROJECT_ID>'];
}
if (isset($output['securityDefinitions']['ProjectQuery'])) {
$output['securityDefinitions']['ProjectQuery']['x-appwrite'] = ['demo' => '<YOUR_PROJECT_ID>'];
}
if (isset($output['securityDefinitions']['Key'])) {
$output['securityDefinitions']['Key']['x-appwrite'] = ['demo' => '<YOUR_API_KEY>'];
}
@@ -184,7 +188,7 @@ class Swagger2 extends Format
continue;
}
$methodSecurities = ['Project' => []];
$methodSecurities = [$methodObj->getProjectAuth() => []];
foreach ($methodObj->getAuth() as $security) {
/** @var AuthType $security */
if (\array_key_exists($security->value, $this->keys)) {
@@ -361,7 +365,7 @@ class Swagger2 extends Format
}
if (!empty($scope)) {
$securities = ['Project' => []];
$securities = [$sdk->getProjectAuth() => []];
foreach ($sdk->getAuth() as $security) {
if (\array_key_exists($security->value, $this->keys)) {