Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,10 @@ Pass as first argument to generate only that SDK:
- **Silent no-op:** A new `.twig` file with no `getFiles()` entry — generation runs successfully but the file is never created
- **Wrong scope:** Using `default` scope when you need `service` scope means your template can't access `{{ service.name }}`
- **Copy scope surprises:** A `copy`-scoped file with Twig syntax — the syntax is output literally, not rendered
- **Spec fetch failure:** `example.php` requires internet access to fetch the live spec from GitHub; generation fails with an exception if the fetch returns empty. Spec URL pattern (prefix is `open-api3` or `swagger2` depending on the format):
- **Spec fetch failure:** `example.php` requires internet access to fetch the live spec from GitHub; generation fails with an exception if the fetch returns empty. OpenAPI 3 is one canonical document per version and the generator selects the platform from it (`x-appwrite.platforms`); Swagger 2 documents are still per platform:
```
https://raw.githubusercontent.com/appwrite/specs/main/specs/{version}/open-api3-{version}-{platform}.json
https://raw.githubusercontent.com/appwrite/specs/main/specs/{version}/open-api3-{version}.json
https://raw.githubusercontent.com/appwrite/specs/main/specs/{version}/swagger2-{version}-{platform}.json
```
- **Spec formats:** `example.php` parses every document through `Utopia\OpenAPI\Parser`. OpenAPI 3 is fetched by default; Swagger 2 is also supported. Pass the fetched format as the third argument:
```bash
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ use Appwrite\SDK\Language\PHP;
use Utopia\OpenAPI\Parser;

// Parse an OpenAPI 2, 3.0, or 3.1 document into the canonical specification model.
// One document covers every SDK platform; the SDK selects its own below.
$version = '2.0.x';
$platform = 'server';
$content = file_get_contents("https://raw.githubusercontent.com/appwrite/specs/main/specs/{$version}/open-api3-{$version}-{$platform}.json");
$content = file_get_contents("https://raw.githubusercontent.com/appwrite/specs/main/specs/{$version}/open-api3-{$version}.json");
Comment thread
ChiragAgg5k marked this conversation as resolved.
$spec = Parser::parse($content);

// Create language instance
Expand All @@ -61,6 +62,7 @@ $lang // Set language or platform specific options
$sdk = new SDK($lang, $spec);

$sdk
->setPlatform($platform) // Keep the operations, aliases and security schemes available to this platform
->setCoverImage('https://github.com/appwrite/appwrite/raw/main/public/images/github.png')
->setLicenseContent('License content here.')
->setVersion('v1.1.0')
Expand Down
6 changes: 4 additions & 2 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ function buildStaticSpecification(): Specification {
if ($specFile) {
$spec = file_get_contents($specFile);
} else {
$specPrefix = $specFormat === 'swagger2' ? 'swagger2' : 'open-api3';
$spec = getSSLPage(Config::SPECS_URL . "/{$version}/{$specPrefix}-{$version}-{$platform}.json");
// OpenAPI 3 ships one canonical document per version; the generator selects the platform from it.
$spec = getSSLPage($specFormat === 'swagger2'
? Config::SPECS_URL . "/{$version}/swagger2-{$version}-{$platform}.json"
: Config::SPECS_URL . "/{$version}/open-api3-{$version}.json");
}

if(empty($spec)) {
Expand Down
1 change: 1 addition & 0 deletions templates/rust/Cargo.toml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ indexmap = ">=2, <2.14"
url = ">=2.5.4, <2.6"
idna = ">=1.0.3, <1.2"
idna_adapter = ">=1.0.0, <1.1"
encoding_rs = ">=0.8.35, <0.8.40"
mime = "0.3.17"
fastrand = "=2.0.2"
thiserror = "1.0.69"
Expand Down
Loading