Skip to content

Commit 12c75b8

Browse files
Merge pull request #1068 from appwrite/fix-endpoint
feat: endpoint for docs / examples
2 parents c4bc0ff + 412ea68 commit 12c75b8

File tree

21 files changed

+34
-18
lines changed

21 files changed

+34
-18
lines changed

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function getSSLPage($url) {
4242
$platform = 'console';
4343
// $platform = 'server';
4444

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

4747
if(empty($spec)) {
4848
throw new Exception('Failed to fetch spec from Appwrite server');

src/SDK/SDK.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ public function generate(string $target): void
544544
'namespace' => $this->spec->getNamespace(),
545545
'version' => $this->spec->getVersion(),
546546
'endpoint' => $this->spec->getEndpoint(),
547+
'endpointDocs' => $this->spec->getEndpointDocs(),
547548
'host' => parse_url($this->spec->getEndpoint(), PHP_URL_HOST),
548549
'basePath' => $this->spec->getAttribute('basePath', ''),
549550
'licenseName' => $this->spec->getLicenseName(),

src/Spec/Spec.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ abstract public function getVersion();
6464
*/
6565
abstract public function getEndpoint();
6666

67+
/**
68+
* @return string
69+
*/
70+
abstract public function getEndpointDocs();
71+
6772
/**
6873
* @return string
6974
*/

src/Spec/Swagger2.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function getEndpoint()
4848
$this->getAttribute('basePath', '');
4949
}
5050

51+
/**
52+
* @return string
53+
*/
54+
public function getEndpointDocs()
55+
{
56+
return $this->getAttribute('schemes.0', 'https') .
57+
'://' . $this->getAttribute('x-host-docs', 'example.com') .
58+
$this->getAttribute('basePath', '');
59+
}
60+
5161
/**
5262
* @return string
5363
*/

templates/android/docs/java/example.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }};
2323

2424
Client client = new Client(context)
2525
{%~ if method.auth|length > 0 %}
26-
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
26+
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
2727
{%~ for node in method.auth %}
2828
{%~ for key,header in node|keys %}
2929
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}"){% if loop.last %};{% endif %} // {{ node[header].description }}

templates/android/docs/kotlin/example.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {{ sdk.namespace | caseDot }}.enums.{{ name | caseUcfirst }}
2323

2424
val client = Client(context)
2525
{%~ if method.auth|length > 0 %}
26-
.setEndpoint("https://cloud.appwrite.io/v1") // Your API Endpoint
26+
.setEndpoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
2727
{%~ for node in method.auth %}
2828
{%~ for key,header in node|keys %}
2929
.set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}") // {{node[header].description}}

templates/android/example/src/main/java/io/package/android/utils/Client.kt.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Client {
88

99
fun create(context: Context) {
1010
client = Client(context)
11-
.setEndpoint("http://192.168.4.24/v1")
11+
.setEndpoint("{{ spec.endpointDocs | raw }}")
1212
.setProject("65a8e2b4632c04b1f5da")
1313
.setSelfSigned(true)
1414
}

templates/dart/docs/example.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:{{ language.params.packageName }}/{{ language.params.packageName
55

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

templates/deno/docs/example.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Client, {{ service.name | caseUcfirst }}{% for parameter in method.para
22

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

templates/dotnet/docs/example.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using {{ spec.title | caseUcfirst }}.Services;
1111

1212
Client client = new Client()
1313
{% if method.auth|length > 0 %}
14-
.SetEndPoint("https://cloud.appwrite.io/v1") // Your API Endpoint
14+
.SetEndPoint("{{ spec.endpointDocs | raw }}") // Your API Endpoint
1515
{% for node in method.auth %}
1616
{% for key,header in node|keys %}
1717
.Set{{header | caseUcfirst}}("{{node[header]['x-appwrite']['demo'] | raw }}"){% if loop.last %};{% endif %} // {{node[header].description}}

0 commit comments

Comments
 (0)