@kattebak/openapi-generator-ts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/dist/cli/commands/generate.d.ts +23 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +116 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +26 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +6 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +80 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/convert-template.d.ts +31 -0
- package/dist/cli/convert-template.d.ts.map +1 -0
- package/dist/cli/convert-template.js +204 -0
- package/dist/cli/convert-template.js.map +1 -0
- package/dist/cli/convert-template.test.d.ts +2 -0
- package/dist/cli/convert-template.test.d.ts.map +1 -0
- package/dist/cli/convert-template.test.js +74 -0
- package/dist/cli/convert-template.test.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +246 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/config.d.ts +252 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +31 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/generator.d.ts +99 -0
- package/dist/core/generator.d.ts.map +1 -0
- package/dist/core/generator.js +492 -0
- package/dist/core/generator.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +47 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generators/generators.test.d.ts +6 -0
- package/dist/generators/generators.test.d.ts.map +1 -0
- package/dist/generators/generators.test.js +247 -0
- package/dist/generators/generators.test.js.map +1 -0
- package/dist/generators/go.d.ts +10 -0
- package/dist/generators/go.d.ts.map +1 -0
- package/dist/generators/go.js +327 -0
- package/dist/generators/go.js.map +1 -0
- package/dist/generators/index.d.ts +29 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +58 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/php.d.ts +14 -0
- package/dist/generators/php.d.ts.map +1 -0
- package/dist/generators/php.js +241 -0
- package/dist/generators/php.js.map +1 -0
- package/dist/generators/python.d.ts +10 -0
- package/dist/generators/python.d.ts.map +1 -0
- package/dist/generators/python.js +273 -0
- package/dist/generators/python.js.map +1 -0
- package/dist/generators/typescript-fetch.d.ts +14 -0
- package/dist/generators/typescript-fetch.d.ts.map +1 -0
- package/dist/generators/typescript-fetch.js +217 -0
- package/dist/generators/typescript-fetch.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/models/codegen-model.d.ts +123 -0
- package/dist/models/codegen-model.d.ts.map +1 -0
- package/dist/models/codegen-model.js +64 -0
- package/dist/models/codegen-model.js.map +1 -0
- package/dist/models/codegen-model.test.d.ts +6 -0
- package/dist/models/codegen-model.test.d.ts.map +1 -0
- package/dist/models/codegen-model.test.js +143 -0
- package/dist/models/codegen-model.test.js.map +1 -0
- package/dist/models/codegen-operation.d.ts +95 -0
- package/dist/models/codegen-operation.d.ts.map +1 -0
- package/dist/models/codegen-operation.js +54 -0
- package/dist/models/codegen-operation.js.map +1 -0
- package/dist/models/codegen-parameter.d.ts +86 -0
- package/dist/models/codegen-parameter.d.ts.map +1 -0
- package/dist/models/codegen-parameter.js +47 -0
- package/dist/models/codegen-parameter.js.map +1 -0
- package/dist/models/codegen-property.d.ts +95 -0
- package/dist/models/codegen-property.d.ts.map +1 -0
- package/dist/models/codegen-property.js +47 -0
- package/dist/models/codegen-property.js.map +1 -0
- package/dist/models/codegen-response.d.ts +64 -0
- package/dist/models/codegen-response.d.ts.map +1 -0
- package/dist/models/codegen-response.js +42 -0
- package/dist/models/codegen-response.js.map +1 -0
- package/dist/models/codegen-security.d.ts +34 -0
- package/dist/models/codegen-security.d.ts.map +1 -0
- package/dist/models/codegen-security.js +18 -0
- package/dist/models/codegen-security.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +4 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/openapi-parser.d.ts +71 -0
- package/dist/parser/openapi-parser.d.ts.map +1 -0
- package/dist/parser/openapi-parser.js +195 -0
- package/dist/parser/openapi-parser.js.map +1 -0
- package/dist/parser/openapi-parser.test.d.ts +6 -0
- package/dist/parser/openapi-parser.test.d.ts.map +1 -0
- package/dist/parser/openapi-parser.test.js +238 -0
- package/dist/parser/openapi-parser.test.js.map +1 -0
- package/dist/parser/operation-transformer.d.ts +95 -0
- package/dist/parser/operation-transformer.d.ts.map +1 -0
- package/dist/parser/operation-transformer.js +634 -0
- package/dist/parser/operation-transformer.js.map +1 -0
- package/dist/parser/schema-transformer.d.ts +134 -0
- package/dist/parser/schema-transformer.d.ts.map +1 -0
- package/dist/parser/schema-transformer.js +557 -0
- package/dist/parser/schema-transformer.js.map +1 -0
- package/dist/template/engine-adapter.d.ts +55 -0
- package/dist/template/engine-adapter.d.ts.map +1 -0
- package/dist/template/engine-adapter.js +178 -0
- package/dist/template/engine-adapter.js.map +1 -0
- package/dist/template/engine-adapter.test.d.ts +6 -0
- package/dist/template/engine-adapter.test.d.ts.map +1 -0
- package/dist/template/engine-adapter.test.js +186 -0
- package/dist/template/engine-adapter.test.js.map +1 -0
- package/dist/template/index.d.ts +5 -0
- package/dist/template/index.d.ts.map +1 -0
- package/dist/template/index.js +5 -0
- package/dist/template/index.js.map +1 -0
- package/dist/template/lambdas/indent-lambdas.d.ts +40 -0
- package/dist/template/lambdas/indent-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/indent-lambdas.js +98 -0
- package/dist/template/lambdas/indent-lambdas.js.map +1 -0
- package/dist/template/lambdas/index.d.ts +44 -0
- package/dist/template/lambdas/index.d.ts.map +1 -0
- package/dist/template/lambdas/index.js +79 -0
- package/dist/template/lambdas/index.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.d.ts +78 -0
- package/dist/template/lambdas/string-lambdas.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.js +148 -0
- package/dist/template/lambdas/string-lambdas.js.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts +6 -0
- package/dist/template/lambdas/string-lambdas.test.d.ts.map +1 -0
- package/dist/template/lambdas/string-lambdas.test.js +158 -0
- package/dist/template/lambdas/string-lambdas.test.js.map +1 -0
- package/dist/template/template-locator.d.ts +72 -0
- package/dist/template/template-locator.d.ts.map +1 -0
- package/dist/template/template-locator.js +173 -0
- package/dist/template/template-locator.js.map +1 -0
- package/dist/template/template-manager.d.ts +65 -0
- package/dist/template/template-manager.d.ts.map +1 -0
- package/dist/template/template-manager.js +185 -0
- package/dist/template/template-manager.js.map +1 -0
- package/package.json +67 -0
- package/templates/go/.travis.yml +8 -0
- package/templates/go/README.mustache +236 -0
- package/templates/go/api.mustache +452 -0
- package/templates/go/api_doc.mustache +92 -0
- package/templates/go/api_test.mustache +59 -0
- package/templates/go/client.mustache +761 -0
- package/templates/go/configuration.mustache +332 -0
- package/templates/go/git_push.sh.mustache +57 -0
- package/templates/go/gitignore.mustache +24 -0
- package/templates/go/go.mod.mustache +16 -0
- package/templates/go/go.sum.mustache +19 -0
- package/templates/go/model.mustache +21 -0
- package/templates/go/model_anyof.mustache +93 -0
- package/templates/go/model_doc.mustache +97 -0
- package/templates/go/model_enum.mustache +101 -0
- package/templates/go/model_oneof.mustache +160 -0
- package/templates/go/model_simple.mustache +572 -0
- package/templates/go/nullable_model.mustache +35 -0
- package/templates/go/openapi.mustache +1 -0
- package/templates/go/partial_header.mustache +18 -0
- package/templates/go/response.mustache +38 -0
- package/templates/go/signing.mustache +453 -0
- package/templates/go/utils.mustache +352 -0
- package/templates/php/.php-cs-fixer.dist.php +29 -0
- package/templates/php/.travis.yml +8 -0
- package/templates/php/ApiException.mustache +111 -0
- package/templates/php/Configuration.mustache +606 -0
- package/templates/php/FormDataProcessor.mustache +238 -0
- package/templates/php/HeaderSelector.mustache +265 -0
- package/templates/php/ModelInterface.mustache +103 -0
- package/templates/php/ObjectSerializer.mustache +591 -0
- package/templates/php/README.mustache +151 -0
- package/templates/php/api.mustache +891 -0
- package/templates/php/api_doc.mustache +105 -0
- package/templates/php/api_test.mustache +80 -0
- package/templates/php/composer.mustache +44 -0
- package/templates/php/git_push.sh.mustache +57 -0
- package/templates/php/gitignore +15 -0
- package/templates/php/libraries/psr-18/ApiException.mustache +114 -0
- package/templates/php/libraries/psr-18/DebugPlugin.mustache +93 -0
- package/templates/php/libraries/psr-18/README.mustache +161 -0
- package/templates/php/libraries/psr-18/api.mustache +833 -0
- package/templates/php/libraries/psr-18/api_doc.mustache +79 -0
- package/templates/php/libraries/psr-18/composer.mustache +56 -0
- package/templates/php/model.mustache +47 -0
- package/templates/php/model_doc.mustache +10 -0
- package/templates/php/model_enum.mustache +33 -0
- package/templates/php/model_generic.mustache +565 -0
- package/templates/php/model_test.mustache +88 -0
- package/templates/php/partial_header.mustache +18 -0
- package/templates/php/php_doc_auth_partial.mustache +23 -0
- package/templates/php/phpunit.xml.mustache +18 -0
- package/templates/python/README.mustache +60 -0
- package/templates/python/README_onlypackage.mustache +50 -0
- package/templates/python/__init__.mustache +1 -0
- package/templates/python/__init__api.mustache +19 -0
- package/templates/python/__init__model.mustache +22 -0
- package/templates/python/__init__package.mustache +49 -0
- package/templates/python/api.mustache +244 -0
- package/templates/python/api_client.mustache +822 -0
- package/templates/python/api_doc.mustache +81 -0
- package/templates/python/api_doc_example.mustache +38 -0
- package/templates/python/api_response.mustache +21 -0
- package/templates/python/api_test.mustache +48 -0
- package/templates/python/asyncio/rest.mustache +209 -0
- package/templates/python/common_README.mustache +85 -0
- package/templates/python/configuration.mustache +806 -0
- package/templates/python/exceptions.mustache +210 -0
- package/templates/python/exports_api.mustache +3 -0
- package/templates/python/exports_model.mustache +3 -0
- package/templates/python/exports_package.mustache +20 -0
- package/templates/python/git_push.sh.mustache +57 -0
- package/templates/python/github-workflow.mustache +35 -0
- package/templates/python/gitignore.mustache +66 -0
- package/templates/python/gitlab-ci.mustache +31 -0
- package/templates/python/httpx/rest.mustache +190 -0
- package/templates/python/model.mustache +16 -0
- package/templates/python/model_anyof.mustache +182 -0
- package/templates/python/model_doc.mustache +40 -0
- package/templates/python/model_enum.mustache +36 -0
- package/templates/python/model_generic.mustache +403 -0
- package/templates/python/model_oneof.mustache +209 -0
- package/templates/python/model_test.mustache +60 -0
- package/templates/python/partial_api.mustache +52 -0
- package/templates/python/partial_api_args.mustache +18 -0
- package/templates/python/partial_header.mustache +19 -0
- package/templates/python/py.typed.mustache +1 -0
- package/templates/python/pyproject.mustache +172 -0
- package/templates/python/python_doc_auth_partial.mustache +108 -0
- package/templates/python/requirements.mustache +23 -0
- package/templates/python/rest.mustache +254 -0
- package/templates/python/setup.mustache +60 -0
- package/templates/python/setup_cfg.mustache +2 -0
- package/templates/python/signing.mustache +422 -0
- package/templates/python/test-requirements.mustache +6 -0
- package/templates/python/tornado/rest.mustache +148 -0
- package/templates/python/tox.mustache +9 -0
- package/templates/python/travis.mustache +17 -0
- package/templates/typescript-fetch/ApiEntitiesRecord.mustache +26 -0
- package/templates/typescript-fetch/ApiEntitiesReducer.mustache +21 -0
- package/templates/typescript-fetch/ApiEntitiesSelectors.mustache +5 -0
- package/templates/typescript-fetch/README.mustache +127 -0
- package/templates/typescript-fetch/allSagas.mustache +19 -0
- package/templates/typescript-fetch/api_doc.mustache +63 -0
- package/templates/typescript-fetch/api_example.mustache +44 -0
- package/templates/typescript-fetch/apis.index.mustache +16 -0
- package/templates/typescript-fetch/apis.mustache +483 -0
- package/templates/typescript-fetch/apisAssignQueryParam.mustache +12 -0
- package/templates/typescript-fetch/gitignore +4 -0
- package/templates/typescript-fetch/index.mustache +17 -0
- package/templates/typescript-fetch/licenseInfo.mustache +11 -0
- package/templates/typescript-fetch/modelEnum.mustache +28 -0
- package/templates/typescript-fetch/modelEnumInterfaces.mustache +37 -0
- package/templates/typescript-fetch/modelGeneric.mustache +261 -0
- package/templates/typescript-fetch/modelGenericInterfaces.mustache +50 -0
- package/templates/typescript-fetch/modelOneOf.mustache +255 -0
- package/templates/typescript-fetch/modelOneOfInterfaces.mustache +6 -0
- package/templates/typescript-fetch/model_doc.mustache +41 -0
- package/templates/typescript-fetch/models.index.mustache +32 -0
- package/templates/typescript-fetch/models.mustache +24 -0
- package/templates/typescript-fetch/npmignore.mustache +1 -0
- package/templates/typescript-fetch/package.mustache +43 -0
- package/templates/typescript-fetch/recordGeneric.mustache +295 -0
- package/templates/typescript-fetch/records.mustache +17 -0
- package/templates/typescript-fetch/runtime.mustache +424 -0
- package/templates/typescript-fetch/runtimeSagasAndRecords.mustache +120 -0
- package/templates/typescript-fetch/sagaApiManager.mustache +28 -0
- package/templates/typescript-fetch/sagas.mustache +245 -0
- package/templates/typescript-fetch/sourceLibraryIndex.mustache +1 -0
- package/templates/typescript-fetch/tsconfig.esm.mustache +7 -0
- package/templates/typescript-fetch/tsconfig.mustache +25 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { mapValues } from '../runtime{{importFileExtension}}';
|
|
2
|
+
{{#hasImports}}
|
|
3
|
+
{{#tsImports}}
|
|
4
|
+
import type { {{{classname}}} } from './{{filename}}{{importFileExtension}}';
|
|
5
|
+
import {
|
|
6
|
+
{{classname}}FromJSON,
|
|
7
|
+
{{classname}}FromJSONTyped,
|
|
8
|
+
{{classname}}ToJSON,
|
|
9
|
+
{{classname}}ToJSONTyped,
|
|
10
|
+
} from './{{filename}}{{importFileExtension}}';
|
|
11
|
+
{{/tsImports}}
|
|
12
|
+
|
|
13
|
+
{{/hasImports}}
|
|
14
|
+
{{#discriminator}}
|
|
15
|
+
{{#discriminator.mappedModels}}
|
|
16
|
+
import { type {{modelName}}, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}';
|
|
17
|
+
{{/discriminator.mappedModels}}
|
|
18
|
+
{{/discriminator}}
|
|
19
|
+
{{>modelGenericInterfaces}}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if a given object implements the {{classname}} interface.
|
|
24
|
+
*/
|
|
25
|
+
export function instanceOf{{classname}}(value: object): value is {{classname}} {
|
|
26
|
+
{{#vars}}
|
|
27
|
+
{{#required}}
|
|
28
|
+
if (!('{{name}}' in value) || value['{{name}}'] === undefined) return false;
|
|
29
|
+
{{/required}}
|
|
30
|
+
{{/vars}}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function {{classname}}FromJSON(json: any): {{classname}} {
|
|
35
|
+
return {{classname}}FromJSONTyped(json, false);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} {
|
|
39
|
+
{{#hasVars}}
|
|
40
|
+
if (json == null) {
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
{{#discriminator}}
|
|
44
|
+
if (!ignoreDiscriminator) {
|
|
45
|
+
{{#discriminator.mappedModels}}
|
|
46
|
+
if (json['{{discriminator.propertyBaseName}}'] === '{{mappingName}}') {
|
|
47
|
+
return {{modelName}}FromJSONTyped(json, ignoreDiscriminator);
|
|
48
|
+
}
|
|
49
|
+
{{/discriminator.mappedModels}}
|
|
50
|
+
{{#hasSelfReferencingDiscriminatorMapping}}
|
|
51
|
+
if (json['{{discriminator.propertyBaseName}}'] === '{{selfReferencingDiscriminatorMapping.mappingName}}') {
|
|
52
|
+
return {{selfReferencingDiscriminatorMapping.modelName}}FromJSONTyped(json, true);
|
|
53
|
+
}
|
|
54
|
+
{{/hasSelfReferencingDiscriminatorMapping}}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
{{/discriminator}}
|
|
58
|
+
return {
|
|
59
|
+
{{#parent}}...{{{.}}}FromJSONTyped(json, true),{{/parent}}
|
|
60
|
+
{{#additionalPropertiesType}}
|
|
61
|
+
...json,
|
|
62
|
+
{{/additionalPropertiesType}}
|
|
63
|
+
{{#vars}}
|
|
64
|
+
{{#isPrimitiveType}}
|
|
65
|
+
{{#isArray}}
|
|
66
|
+
{{#uniqueItems}}
|
|
67
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Set(json['{{baseName}}']),
|
|
68
|
+
{{/uniqueItems}}
|
|
69
|
+
{{^uniqueItems}}
|
|
70
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}json['{{baseName}}'],
|
|
71
|
+
{{/uniqueItems}}
|
|
72
|
+
{{/isArray}}
|
|
73
|
+
{{^isArray}}
|
|
74
|
+
{{#isDateType}}
|
|
75
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
|
|
76
|
+
{{/isDateType}}
|
|
77
|
+
{{#isDateTimeType}}
|
|
78
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
|
|
79
|
+
{{/isDateTimeType}}
|
|
80
|
+
{{^isDateType}}
|
|
81
|
+
{{^isDateTimeType}}
|
|
82
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}json['{{baseName}}'],
|
|
83
|
+
{{/isDateTimeType}}
|
|
84
|
+
{{/isDateType}}
|
|
85
|
+
{{/isArray}}
|
|
86
|
+
{{/isPrimitiveType}}
|
|
87
|
+
{{^isPrimitiveType}}
|
|
88
|
+
{{#isArray}}
|
|
89
|
+
{{#uniqueItems}}
|
|
90
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Set((json['{{baseName}}'] as Array<any>).map({{#items}}{{datatype}}{{/items}}FromJSON))),
|
|
91
|
+
{{/uniqueItems}}
|
|
92
|
+
{{^uniqueItems}}
|
|
93
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}(json['{{baseName}}'] as Array<any>).map({{#items}}{{datatype}}{{/items}}FromJSON)),
|
|
94
|
+
{{/uniqueItems}}
|
|
95
|
+
{{/isArray}}
|
|
96
|
+
{{#isMap}}
|
|
97
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}mapValues(json['{{baseName}}'], {{#items}}{{datatype}}{{/items}}FromJSON)),
|
|
98
|
+
{{/isMap}}
|
|
99
|
+
{{^isArray}}
|
|
100
|
+
{{^isMap}}
|
|
101
|
+
{{^isFreeFormObject}}
|
|
102
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}{{datatype}}FromJSON(json['{{baseName}}']),
|
|
103
|
+
{{/isFreeFormObject}}
|
|
104
|
+
{{#isFreeFormObject}}
|
|
105
|
+
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}json['{{baseName}}'],
|
|
106
|
+
{{/isFreeFormObject}}
|
|
107
|
+
{{/isMap}}
|
|
108
|
+
{{/isArray}}
|
|
109
|
+
{{/isPrimitiveType}}
|
|
110
|
+
{{/vars}}
|
|
111
|
+
};
|
|
112
|
+
{{/hasVars}}
|
|
113
|
+
{{^hasVars}}
|
|
114
|
+
return json;
|
|
115
|
+
{{/hasVars}}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function {{classname}}ToJSON(json: any): {{classname}} {
|
|
119
|
+
return {{classname}}ToJSONTyped(json, false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function {{classname}}ToJSONTyped(value?: {{#hasReadOnly}}Omit<{{classname}}, {{#readOnlyVars}}'{{baseName}}'{{#unless @last}}|{{/unless}}{{/readOnlyVars}}>{{/hasReadOnly}}{{^hasReadOnly}}{{classname}}{{/hasReadOnly}} | null, ignoreDiscriminator: boolean = false): any {
|
|
123
|
+
{{#hasVars}}
|
|
124
|
+
if (value == null) {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
{{#discriminator}}
|
|
128
|
+
|
|
129
|
+
if (!ignoreDiscriminator) {
|
|
130
|
+
switch (value['{{discriminator.propertyName}}']) {
|
|
131
|
+
{{#discriminator.mappedModels}}
|
|
132
|
+
case '{{mappingName}}':
|
|
133
|
+
return {{modelName}}ToJSONTyped(value as {{modelName}}, ignoreDiscriminator);
|
|
134
|
+
{{/discriminator.mappedModels}}
|
|
135
|
+
default:
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
{{/discriminator}}
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
{{#parent}}...{{{.}}}ToJSONTyped(value, true),{{/parent}}
|
|
143
|
+
{{#additionalPropertiesType}}
|
|
144
|
+
...value,
|
|
145
|
+
{{/additionalPropertiesType}}
|
|
146
|
+
{{#vars}}
|
|
147
|
+
{{^isReadOnly}}
|
|
148
|
+
{{#isPrimitiveType}}
|
|
149
|
+
{{#isDateType}}
|
|
150
|
+
'{{baseName}}': {{^required}}value['{{name}}'] == null ? value['{{name}}'] : {{/required}}{{#isNullable}}{{#required}}value['{{name}}'] == null ? value['{{name}}'] : {{/required}}{{/isNullable}}value['{{name}}'].toISOString().substring(0,10),
|
|
151
|
+
{{/isDateType}}
|
|
152
|
+
{{#isDateTimeType}}
|
|
153
|
+
'{{baseName}}': {{^required}}value['{{name}}'] == null ? value['{{name}}'] : {{/required}}{{#isNullable}}{{#required}}value['{{name}}'] == null ? value['{{name}}'] : {{/required}}{{/isNullable}}value['{{name}}'].toISOString(),
|
|
154
|
+
{{/isDateTimeType}}
|
|
155
|
+
{{#isArray}}
|
|
156
|
+
'{{baseName}}': {{#uniqueItems}}{{^required}}value['{{name}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}value['{{name}}'] == null ? null : {{/isNullable}}{{/required}}Array.from(value['{{name}}'] as Set<any>){{/uniqueItems}}{{^uniqueItems}}value['{{name}}']{{/uniqueItems}},
|
|
157
|
+
{{/isArray}}
|
|
158
|
+
{{^isDateType}}
|
|
159
|
+
{{^isDateTimeType}}
|
|
160
|
+
{{^isArray}}
|
|
161
|
+
'{{baseName}}': value['{{name}}'],
|
|
162
|
+
{{/isArray}}
|
|
163
|
+
{{/isDateTimeType}}
|
|
164
|
+
{{/isDateType}}
|
|
165
|
+
{{/isPrimitiveType}}
|
|
166
|
+
{{^isPrimitiveType}}
|
|
167
|
+
{{#isArray}}
|
|
168
|
+
{{#uniqueItems}}
|
|
169
|
+
'{{baseName}}': {{^required}}value['{{name}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}value['{{name}}'] == null ? null : {{/isNullable}}{{/required}}Array.from(value['{{name}}'] as Set<any>).map({{#items}}{{datatype}}{{/items}}ToJSON)),
|
|
170
|
+
{{/uniqueItems}}
|
|
171
|
+
{{^uniqueItems}}
|
|
172
|
+
'{{baseName}}': {{^required}}value['{{name}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}value['{{name}}'] == null ? null : {{/isNullable}}{{/required}}(value['{{name}}'] as Array<any>).map({{#items}}{{datatype}}{{/items}}ToJSON)),
|
|
173
|
+
{{/uniqueItems}}
|
|
174
|
+
{{/isArray}}
|
|
175
|
+
{{#isMap}}
|
|
176
|
+
'{{baseName}}': {{^required}}value['{{name}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}value['{{name}}'] == null ? null : {{/isNullable}}{{/required}}mapValues(value['{{name}}'], {{#items}}{{datatype}}{{/items}}ToJSON)),
|
|
177
|
+
{{/isMap}}
|
|
178
|
+
{{^isArray}}
|
|
179
|
+
{{^isMap}}
|
|
180
|
+
{{^isFreeFormObject}}
|
|
181
|
+
'{{baseName}}': {{datatype}}ToJSON(value['{{name}}']),
|
|
182
|
+
{{/isFreeFormObject}}
|
|
183
|
+
{{#isFreeFormObject}}
|
|
184
|
+
'{{baseName}}': value['{{name}}'],
|
|
185
|
+
{{/isFreeFormObject}}
|
|
186
|
+
{{/isMap}}
|
|
187
|
+
{{/isArray}}
|
|
188
|
+
{{/isPrimitiveType}}
|
|
189
|
+
{{/isReadOnly}}
|
|
190
|
+
{{/vars}}
|
|
191
|
+
};
|
|
192
|
+
{{/hasVars}}
|
|
193
|
+
{{^hasVars}}
|
|
194
|
+
return value;
|
|
195
|
+
{{/hasVars}}
|
|
196
|
+
}
|
|
197
|
+
{{#validationAttributes}}
|
|
198
|
+
|
|
199
|
+
export const {{classname}}PropertyValidationAttributesMap: {
|
|
200
|
+
[property: string]: {
|
|
201
|
+
maxLength?: number,
|
|
202
|
+
minLength?: number,
|
|
203
|
+
pattern?: string,
|
|
204
|
+
maximum?: number,
|
|
205
|
+
exclusiveMaximum?: boolean,
|
|
206
|
+
minimum?: number,
|
|
207
|
+
exclusiveMinimum?: boolean,
|
|
208
|
+
multipleOf?: number,
|
|
209
|
+
maxItems?: number,
|
|
210
|
+
minItems?: number,
|
|
211
|
+
uniqueItems?: boolean
|
|
212
|
+
}
|
|
213
|
+
} = {
|
|
214
|
+
{{#vars}}
|
|
215
|
+
{{#hasValidation}}
|
|
216
|
+
{{name}}: {
|
|
217
|
+
{{#if maxLength}}
|
|
218
|
+
maxLength: {{maxLength}},
|
|
219
|
+
{{/if}}
|
|
220
|
+
{{#if minLength}}
|
|
221
|
+
minLength: {{minLength}},
|
|
222
|
+
{{/if}}
|
|
223
|
+
{{#if pattern}}
|
|
224
|
+
pattern: '{{pattern}}',
|
|
225
|
+
{{/if}}
|
|
226
|
+
{{#if maximum}}
|
|
227
|
+
maximum: {{maximum}},
|
|
228
|
+
exclusiveMaximum: {{exclusiveMaximum}},
|
|
229
|
+
{{/if}}
|
|
230
|
+
{{#if minimum}}
|
|
231
|
+
minimum: {{minimum}},
|
|
232
|
+
exclusiveMinimum: {{exclusiveMinimum}},
|
|
233
|
+
{{/if}}
|
|
234
|
+
{{#multipleOf}}
|
|
235
|
+
multipleOf: {{multipleOf}},
|
|
236
|
+
{{/multipleOf}}
|
|
237
|
+
{{#maxItems}}
|
|
238
|
+
maxItems: {{maxItems}},
|
|
239
|
+
{{/maxItems}}
|
|
240
|
+
{{#minItems}}
|
|
241
|
+
minItems: {{minItems}},
|
|
242
|
+
{{/minItems}}
|
|
243
|
+
{{#isArray}}
|
|
244
|
+
uniqueItems: {{uniqueItems}},
|
|
245
|
+
{{/isArray}}
|
|
246
|
+
},
|
|
247
|
+
{{/hasValidation}}
|
|
248
|
+
{{/vars}}
|
|
249
|
+
}
|
|
250
|
+
{{#isAdditionalPropertiesTrue}}
|
|
251
|
+
|
|
252
|
+
export const {{classname}}AdditionalPropertiesValidationAttributes: { maxProperties?: number, minProperties?: number } = {
|
|
253
|
+
{{#maxProperties}}
|
|
254
|
+
maxProperties: {{maxProperties}},
|
|
255
|
+
{{/maxProperties}}
|
|
256
|
+
{{#minProperties}}
|
|
257
|
+
minProperties: {{minProperties}},
|
|
258
|
+
{{/minProperties}}
|
|
259
|
+
}
|
|
260
|
+
{{/isAdditionalPropertiesTrue}}
|
|
261
|
+
{{/validationAttributes}}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{#indented_star_1}}{{{unescapedDescription}}}{{/indented_star_1}}
|
|
3
|
+
* @export
|
|
4
|
+
* @interface {{classname}}
|
|
5
|
+
*/
|
|
6
|
+
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
|
|
7
|
+
{{#additionalPropertiesType}}
|
|
8
|
+
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
|
9
|
+
{{/additionalPropertiesType}}
|
|
10
|
+
{{#vars}}
|
|
11
|
+
/**
|
|
12
|
+
* {{#indented_star_4}}{{{unescapedDescription}}}{{/indented_star_4}}
|
|
13
|
+
* @type {{braceWrap datatype}}
|
|
14
|
+
* @memberof {{classname}}
|
|
15
|
+
{{#deprecated}}
|
|
16
|
+
* @deprecated
|
|
17
|
+
{{/deprecated}}
|
|
18
|
+
*/
|
|
19
|
+
{{#isReadOnly}}readonly {{/isReadOnly}}{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
|
|
20
|
+
{{/vars}}
|
|
21
|
+
}{{#hasEnums}}
|
|
22
|
+
|
|
23
|
+
{{#vars}}
|
|
24
|
+
{{#isEnum}}
|
|
25
|
+
{{#stringEnums}}
|
|
26
|
+
/**
|
|
27
|
+
* @export
|
|
28
|
+
* @enum {string}
|
|
29
|
+
*/
|
|
30
|
+
export enum {{classname}}{{enumName}} {
|
|
31
|
+
{{#allowableValues}}
|
|
32
|
+
{{#enumVars}}
|
|
33
|
+
{{{name}}} = {{{value}}}{{#unless @last}},{{/unless}}
|
|
34
|
+
{{/enumVars}}
|
|
35
|
+
{{/allowableValues}}
|
|
36
|
+
}
|
|
37
|
+
{{/stringEnums}}{{^stringEnums}}
|
|
38
|
+
/**
|
|
39
|
+
* @export
|
|
40
|
+
*/
|
|
41
|
+
export const {{classname}}{{enumName}} = {
|
|
42
|
+
{{#allowableValues}}
|
|
43
|
+
{{#enumVars}}
|
|
44
|
+
{{{name}}}: {{{value}}}{{#unless @last}},{{/unless}}
|
|
45
|
+
{{/enumVars}}
|
|
46
|
+
{{/allowableValues}}
|
|
47
|
+
} as const;
|
|
48
|
+
export type {{classname}}{{enumName}} = typeof {{classname}}{{enumName}}[keyof typeof {{classname}}{{enumName}}];
|
|
49
|
+
{{/stringEnums}}
|
|
50
|
+
{{/isEnum}}{{/vars}}{{/hasEnums}}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
{{#hasImports}}
|
|
2
|
+
{{#oneOfArrays}}
|
|
3
|
+
import type { {{{.}}} } from './{{.}}{{importFileExtension}}';
|
|
4
|
+
import {
|
|
5
|
+
instanceOf{{{.}}},
|
|
6
|
+
{{{.}}}FromJSON,
|
|
7
|
+
{{{.}}}FromJSONTyped,
|
|
8
|
+
{{{.}}}ToJSON,
|
|
9
|
+
} from './{{.}}{{importFileExtension}}';
|
|
10
|
+
{{/oneOfArrays}}
|
|
11
|
+
{{#oneOfModels}}
|
|
12
|
+
import type { {{{.}}} } from './{{.}}{{importFileExtension}}';
|
|
13
|
+
import {
|
|
14
|
+
instanceOf{{{.}}},
|
|
15
|
+
{{{.}}}FromJSON,
|
|
16
|
+
{{{.}}}FromJSONTyped,
|
|
17
|
+
{{{.}}}ToJSON,
|
|
18
|
+
} from './{{.}}{{importFileExtension}}';
|
|
19
|
+
{{/oneOfModels}}
|
|
20
|
+
|
|
21
|
+
{{/hasImports}}
|
|
22
|
+
{{>modelOneOfInterfaces}}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export function {{classname}}FromJSON(json: any): {{classname}} {
|
|
26
|
+
return {{classname}}FromJSONTyped(json, false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boolean): {{classname}} {
|
|
30
|
+
if (json == null) {
|
|
31
|
+
return json;
|
|
32
|
+
}
|
|
33
|
+
{{#discriminator}}
|
|
34
|
+
switch (json['{{discriminator.propertyBaseName}}']) {
|
|
35
|
+
{{#discriminator.mappedModels}}
|
|
36
|
+
case '{{mappingName}}':
|
|
37
|
+
return Object.assign({}, {{modelName}}FromJSONTyped(json, true), { {{discriminator.propertyName}}: '{{mappingName}}' } as const);
|
|
38
|
+
{{/discriminator.mappedModels}}
|
|
39
|
+
default:
|
|
40
|
+
return json;
|
|
41
|
+
}
|
|
42
|
+
{{/discriminator}}
|
|
43
|
+
{{^discriminator}}
|
|
44
|
+
{{#oneOfModels}}
|
|
45
|
+
{{#if @first}}
|
|
46
|
+
if (typeof json !== 'object') {
|
|
47
|
+
return json;
|
|
48
|
+
}
|
|
49
|
+
{{/if}}
|
|
50
|
+
if (instanceOf{{{.}}}(json)) {
|
|
51
|
+
return {{{.}}}FromJSONTyped(json, true);
|
|
52
|
+
}
|
|
53
|
+
{{/oneOfModels}}
|
|
54
|
+
{{#oneOfArrays}}
|
|
55
|
+
{{#if @first}}
|
|
56
|
+
if (Array.isArray(json)) {
|
|
57
|
+
if (json.every(item => typeof item === 'object')) {
|
|
58
|
+
{{/if}}
|
|
59
|
+
if (json.every(item => instanceOf{{{.}}}(item))) {
|
|
60
|
+
return json.map(value => {{{.}}}FromJSONTyped(value, true));
|
|
61
|
+
}
|
|
62
|
+
{{#if @last}}
|
|
63
|
+
}
|
|
64
|
+
return json;
|
|
65
|
+
}
|
|
66
|
+
{{/if}}
|
|
67
|
+
{{/oneOfArrays}}
|
|
68
|
+
{{#oneOfPrimitives}}
|
|
69
|
+
{{#isArray}}
|
|
70
|
+
{{#items}}
|
|
71
|
+
{{#isDateType}}
|
|
72
|
+
if (Array.isArray(json)) {
|
|
73
|
+
if (json.every(item => !(isNaN(new Date(json).getTime()))) {
|
|
74
|
+
return json.map(value => new Date(json);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
{{/isDateType}}
|
|
78
|
+
{{#isDateTimeType}}
|
|
79
|
+
if (Array.isArray(json)) {
|
|
80
|
+
if (json.every(item => !(isNaN(new Date(json).getTime()))) {
|
|
81
|
+
return json.map(value => new Date(json);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
{{/isDateTimeType}}
|
|
85
|
+
{{#isNumeric}}
|
|
86
|
+
if (Array.isArray(json)) {
|
|
87
|
+
if (json.every(item => typeof item === 'number'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
88
|
+
return json;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
{{/isNumeric}}
|
|
92
|
+
{{#isBoolean}}
|
|
93
|
+
if (Array.isArray(json)) {
|
|
94
|
+
if (json.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
95
|
+
return json;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
{{/isBoolean}}
|
|
99
|
+
{{#isString}}
|
|
100
|
+
if (Array.isArray(json)) {
|
|
101
|
+
if (json.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
102
|
+
return json;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
{{/isString}}
|
|
106
|
+
{{/items}}
|
|
107
|
+
{{/isArray}}
|
|
108
|
+
{{^isArray}}
|
|
109
|
+
{{#isDateType}}
|
|
110
|
+
if (!(isNaN(new Date(json).getTime()))) {
|
|
111
|
+
return {{^required}}json == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json == null ? null : {{/isNullable}}{{/required}}new Date(json));
|
|
112
|
+
}
|
|
113
|
+
{{/isDateType}}
|
|
114
|
+
{{^isDateType}}
|
|
115
|
+
{{#isDateTimeType}}
|
|
116
|
+
if (!(isNaN(new Date(json).getTime()))) {
|
|
117
|
+
return {{^required}}json == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json == null ? null : {{/isNullable}}{{/required}}new Date(json));
|
|
118
|
+
}
|
|
119
|
+
{{/isDateTimeType}}
|
|
120
|
+
{{/isDateType}}
|
|
121
|
+
{{#isNumeric}}
|
|
122
|
+
if (typeof json === 'number'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
123
|
+
return json;
|
|
124
|
+
}
|
|
125
|
+
{{/isNumeric}}
|
|
126
|
+
{{#isBoolean}}
|
|
127
|
+
if (typeof json === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
128
|
+
return json;
|
|
129
|
+
}
|
|
130
|
+
{{/isBoolean}}
|
|
131
|
+
{{#isString}}
|
|
132
|
+
if (typeof json === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}json === '{{.}}'{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
133
|
+
return json;
|
|
134
|
+
}
|
|
135
|
+
{{/isString}}
|
|
136
|
+
{{/isArray}}
|
|
137
|
+
{{/oneOfPrimitives}}
|
|
138
|
+
return {} as any;
|
|
139
|
+
{{/discriminator}}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function {{classname}}ToJSON(json: any): any {
|
|
143
|
+
return {{classname}}ToJSONTyped(json, false);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function {{classname}}ToJSONTyped(value?: {{classname}} | null, ignoreDiscriminator: boolean = false): any {
|
|
147
|
+
if (value == null) {
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
{{#discriminator}}
|
|
151
|
+
switch (value['{{discriminator.propertyName}}']) {
|
|
152
|
+
{{#discriminator.mappedModels}}
|
|
153
|
+
case '{{mappingName}}':
|
|
154
|
+
return Object.assign({}, {{modelName}}ToJSON(value), { {{discriminator.propertyName}}: '{{mappingName}}' } as const);
|
|
155
|
+
{{/discriminator.mappedModels}}
|
|
156
|
+
default:
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
{{/discriminator}}
|
|
160
|
+
{{^discriminator}}
|
|
161
|
+
{{#oneOfModels}}
|
|
162
|
+
{{#if @first}}
|
|
163
|
+
if (typeof value !== 'object') {
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
{{/if}}
|
|
167
|
+
if (instanceOf{{{.}}}(value)) {
|
|
168
|
+
return {{{.}}}ToJSON(value as {{{.}}});
|
|
169
|
+
}
|
|
170
|
+
{{/oneOfModels}}
|
|
171
|
+
{{#oneOfArrays}}
|
|
172
|
+
{{#if @first}}
|
|
173
|
+
if (Array.isArray(value)) {
|
|
174
|
+
if (value.every(item => typeof item === 'object')) {
|
|
175
|
+
{{/if}}
|
|
176
|
+
if (value.every(item => instanceOf{{{.}}}(item))) {
|
|
177
|
+
return value.map(value => {{{.}}}ToJSON(value as {{{.}}}));
|
|
178
|
+
}
|
|
179
|
+
{{#if @last}}
|
|
180
|
+
}
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
{{/if}}
|
|
184
|
+
{{/oneOfArrays}}
|
|
185
|
+
{{#oneOfPrimitives}}
|
|
186
|
+
{{#isArray}}
|
|
187
|
+
{{#items}}
|
|
188
|
+
{{#isDateType}}
|
|
189
|
+
if (Array.isArray(value)) {
|
|
190
|
+
if (value.every(item => item instanceof Date) {
|
|
191
|
+
return value.map(value => value.toISOString().substring(0,10)));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
{{/isDateType}}
|
|
195
|
+
{{#isDateTimeType}}
|
|
196
|
+
if (Array.isArray(value)) {
|
|
197
|
+
if (value.every(item => item instanceof Date) {
|
|
198
|
+
return value.map(value => value.toISOString();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
{{/isDateTimeType}}
|
|
202
|
+
{{#isNumeric}}
|
|
203
|
+
if (Array.isArray(value)) {
|
|
204
|
+
if (value.every(item => typeof item === 'number'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
{{/isNumeric}}
|
|
209
|
+
{{#isBoolean}}
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
if (value.every(item => typeof item === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
{{/isBoolean}}
|
|
216
|
+
{{#isString}}
|
|
217
|
+
if (Array.isArray(value)) {
|
|
218
|
+
if (value.every(item => typeof item === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}item === '{{.}}'{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}})) {
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
{{/isString}}
|
|
223
|
+
{{/items}}
|
|
224
|
+
{{/isArray}}
|
|
225
|
+
{{^isArray}}
|
|
226
|
+
{{#isDateType}}
|
|
227
|
+
if (value instanceof Date) {
|
|
228
|
+
return ((value{{#isNullable}} as any{{/isNullable}}){{^required}}{{#isNullable}}?{{/isNullable}}{{/required}}.toISOString().substring(0,10));
|
|
229
|
+
}
|
|
230
|
+
{{/isDateType}}
|
|
231
|
+
{{#isDateTimeType}}
|
|
232
|
+
if (value instanceof Date) {
|
|
233
|
+
return {{^required}}{{#isNullable}}value === null ? null : {{/isNullable}}{{^isNullable}}value == null ? undefined : {{/isNullable}}{{/required}}((value{{#isNullable}} as any{{/isNullable}}){{^required}}{{#isNullable}}?{{/isNullable}}{{/required}}.toISOString());
|
|
234
|
+
}
|
|
235
|
+
{{/isDateTimeType}}
|
|
236
|
+
{{#isNumeric}}
|
|
237
|
+
if (typeof value === 'number'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
238
|
+
return value;
|
|
239
|
+
}
|
|
240
|
+
{{/isNumeric}}
|
|
241
|
+
{{#isBoolean}}
|
|
242
|
+
if (typeof value === 'boolean'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === {{.}}{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
243
|
+
return value;
|
|
244
|
+
}
|
|
245
|
+
{{/isBoolean}}
|
|
246
|
+
{{#isString}}
|
|
247
|
+
if (typeof value === 'string'{{#isEnum}} && ({{#allowableValues}}{{#values}}value === '{{.}}'{{#unless @last}} || {{/unless}}{{/values}}{{/allowableValues}}){{/isEnum}}) {
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
{{/isString}}
|
|
251
|
+
{{/isArray}}
|
|
252
|
+
{{/oneOfPrimitives}}
|
|
253
|
+
return {};
|
|
254
|
+
{{/discriminator}}
|
|
255
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {{classname}}
|
|
3
|
+
* {{#indented_star_1}}{{{unescapedDescription}}}{{/indented_star_1}}
|
|
4
|
+
* @export
|
|
5
|
+
*/
|
|
6
|
+
export type {{classname}} = {{#discriminator}}{{#mappedModels}}{ {{discriminator.propertyName}}: '{{mappingName}}' } & {{modelName}}{{#unless @last}} | {{/unless}}{{/mappedModels}}{{/discriminator}}{{^discriminator}}{{#oneOf}}{{{.}}}{{#unless @last}} | {{/unless}}{{/oneOf}}{{/discriminator}};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{{#models}}{{#model}}
|
|
2
|
+
# {{classname}}
|
|
3
|
+
|
|
4
|
+
{{#if description}}{{&description}}
|
|
5
|
+
{{/if}}
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
Name | Type
|
|
10
|
+
------------ | -------------
|
|
11
|
+
{{#vars}}`{{name}}` | {{#isPrimitiveType}}{{dataType}}{{/isPrimitiveType}}{{^isPrimitiveType}}[{{dataType}}]({{complexType}}.md){{/isPrimitiveType}}
|
|
12
|
+
{{/vars}}
|
|
13
|
+
|
|
14
|
+
{{^withoutRuntimeChecks}}
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import type { {{classname}} } from '{{npmName}}'
|
|
19
|
+
|
|
20
|
+
// TODO: Update the object below with actual values
|
|
21
|
+
const example = {
|
|
22
|
+
{{#vars}}
|
|
23
|
+
"{{name}}": {{{example}}},
|
|
24
|
+
{{/vars}}
|
|
25
|
+
} satisfies {{classname}}
|
|
26
|
+
|
|
27
|
+
console.log(example)
|
|
28
|
+
|
|
29
|
+
// Convert the instance to a JSON string
|
|
30
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
31
|
+
console.log(exampleJSON)
|
|
32
|
+
|
|
33
|
+
// Parse the JSON string back to an object
|
|
34
|
+
const exampleParsed = JSON.parse(exampleJSON) as {{classname}}
|
|
35
|
+
console.log(exampleParsed)
|
|
36
|
+
```
|
|
37
|
+
{{/withoutRuntimeChecks}}
|
|
38
|
+
|
|
39
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
40
|
+
|
|
41
|
+
{{/model}}{{/models}}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
{{#models}}
|
|
4
|
+
{{#model}}
|
|
5
|
+
{{^withoutRuntimeChecks}}
|
|
6
|
+
export * from './{{{ classFilename }}}{{importFileExtension}}';
|
|
7
|
+
{{#useSagaAndRecords}}
|
|
8
|
+
{{^isEnum}}
|
|
9
|
+
export * from './{{{ classFilename }}}Record{{importFileExtension}}';
|
|
10
|
+
{{/isEnum}}
|
|
11
|
+
{{/useSagaAndRecords}}
|
|
12
|
+
{{/withoutRuntimeChecks}}
|
|
13
|
+
{{#withoutRuntimeChecks}}
|
|
14
|
+
{{#isEnum}}
|
|
15
|
+
{{>modelEnumInterfaces}}
|
|
16
|
+
|
|
17
|
+
{{/isEnum}}
|
|
18
|
+
{{^isEnum}}
|
|
19
|
+
{{#oneOf}}
|
|
20
|
+
{{#if @first}}
|
|
21
|
+
{{>modelOneOfInterfaces}}
|
|
22
|
+
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{/oneOf}}
|
|
25
|
+
{{^oneOf}}
|
|
26
|
+
{{>modelGenericInterfaces}}
|
|
27
|
+
|
|
28
|
+
{{/oneOf}}
|
|
29
|
+
{{/isEnum}}
|
|
30
|
+
{{/withoutRuntimeChecks}}
|
|
31
|
+
{{/model}}
|
|
32
|
+
{{/models}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
{{>licenseInfo}}
|
|
4
|
+
|
|
5
|
+
{{#models}}
|
|
6
|
+
{{#model}}
|
|
7
|
+
{{#isEnum}}
|
|
8
|
+
{{>modelEnum}}
|
|
9
|
+
|
|
10
|
+
{{/isEnum}}
|
|
11
|
+
{{^isEnum}}
|
|
12
|
+
{{#oneOf}}
|
|
13
|
+
{{#if @first}}
|
|
14
|
+
{{>modelOneOf}}
|
|
15
|
+
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{/oneOf}}
|
|
18
|
+
{{^oneOf}}
|
|
19
|
+
{{>modelGeneric}}
|
|
20
|
+
|
|
21
|
+
{{/oneOf}}
|
|
22
|
+
{{/isEnum}}
|
|
23
|
+
{{/model}}
|
|
24
|
+
{{/models}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
README.md
|