@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,81 @@
|
|
|
1
|
+
# {{packageName}}.{{classname}}{{#if description}}
|
|
2
|
+
{{description}}{{/if}}
|
|
3
|
+
|
|
4
|
+
All URIs are relative to *{{basePath}}*
|
|
5
|
+
|
|
6
|
+
Method | HTTP request | Description
|
|
7
|
+
------------- | ------------- | -------------
|
|
8
|
+
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
|
9
|
+
{{/operation}}{{/operations}}
|
|
10
|
+
|
|
11
|
+
{{#operations}}
|
|
12
|
+
{{#operation}}
|
|
13
|
+
# **{{{operationId}}}**
|
|
14
|
+
> {{#if returnType}}{{{returnType}}} {{/if}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}})
|
|
15
|
+
|
|
16
|
+
{{#if summary}}
|
|
17
|
+
{{{summary}}}
|
|
18
|
+
|
|
19
|
+
{{/if}}
|
|
20
|
+
{{#unescapedNotes}}
|
|
21
|
+
{{{.}}}
|
|
22
|
+
|
|
23
|
+
{{/unescapedNotes}}
|
|
24
|
+
### Example
|
|
25
|
+
|
|
26
|
+
{{#hasAuthMethods}}
|
|
27
|
+
{{#authMethods}}
|
|
28
|
+
{{#isBasic}}
|
|
29
|
+
{{#isBasicBasic}}
|
|
30
|
+
* Basic Authentication ({{name}}):
|
|
31
|
+
{{/isBasicBasic}}
|
|
32
|
+
{{#isBasicBearer}}
|
|
33
|
+
* Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}):
|
|
34
|
+
{{/isBasicBearer}}
|
|
35
|
+
{{/isBasic}}
|
|
36
|
+
{{#isApiKey}}
|
|
37
|
+
* Api Key Authentication ({{name}}):
|
|
38
|
+
{{/isApiKey }}
|
|
39
|
+
{{#isOAuth}}
|
|
40
|
+
* OAuth Authentication ({{name}}):
|
|
41
|
+
{{/isOAuth }}
|
|
42
|
+
{{/authMethods}}
|
|
43
|
+
{{/hasAuthMethods}}
|
|
44
|
+
{{> api_doc_example }}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Parameters
|
|
48
|
+
|
|
49
|
+
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#if @last}}
|
|
50
|
+
Name | Type | Description | Notes
|
|
51
|
+
------------- | ------------- | ------------- | -------------{{/if}}{{/allParams}}
|
|
52
|
+
{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#if defaultValue}}[default to {{defaultValue}}]{{/if}}
|
|
53
|
+
{{/allParams}}
|
|
54
|
+
|
|
55
|
+
### Return type
|
|
56
|
+
|
|
57
|
+
{{#if returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/if}}{{#unless returnType}}void (empty response body){{/unless}}
|
|
58
|
+
|
|
59
|
+
### Authorization
|
|
60
|
+
|
|
61
|
+
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{#unless @last}}, {{/unless}}{{/authMethods}}
|
|
62
|
+
|
|
63
|
+
### HTTP request headers
|
|
64
|
+
|
|
65
|
+
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#unless @last}}, {{/unless}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
|
66
|
+
- **Accept**: {{#produces}}{{{mediaType}}}{{#unless @last}}, {{/unless}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
|
67
|
+
|
|
68
|
+
{{#if responses}}
|
|
69
|
+
### HTTP response details
|
|
70
|
+
|
|
71
|
+
| Status code | Description | Response headers |
|
|
72
|
+
|-------------|-------------|------------------|
|
|
73
|
+
{{#responses}}
|
|
74
|
+
**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{#unless headers}} - {{/if}} |
|
|
75
|
+
{{/responses}}
|
|
76
|
+
{{/if}}
|
|
77
|
+
|
|
78
|
+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
|
79
|
+
|
|
80
|
+
{{/operation}}
|
|
81
|
+
{{/operations}}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
```python
|
|
3
|
+
import {{{packageName}}}
|
|
4
|
+
{{#vendorExtensions.x-py-example-import}}
|
|
5
|
+
{{{.}}}
|
|
6
|
+
{{/vendorExtensions.x-py-example-import}}
|
|
7
|
+
from {{{packageName}}}.rest import ApiException
|
|
8
|
+
from pprint import pprint
|
|
9
|
+
|
|
10
|
+
{{> python_doc_auth_partial}}
|
|
11
|
+
|
|
12
|
+
# Enter a context with an instance of the API client
|
|
13
|
+
{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
|
14
|
+
# Create an instance of the API class
|
|
15
|
+
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
|
16
|
+
{{#allParams}}
|
|
17
|
+
{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#if defaultValue}} (default to {{{defaultValue}}}){{/if}}
|
|
18
|
+
{{/allParams}}
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
{{#if summary}}
|
|
22
|
+
# {{{summary}}}
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if returnType}}api_response = {{/if}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}})
|
|
25
|
+
{{#if returnType}}
|
|
26
|
+
print("The response of {{classname}}->{{operationId}}:\n")
|
|
27
|
+
pprint(api_response)
|
|
28
|
+
{{/if}}
|
|
29
|
+
except Exception as e:
|
|
30
|
+
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
{{#vendorExtensions.x-py-postponed-example-imports.size}}
|
|
34
|
+
{{#vendorExtensions.x-py-postponed-example-imports}}
|
|
35
|
+
{{{.}}}
|
|
36
|
+
{{/vendorExtensions.x-py-postponed-example-imports}}
|
|
37
|
+
{{classname}}.update_forward_refs()
|
|
38
|
+
{{/vendorExtensions.x-py-postponed-example-imports.size}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""API response object."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from typing import Optional, Generic, Mapping, TypeVar
|
|
5
|
+
from pydantic import Field, StrictInt, StrictBytes, BaseModel
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
8
|
+
|
|
9
|
+
class ApiResponse(BaseModel, Generic[T]):
|
|
10
|
+
"""
|
|
11
|
+
API response object
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
status_code: StrictInt = Field(description="HTTP status code")
|
|
15
|
+
headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers")
|
|
16
|
+
data: T = Field(description="Deserialized data given the data type")
|
|
17
|
+
raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
|
|
18
|
+
|
|
19
|
+
model_config = {
|
|
20
|
+
"arbitrary_types_allowed": True
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
{{>partial_header}}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
from {{apiPackage}}.{{classFilename}} import {{classname}}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class {{#operations}}Test{{classname}}(unittest.{{#async}}IsolatedAsyncio{{/async}}TestCase):
|
|
12
|
+
"""{{classname}} unit test stubs"""
|
|
13
|
+
|
|
14
|
+
{{#async}}
|
|
15
|
+
async def asyncSetUp(self) -> None:
|
|
16
|
+
self.api = {{classname}}()
|
|
17
|
+
|
|
18
|
+
async def asyncTearDown(self) -> None:
|
|
19
|
+
await self.api.api_client.close()
|
|
20
|
+
{{/async}}
|
|
21
|
+
{{^async}}
|
|
22
|
+
def setUp(self) -> None:
|
|
23
|
+
self.api = {{classname}}()
|
|
24
|
+
|
|
25
|
+
def tearDown(self) -> None:
|
|
26
|
+
pass
|
|
27
|
+
{{/async}}
|
|
28
|
+
|
|
29
|
+
{{#operation}}
|
|
30
|
+
{{#async}}
|
|
31
|
+
async def test_{{operationId}}(self) -> None:
|
|
32
|
+
{{/async}}
|
|
33
|
+
{{^async}}
|
|
34
|
+
def test_{{operationId}}(self) -> None:
|
|
35
|
+
{{/async}}
|
|
36
|
+
"""Test case for {{{operationId}}}
|
|
37
|
+
|
|
38
|
+
{{#if summary}}
|
|
39
|
+
{{{summary}}}
|
|
40
|
+
{{/if}}
|
|
41
|
+
"""
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
{{/operation}}
|
|
45
|
+
{{/operations}}
|
|
46
|
+
|
|
47
|
+
if __name__ == '__main__':
|
|
48
|
+
unittest.main()
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
{{>partial_header}}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import io
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
import ssl
|
|
10
|
+
from typing import Optional, Union
|
|
11
|
+
|
|
12
|
+
import aiohttp
|
|
13
|
+
import aiohttp_retry
|
|
14
|
+
|
|
15
|
+
from {{packageName}}.exceptions import ApiException, ApiValueError
|
|
16
|
+
|
|
17
|
+
RESTResponseType = aiohttp.ClientResponse
|
|
18
|
+
|
|
19
|
+
ALLOW_RETRY_METHODS = frozenset({'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE'})
|
|
20
|
+
|
|
21
|
+
class RESTResponse(io.IOBase):
|
|
22
|
+
|
|
23
|
+
def __init__(self, resp) -> None:
|
|
24
|
+
self.response = resp
|
|
25
|
+
self.status = resp.status
|
|
26
|
+
self.reason = resp.reason
|
|
27
|
+
self.data = None
|
|
28
|
+
|
|
29
|
+
async def read(self):
|
|
30
|
+
if self.data is None:
|
|
31
|
+
self.data = await self.response.read()
|
|
32
|
+
return self.data
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def headers(self):
|
|
36
|
+
"""Returns a CIMultiDictProxy of response headers."""
|
|
37
|
+
return self.response.headers
|
|
38
|
+
|
|
39
|
+
def getheaders(self):
|
|
40
|
+
"""Returns a CIMultiDictProxy of the response headers; use ``headers`` instead."""
|
|
41
|
+
return self.response.headers
|
|
42
|
+
|
|
43
|
+
def getheader(self, name, default=None):
|
|
44
|
+
"""Returns a given response header; use ``headers.get()`` instead."""
|
|
45
|
+
return self.response.headers.get(name, default)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class RESTClientObject:
|
|
49
|
+
|
|
50
|
+
def __init__(self, configuration) -> None:
|
|
51
|
+
|
|
52
|
+
# maxsize is number of requests to host that are allowed in parallel
|
|
53
|
+
self.maxsize = configuration.connection_pool_maxsize
|
|
54
|
+
|
|
55
|
+
self.ssl_context = ssl.create_default_context(
|
|
56
|
+
cafile=configuration.ssl_ca_cert,
|
|
57
|
+
cadata=configuration.ca_cert_data,
|
|
58
|
+
)
|
|
59
|
+
if configuration.cert_file:
|
|
60
|
+
self.ssl_context.load_cert_chain(
|
|
61
|
+
configuration.cert_file, keyfile=configuration.key_file
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if not configuration.verify_ssl:
|
|
65
|
+
self.ssl_context.check_hostname = False
|
|
66
|
+
self.ssl_context.verify_mode = ssl.CERT_NONE
|
|
67
|
+
|
|
68
|
+
self.proxy = configuration.proxy
|
|
69
|
+
self.proxy_headers = configuration.proxy_headers
|
|
70
|
+
|
|
71
|
+
self.retries = configuration.retries
|
|
72
|
+
|
|
73
|
+
self.pool_manager: Optional[aiohttp.ClientSession] = None
|
|
74
|
+
self.retry_client: Optional[aiohttp_retry.RetryClient] = None
|
|
75
|
+
|
|
76
|
+
async def close(self) -> None:
|
|
77
|
+
if self.pool_manager:
|
|
78
|
+
await self.pool_manager.close()
|
|
79
|
+
if self.retry_client is not None:
|
|
80
|
+
await self.retry_client.close()
|
|
81
|
+
|
|
82
|
+
async def request(
|
|
83
|
+
self,
|
|
84
|
+
method,
|
|
85
|
+
url,
|
|
86
|
+
headers=None,
|
|
87
|
+
body=None,
|
|
88
|
+
post_params=None,
|
|
89
|
+
_request_timeout=None
|
|
90
|
+
):
|
|
91
|
+
"""Execute request
|
|
92
|
+
|
|
93
|
+
:param method: http request method
|
|
94
|
+
:param url: http request url
|
|
95
|
+
:param headers: http request headers
|
|
96
|
+
:param body: request json body, for `application/json`
|
|
97
|
+
:param post_params: request post parameters,
|
|
98
|
+
`application/x-www-form-urlencoded`
|
|
99
|
+
and `multipart/form-data`
|
|
100
|
+
:param _request_timeout: timeout setting for this request. If one
|
|
101
|
+
number provided, it will be total request
|
|
102
|
+
timeout. It can also be a pair (tuple) of
|
|
103
|
+
(connection, read) timeouts.
|
|
104
|
+
"""
|
|
105
|
+
method = method.upper()
|
|
106
|
+
assert method in [
|
|
107
|
+
'GET',
|
|
108
|
+
'HEAD',
|
|
109
|
+
'DELETE',
|
|
110
|
+
'POST',
|
|
111
|
+
'PUT',
|
|
112
|
+
'PATCH',
|
|
113
|
+
'OPTIONS'
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
if post_params and body:
|
|
117
|
+
raise ApiValueError(
|
|
118
|
+
"body parameter cannot be used with post_params parameter."
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
post_params = post_params or {}
|
|
122
|
+
headers = headers or {}
|
|
123
|
+
# url already contains the URL query string
|
|
124
|
+
timeout = _request_timeout or 5 * 60
|
|
125
|
+
|
|
126
|
+
if 'Content-Type' not in headers:
|
|
127
|
+
headers['Content-Type'] = 'application/json'
|
|
128
|
+
|
|
129
|
+
args = {
|
|
130
|
+
"method": method,
|
|
131
|
+
"url": url,
|
|
132
|
+
"timeout": timeout,
|
|
133
|
+
"headers": headers
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if self.proxy:
|
|
137
|
+
args["proxy"] = self.proxy
|
|
138
|
+
if self.proxy_headers:
|
|
139
|
+
args["proxy_headers"] = self.proxy_headers
|
|
140
|
+
|
|
141
|
+
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
|
142
|
+
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
|
143
|
+
if re.search('json', headers['Content-Type'], re.IGNORECASE):
|
|
144
|
+
if body is not None:
|
|
145
|
+
body = json.dumps(body)
|
|
146
|
+
args["data"] = body
|
|
147
|
+
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
|
|
148
|
+
args["data"] = aiohttp.FormData(post_params)
|
|
149
|
+
elif headers['Content-Type'] == 'multipart/form-data':
|
|
150
|
+
# must del headers['Content-Type'], or the correct
|
|
151
|
+
# Content-Type which generated by aiohttp
|
|
152
|
+
del headers['Content-Type']
|
|
153
|
+
data = aiohttp.FormData()
|
|
154
|
+
for param in post_params:
|
|
155
|
+
k, v = param
|
|
156
|
+
if isinstance(v, tuple) and len(v) == 3:
|
|
157
|
+
data.add_field(
|
|
158
|
+
k,
|
|
159
|
+
value=v[1],
|
|
160
|
+
filename=v[0],
|
|
161
|
+
content_type=v[2]
|
|
162
|
+
)
|
|
163
|
+
else:
|
|
164
|
+
# Ensures that dict objects are serialized
|
|
165
|
+
if isinstance(v, dict):
|
|
166
|
+
v = json.dumps(v)
|
|
167
|
+
elif isinstance(v, int):
|
|
168
|
+
v = str(v)
|
|
169
|
+
data.add_field(k, v)
|
|
170
|
+
args["data"] = data
|
|
171
|
+
|
|
172
|
+
# Pass a `bytes` or `str` parameter directly in the body to support
|
|
173
|
+
# other content types than Json when `body` argument is provided
|
|
174
|
+
# in serialized form
|
|
175
|
+
elif isinstance(body, str) or isinstance(body, bytes):
|
|
176
|
+
args["data"] = body
|
|
177
|
+
else:
|
|
178
|
+
# Cannot generate the request from given parameters
|
|
179
|
+
msg = """Cannot prepare a request message for provided
|
|
180
|
+
arguments. Please check that your arguments match
|
|
181
|
+
declared content type."""
|
|
182
|
+
raise ApiException(status=0, reason=msg)
|
|
183
|
+
|
|
184
|
+
pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient]
|
|
185
|
+
|
|
186
|
+
# https pool manager
|
|
187
|
+
if self.pool_manager is None:
|
|
188
|
+
self.pool_manager = aiohttp.ClientSession(
|
|
189
|
+
connector=aiohttp.TCPConnector(limit=self.maxsize, ssl=self.ssl_context),
|
|
190
|
+
trust_env=True,
|
|
191
|
+
)
|
|
192
|
+
pool_manager = self.pool_manager
|
|
193
|
+
|
|
194
|
+
if self.retries is not None and method in ALLOW_RETRY_METHODS:
|
|
195
|
+
if self.retry_client is None:
|
|
196
|
+
self.retry_client = aiohttp_retry.RetryClient(
|
|
197
|
+
client_session=self.pool_manager,
|
|
198
|
+
retry_options=aiohttp_retry.ExponentialRetry(
|
|
199
|
+
attempts=self.retries,
|
|
200
|
+
factor=2.0,
|
|
201
|
+
start_timeout=0.1,
|
|
202
|
+
max_timeout=120.0
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
pool_manager = self.retry_client
|
|
206
|
+
|
|
207
|
+
r = await pool_manager.request(**args)
|
|
208
|
+
|
|
209
|
+
return RESTResponse(r)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
```python
|
|
2
|
+
{{#apiInfo}}{{#apis}}{{#if @last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/if}}{{/apis}}{{/apiInfo}}
|
|
3
|
+
import {{{packageName}}}
|
|
4
|
+
from {{{packageName}}}.rest import ApiException
|
|
5
|
+
from pprint import pprint
|
|
6
|
+
{{#apiInfo}}{{#apis}}{{#if @first}}{{#operations}}{{#operation}}{{#if @first}}
|
|
7
|
+
{{> python_doc_auth_partial}}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Enter a context with an instance of the API client
|
|
11
|
+
{{#async}}async {{/async}}with {{{packageName}}}.ApiClient(configuration) as api_client:
|
|
12
|
+
# Create an instance of the API class
|
|
13
|
+
api_instance = {{{packageName}}}.{{{classname}}}(api_client)
|
|
14
|
+
{{#allParams}}
|
|
15
|
+
{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#if defaultValue}} (default to {{{defaultValue}}}){{/if}}
|
|
16
|
+
{{/allParams}}
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
{{#if summary}}
|
|
20
|
+
# {{{summary}}}
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if returnType}}api_response = {{/if}}{{#async}}await {{/async}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#unless @last}}, {{/unless}}{{/allParams}})
|
|
23
|
+
{{#if returnType}}
|
|
24
|
+
print("The response of {{classname}}->{{operationId}}:\n")
|
|
25
|
+
pprint(api_response)
|
|
26
|
+
{{/if}}
|
|
27
|
+
except ApiException as e:
|
|
28
|
+
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
|
29
|
+
{{/if}}{{/operation}}{{/operations}}{{/if}}{{/apis}}{{/apiInfo}}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Documentation for API Endpoints
|
|
33
|
+
|
|
34
|
+
All URIs are relative to *{{{basePath}}}*
|
|
35
|
+
|
|
36
|
+
Class | Method | HTTP request | Description
|
|
37
|
+
------------ | ------------- | ------------- | -------------
|
|
38
|
+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{summary}}
|
|
39
|
+
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
40
|
+
|
|
41
|
+
## Documentation For Models
|
|
42
|
+
|
|
43
|
+
{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
|
44
|
+
{{/model}}{{/models}}
|
|
45
|
+
|
|
46
|
+
<a id="documentation-for-authorization"></a>
|
|
47
|
+
## Documentation For Authorization
|
|
48
|
+
|
|
49
|
+
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
|
|
50
|
+
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
|
|
51
|
+
{{#authMethods}}
|
|
52
|
+
<a id="{{name}}"></a>
|
|
53
|
+
### {{{name}}}
|
|
54
|
+
|
|
55
|
+
{{#isApiKey}}
|
|
56
|
+
- **Type**: API key
|
|
57
|
+
- **API key parameter name**: {{{keyParamName}}}
|
|
58
|
+
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
|
59
|
+
{{/isApiKey}}
|
|
60
|
+
{{#isBasic}}
|
|
61
|
+
{{#isBasicBasic}}
|
|
62
|
+
- **Type**: HTTP basic authentication
|
|
63
|
+
{{/isBasicBasic}}
|
|
64
|
+
{{#isBasicBearer}}
|
|
65
|
+
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
|
|
66
|
+
{{/isBasicBearer}}
|
|
67
|
+
{{#isHttpSignature}}
|
|
68
|
+
- **Type**: HTTP signature authentication
|
|
69
|
+
{{/isHttpSignature}}
|
|
70
|
+
{{/isBasic}}
|
|
71
|
+
{{#isOAuth}}
|
|
72
|
+
- **Type**: OAuth
|
|
73
|
+
- **Flow**: {{{flow}}}
|
|
74
|
+
- **Authorization URL**: {{{authorizationUrl}}}
|
|
75
|
+
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
|
76
|
+
{{#scopes}} - **{{{scope}}}**: {{{description}}}
|
|
77
|
+
{{/scopes}}
|
|
78
|
+
{{/isOAuth}}
|
|
79
|
+
|
|
80
|
+
{{/authMethods}}
|
|
81
|
+
|
|
82
|
+
## Author
|
|
83
|
+
|
|
84
|
+
{{#apiInfo}}{{#apis}}{{#if @last}}{{infoEmail}}
|
|
85
|
+
{{/if}}{{/apis}}{{/apiInfo}}
|