|
| 1 | +{% macro sub_schema(property) %}{% if property.sub_schema %}{% if property.type == 'array' %}{{property.sub_schema | caseUcfirst}}[]{% else %}{{property.sub_schema | caseUcfirst}}{% endif %}{% else %}{{property.type | typeName}}{% endif %}{% endmacro %} |
1 | 2 | import 'isomorphic-form-data'; |
2 | 3 | import { fetch } from 'cross-fetch'; |
3 | 4 |
|
| 5 | +namespace Models { |
| 6 | +{% for definition in spec.definitions %} |
| 7 | + /** |
| 8 | + * {{ definition.description }} |
| 9 | + */ |
| 10 | + export type {{ definition.name | caseUcfirst }}<{% for property in definition.properties %}{% if spec.definitions[property.sub_schema].additionalProperties %}{{property.sub_schema | caseUcfirst}} extends Models.{{property.sub_schema | caseUcfirst}}{% endif %}{% endfor %}> = { |
| 11 | +{% for property in definition.properties %} |
| 12 | + /** |
| 13 | + * {{ property.description }} |
| 14 | + */ |
| 15 | + {{ property.name | escapeKeyword }}{% if not property.required %}?{% endif %}: {{_self.sub_schema(property)}}; |
| 16 | +{% endfor %} |
| 17 | + } |
| 18 | +{% endfor %} |
| 19 | +} |
| 20 | + |
4 | 21 | type Payload = { |
5 | 22 | [key: string]: any; |
6 | 23 | } |
@@ -434,7 +451,7 @@ class {{ spec.title | caseUcfirst }} { |
434 | 451 | * @returns {% if method.type == 'webAuth' %}{void|string}{% elseif method.type == 'location' %}{URL}{% else %}{Promise}{% endif %} |
435 | 452 |
|
436 | 453 | */ |
437 | | - {{ method.name | caseCamel }}: {% if method.type != 'location' and method.type != 'webAuth'%}async <T extends unknown>{% endif %}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): {% if method.type == 'webAuth' %}void | URL{% elseif method.type == 'location' %}URL{% else %}Promise<T>{% endif %} => { |
| 454 | + {{ method.name | caseCamel }}: {% if method.type != 'location' and method.type != 'webAuth'%}async {% if spec.definitions[method.responseModel].additionalProperties %}<{{method.responseModel | caseUcfirst}} extends Models.{{method.responseModel | caseUcfirst}}>{% endif %}{% for property in spec.definitions[method.responseModel].properties %}{% if spec.definitions[property.sub_schema].additionalProperties %}<{{property.sub_schema | caseUcfirst}} extends Models.{{property.sub_schema | caseUcfirst}}>{% endif %}{% endfor %}{% endif %}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %}?{% endif %}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): {% if method.type == 'webAuth' %}void | URL{% elseif method.type == 'location' %}URL{% else %}Promise<{% if method.responseModel and method.responseModel != 'any' %}{% if not spec.definitions[method.responseModel].additionalProperties %}Models.{% endif %}{{method.responseModel | caseUcfirst}}{% for property in spec.definitions[method.responseModel].properties %}{% if spec.definitions[property.sub_schema].additionalProperties %}<{{property.sub_schema | caseUcfirst}}>{% endif %}{% endfor %}{% else %}{}{% endif %}>{% endif %} => { |
438 | 455 | {% for parameter in method.parameters.all %} |
439 | 456 | {% if parameter.required %} |
440 | 457 | if (typeof {{ parameter.name | caseCamel | escapeKeyword }} === 'undefined') { |
@@ -501,4 +518,4 @@ class {{ spec.title | caseUcfirst }} { |
501 | 518 | }; |
502 | 519 |
|
503 | 520 | export { {{spec.title | caseUcfirst}} } |
504 | | -export type { {{spec.title | caseUcfirst}}Exception } |
| 521 | +export type { {{spec.title | caseUcfirst}}Exception, Models } |
0 commit comments