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
2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function getSSLPage($url) {
$platform = 'console';
// $platform = 'server';

$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/1.7.x/app/config/specs/swagger2-latest-{$platform}.json");
$spec = getSSLPage("https://raw.githubusercontent.com/appwrite/appwrite/1.6.x/app/config/specs/swagger2-latest-{$platform}.json");

if(empty($spec)) {
throw new Exception('Failed to fetch spec from Appwrite server');
Expand Down
1 change: 1 addition & 0 deletions src/SDK/SDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ public function generate(string $target): void
'namespace' => $this->spec->getNamespace(),
'version' => $this->spec->getVersion(),
'endpoint' => $this->spec->getEndpoint(),
'endpointDocs' => $this->spec->getEndpointDocs(),
'host' => parse_url($this->spec->getEndpoint(), PHP_URL_HOST),
'basePath' => $this->spec->getAttribute('basePath', ''),
'licenseName' => $this->spec->getLicenseName(),
Expand Down
5 changes: 5 additions & 0 deletions src/Spec/Spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ abstract public function getVersion();
*/
abstract public function getEndpoint();

/**
* @return string
*/
abstract public function getEndpointDocs();

/**
* @return string
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Spec/Swagger2.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public function getEndpoint()
$this->getAttribute('basePath', '');
}

/**
* @return string
*/
public function getEndpointDocs()
{
return $this->getAttribute('schemes.0', 'https') .
'://' . $this->getAttribute('x-host-docs', 'example.com') .
$this->getAttribute('basePath', '');
}

/**
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion templates/android/docs/java/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }};

Client client = new Client(context)
{%~ if method.auth|length > 0 %}
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}"){% if loop.last %};{% endif %} // {{ node[header].description }}
Expand Down
2 changes: 1 addition & 1 deletion templates/android/docs/kotlin/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }}

val client = Client(context)
{%~ if method.auth|length > 0 %}
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Client {

fun create(context: Context) {
client = Client(context)
.setEndpoint("http://192.168.4.24/v1")
.setEndpoint("{{ spec.endpointDocs | raw }}")
.setProject("65a8e2b4632c04b1f5da")
.setSelfSigned(true)
}
Expand Down
2 changes: 1 addition & 1 deletion templates/dart/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:{{ language.params.packageName }}/{{ language.params.packageName

Client client = Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/deno/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client, {{ service.name | caseUcfirst }}{% for parameter in method.para

const client = new Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/dotnet/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using {{ spec.title | caseUcfirst }}.Services;

Client client = new Client()
{% if method.auth|length > 0 %}
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.SetEndPoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
.Set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}"){% if loop.last %};{% endif %} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/flutter/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:{{ language.params.packageName }}/{{ language.params.packageName

Client client = Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/go/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
client := client.NewClient()

{% if method.auth|length > 0 %}
client.SetEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
client.SetEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
client.Set{{header}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/kotlin/docs/java/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }};

Client client = new Client()
{% if method.auth|length > 0 %}
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}"){% if loop.last %};{% endif %} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/kotlin/docs/kotlin/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }}

val client = Client()
{% if method.auth|length > 0 %}
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/node/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const fs = require('fs');

const client = new sdk.Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/php/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use {{ spec.title | caseUcfirst }}\Enums\{{parameter.enumName | caseUcfirst}};

$client = (new Client())
{%~ if method.auth|length > 0 %}
->setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
->setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
->set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last%};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/python/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from {{ spec.title | caseSnake }}.enums import {{parameter.enumName | caseUcfirs

client = Client()
{% if method.auth|length > 0 %}
client.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
client.set_endpoint('{{ spec.endpointDocs | raw }}') # Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
client.set_{{header | caseSnake}}('{{node[header]['x-appwrite']['demo'] | raw }}') # {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/react-native/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client, {{ service.name | caseUcfirst }}{% for parameter in method.para

const client = new Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/ruby/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include {{ spec.title | caseUcfirst }}::Enums
{% endfor %}

client = Client.new
.set_endpoint('https://cloud.appwrite.io/v1') # Your API Endpoint
.set_endpoint('{{ spec.endpointDocs | raw }}') # Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set_{{header|caseSnake}}('{{node[header]['x-appwrite']['demo'] | raw }}') # {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/swift/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {{ spec.title | caseUcfirst }}Enums

let client = Client()
{% if method.auth|length > 0 %}
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
{% for node in method.auth %}
{% for key,header in node|keys %}
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}
Expand Down
2 changes: 1 addition & 1 deletion templates/web/docs/example.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Client, {{ service.name | caseUcfirst }}{% for parameter in method.para

const client = new Client()
{%~ if method.auth|length > 0 %}
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setEndpoint('{{ spec.endpointDocs | raw }}') // Your API Endpoint
{%~ for node in method.auth %}
{%~ for key,header in node|keys %}
.set{{header}}('{{node[header]['x-appwrite']['demo'] | raw }}'){% if loop.last %};{% endif%} // {{node[header].description}}
Expand Down