Skip to content

Commit 7b03d75

Browse files
Merge pull request #441 from appwrite/fix-deno-anyOf-type
Fix: Deno anyOf types
2 parents ede6d39 + 7ee745a commit 7b03d75

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Spec/Swagger2.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,16 @@ public function getDefinitions() {
312312
//nested model
313313
$sch['properties'][$name]['sub_schema'] = str_replace('#/definitions/', '', $def['items']['$ref']);
314314
}
315+
316+
if(isset($def['items']['x-anyOf'])) {
317+
//nested model
318+
$sch['properties'][$name]['sub_schemas'] = \array_map(fn($schema) => str_replace('#/definitions/', '', $schema['$ref']), $def['items']['x-anyOf']);
319+
}
320+
321+
if(isset($def['items']['x-oneOf'])) {
322+
//nested model
323+
$sch['properties'][$name]['sub_schemas'] = \array_map(fn($schema) => str_replace('#/definitions/', '', $schema['$ref']), $def['items']['x-oneOf']);
324+
}
315325
}
316326
}
317327
$list[$key] = $sch;

templates/deno/src/models.d.ts.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
{% else %}
77
{{property.sub_schema | caseUcfirst}}{% if property.type == 'array' %}[]{% endif %}
88
{% endif %}
9+
{% elseif property.sub_schemas %}
10+
({% for subProperty in property.sub_schemas %}{{subProperty | caseUcfirst}}{% if loop.last == false %} | {% endif %}{% endfor %}){% if property.type == 'array' %}[]{% endif %}
911
{% else %}
1012
{{property.type | typeName}}
1113
{% endif %}

0 commit comments

Comments
 (0)