@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,606 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Configuration
|
|
4
|
+
* PHP version 8.1
|
|
5
|
+
*
|
|
6
|
+
* @category Class
|
|
7
|
+
* @package {{invokerPackage}}
|
|
8
|
+
* @author OpenAPI Generator team
|
|
9
|
+
* @link https://openapi-generator.tech
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
{{>partial_header}}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
16
|
+
* https://openapi-generator.tech
|
|
17
|
+
* Do not edit the class manually.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
namespace {{invokerPackage}};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Configuration Class Doc Comment
|
|
24
|
+
* PHP version 8.1
|
|
25
|
+
*
|
|
26
|
+
* @category Class
|
|
27
|
+
* @package {{invokerPackage}}
|
|
28
|
+
* @author OpenAPI Generator team
|
|
29
|
+
* @link https://openapi-generator.tech
|
|
30
|
+
*/
|
|
31
|
+
class Configuration
|
|
32
|
+
{
|
|
33
|
+
public const BOOLEAN_FORMAT_INT = 'int';
|
|
34
|
+
public const BOOLEAN_FORMAT_STRING = 'string';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @var Configuration
|
|
38
|
+
*/
|
|
39
|
+
private static $defaultConfiguration;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Associate array to store API key(s)
|
|
43
|
+
*
|
|
44
|
+
* @var string[]
|
|
45
|
+
*/
|
|
46
|
+
protected $apiKeys = [];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Associate array to store API prefix (e.g. Bearer)
|
|
50
|
+
*
|
|
51
|
+
* @var string[]
|
|
52
|
+
*/
|
|
53
|
+
protected $apiKeyPrefixes = [];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Access token for OAuth/Bearer authentication
|
|
57
|
+
*
|
|
58
|
+
* @var string
|
|
59
|
+
*/
|
|
60
|
+
protected $accessToken = '';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Boolean format for query string
|
|
64
|
+
*
|
|
65
|
+
* @var string
|
|
66
|
+
*/
|
|
67
|
+
protected $booleanFormatForQueryString = self::BOOLEAN_FORMAT_INT;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Username for HTTP basic authentication
|
|
71
|
+
*
|
|
72
|
+
* @var string
|
|
73
|
+
*/
|
|
74
|
+
protected $username = '';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Password for HTTP basic authentication
|
|
78
|
+
*
|
|
79
|
+
* @var string
|
|
80
|
+
*/
|
|
81
|
+
protected $password = '';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The host
|
|
85
|
+
*
|
|
86
|
+
* @var string
|
|
87
|
+
*/
|
|
88
|
+
protected $host = '{{basePath}}';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* User agent of the HTTP request, set to "OpenAPI-Generator/{version}/PHP" by default
|
|
92
|
+
*
|
|
93
|
+
* @var string
|
|
94
|
+
*/
|
|
95
|
+
protected $userAgent = '{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}{{^artifactVersion}}1.[0].0{{/artifactVersion}}/PHP{{/httpUserAgent}}';
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Debug switch (default set to false)
|
|
99
|
+
*
|
|
100
|
+
* @var bool
|
|
101
|
+
*/
|
|
102
|
+
protected $debug = false;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Debug file location (log to STDOUT by default)
|
|
106
|
+
*
|
|
107
|
+
* @var string
|
|
108
|
+
*/
|
|
109
|
+
protected $debugFile = 'php://output';
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Debug file location (log to STDOUT by default)
|
|
113
|
+
*
|
|
114
|
+
* @var string
|
|
115
|
+
*/
|
|
116
|
+
protected $tempFolderPath;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Path to a certificate file, for mTLS
|
|
120
|
+
*
|
|
121
|
+
* @var string
|
|
122
|
+
*/
|
|
123
|
+
protected $certFile;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Path to a key file, for mTLS
|
|
127
|
+
*
|
|
128
|
+
* @var string
|
|
129
|
+
*/
|
|
130
|
+
protected $keyFile;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Constructor
|
|
134
|
+
*/
|
|
135
|
+
public function __construct()
|
|
136
|
+
{
|
|
137
|
+
$this->tempFolderPath = sys_get_temp_dir();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Sets API key
|
|
142
|
+
*
|
|
143
|
+
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
|
144
|
+
* @param string $key API key or token
|
|
145
|
+
*
|
|
146
|
+
* @return $this
|
|
147
|
+
*/
|
|
148
|
+
public function setApiKey($apiKeyIdentifier, $key)
|
|
149
|
+
{
|
|
150
|
+
$this->apiKeys[$apiKeyIdentifier] = $key;
|
|
151
|
+
return $this;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Gets API key
|
|
156
|
+
*
|
|
157
|
+
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
|
158
|
+
*
|
|
159
|
+
* @return null|string API key or token
|
|
160
|
+
*/
|
|
161
|
+
public function getApiKey($apiKeyIdentifier)
|
|
162
|
+
{
|
|
163
|
+
return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sets the prefix for API key (e.g. Bearer)
|
|
168
|
+
*
|
|
169
|
+
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
|
170
|
+
* @param string $prefix API key prefix, e.g. Bearer
|
|
171
|
+
*
|
|
172
|
+
* @return $this
|
|
173
|
+
*/
|
|
174
|
+
public function setApiKeyPrefix($apiKeyIdentifier, $prefix)
|
|
175
|
+
{
|
|
176
|
+
$this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix;
|
|
177
|
+
return $this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Gets API key prefix
|
|
182
|
+
*
|
|
183
|
+
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
|
184
|
+
*
|
|
185
|
+
* @return null|string
|
|
186
|
+
*/
|
|
187
|
+
public function getApiKeyPrefix($apiKeyIdentifier)
|
|
188
|
+
{
|
|
189
|
+
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Sets the access token for OAuth
|
|
194
|
+
*
|
|
195
|
+
* @param string $accessToken Token for OAuth
|
|
196
|
+
*
|
|
197
|
+
* @return $this
|
|
198
|
+
*/
|
|
199
|
+
public function setAccessToken($accessToken)
|
|
200
|
+
{
|
|
201
|
+
$this->accessToken = $accessToken;
|
|
202
|
+
return $this;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Gets the access token for OAuth
|
|
207
|
+
*
|
|
208
|
+
* @return string Access token for OAuth
|
|
209
|
+
*/
|
|
210
|
+
public function getAccessToken()
|
|
211
|
+
{
|
|
212
|
+
return $this->accessToken;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Sets boolean format for query string.
|
|
217
|
+
*
|
|
218
|
+
* @param string $booleanFormat Boolean format for query string
|
|
219
|
+
*
|
|
220
|
+
* @return $this
|
|
221
|
+
*/
|
|
222
|
+
public function setBooleanFormatForQueryString(string $booleanFormat)
|
|
223
|
+
{
|
|
224
|
+
$this->booleanFormatForQueryString = $booleanFormat;
|
|
225
|
+
|
|
226
|
+
return $this;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Gets boolean format for query string.
|
|
231
|
+
*
|
|
232
|
+
* @return string Boolean format for query string
|
|
233
|
+
*/
|
|
234
|
+
public function getBooleanFormatForQueryString(): string
|
|
235
|
+
{
|
|
236
|
+
return $this->booleanFormatForQueryString;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Sets the username for HTTP basic authentication
|
|
241
|
+
*
|
|
242
|
+
* @param string $username Username for HTTP basic authentication
|
|
243
|
+
*
|
|
244
|
+
* @return $this
|
|
245
|
+
*/
|
|
246
|
+
public function setUsername($username)
|
|
247
|
+
{
|
|
248
|
+
$this->username = $username;
|
|
249
|
+
return $this;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Gets the username for HTTP basic authentication
|
|
254
|
+
*
|
|
255
|
+
* @return string Username for HTTP basic authentication
|
|
256
|
+
*/
|
|
257
|
+
public function getUsername()
|
|
258
|
+
{
|
|
259
|
+
return $this->username;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Sets the password for HTTP basic authentication
|
|
264
|
+
*
|
|
265
|
+
* @param string $password Password for HTTP basic authentication
|
|
266
|
+
*
|
|
267
|
+
* @return $this
|
|
268
|
+
*/
|
|
269
|
+
public function setPassword($password)
|
|
270
|
+
{
|
|
271
|
+
$this->password = $password;
|
|
272
|
+
return $this;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Gets the password for HTTP basic authentication
|
|
277
|
+
*
|
|
278
|
+
* @return string Password for HTTP basic authentication
|
|
279
|
+
*/
|
|
280
|
+
public function getPassword()
|
|
281
|
+
{
|
|
282
|
+
return $this->password;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Sets the host
|
|
287
|
+
*
|
|
288
|
+
* @param string $host Host
|
|
289
|
+
*
|
|
290
|
+
* @return $this
|
|
291
|
+
*/
|
|
292
|
+
public function setHost($host)
|
|
293
|
+
{
|
|
294
|
+
$this->host = $host;
|
|
295
|
+
return $this;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Gets the host
|
|
300
|
+
*
|
|
301
|
+
* @return string Host
|
|
302
|
+
*/
|
|
303
|
+
public function getHost()
|
|
304
|
+
{
|
|
305
|
+
return $this->host;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Sets the user agent of the api client
|
|
310
|
+
*
|
|
311
|
+
* @param string $userAgent the user agent of the api client
|
|
312
|
+
*
|
|
313
|
+
* @throws \InvalidArgumentException
|
|
314
|
+
* @return $this
|
|
315
|
+
*/
|
|
316
|
+
public function setUserAgent($userAgent)
|
|
317
|
+
{
|
|
318
|
+
if (!is_string($userAgent)) {
|
|
319
|
+
throw new \InvalidArgumentException('User-agent must be a string.');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
$this->userAgent = $userAgent;
|
|
323
|
+
return $this;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Gets the user agent of the api client
|
|
328
|
+
*
|
|
329
|
+
* @return string user agent
|
|
330
|
+
*/
|
|
331
|
+
public function getUserAgent()
|
|
332
|
+
{
|
|
333
|
+
return $this->userAgent;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Sets debug flag
|
|
338
|
+
*
|
|
339
|
+
* @param bool $debug Debug flag
|
|
340
|
+
*
|
|
341
|
+
* @return $this
|
|
342
|
+
*/
|
|
343
|
+
public function setDebug($debug)
|
|
344
|
+
{
|
|
345
|
+
$this->debug = $debug;
|
|
346
|
+
return $this;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Gets the debug flag
|
|
351
|
+
*
|
|
352
|
+
* @return bool
|
|
353
|
+
*/
|
|
354
|
+
public function getDebug()
|
|
355
|
+
{
|
|
356
|
+
return $this->debug;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Sets the debug file
|
|
361
|
+
*
|
|
362
|
+
* @param string $debugFile Debug file
|
|
363
|
+
*
|
|
364
|
+
* @return $this
|
|
365
|
+
*/
|
|
366
|
+
public function setDebugFile($debugFile)
|
|
367
|
+
{
|
|
368
|
+
$this->debugFile = $debugFile;
|
|
369
|
+
return $this;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Gets the debug file
|
|
374
|
+
*
|
|
375
|
+
* @return string
|
|
376
|
+
*/
|
|
377
|
+
public function getDebugFile()
|
|
378
|
+
{
|
|
379
|
+
return $this->debugFile;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Sets the temp folder path
|
|
384
|
+
*
|
|
385
|
+
* @param string $tempFolderPath Temp folder path
|
|
386
|
+
*
|
|
387
|
+
* @return $this
|
|
388
|
+
*/
|
|
389
|
+
public function setTempFolderPath($tempFolderPath)
|
|
390
|
+
{
|
|
391
|
+
$this->tempFolderPath = $tempFolderPath;
|
|
392
|
+
return $this;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Gets the temp folder path
|
|
397
|
+
*
|
|
398
|
+
* @return string Temp folder path
|
|
399
|
+
*/
|
|
400
|
+
public function getTempFolderPath()
|
|
401
|
+
{
|
|
402
|
+
return $this->tempFolderPath;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Sets the certificate file path, for mTLS
|
|
407
|
+
*
|
|
408
|
+
* @return $this
|
|
409
|
+
*/
|
|
410
|
+
public function setCertFile($certFile)
|
|
411
|
+
{
|
|
412
|
+
$this->certFile = $certFile;
|
|
413
|
+
return $this;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Gets the certificate file path, for mTLS
|
|
418
|
+
*
|
|
419
|
+
* @return string Certificate file path
|
|
420
|
+
*/
|
|
421
|
+
public function getCertFile()
|
|
422
|
+
{
|
|
423
|
+
return $this->certFile;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Sets the certificate key path, for mTLS
|
|
428
|
+
*
|
|
429
|
+
* @return $this
|
|
430
|
+
*/
|
|
431
|
+
public function setKeyFile($keyFile)
|
|
432
|
+
{
|
|
433
|
+
$this->keyFile = $keyFile;
|
|
434
|
+
return $this;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Gets the certificate key path, for mTLS
|
|
439
|
+
*
|
|
440
|
+
* @return string Certificate key path
|
|
441
|
+
*/
|
|
442
|
+
public function getKeyFile()
|
|
443
|
+
{
|
|
444
|
+
return $this->keyFile;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Gets the default configuration instance
|
|
450
|
+
*
|
|
451
|
+
* @return Configuration
|
|
452
|
+
*/
|
|
453
|
+
public static function getDefaultConfiguration()
|
|
454
|
+
{
|
|
455
|
+
if (self::$defaultConfiguration === null) {
|
|
456
|
+
self::$defaultConfiguration = new Configuration();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return self::$defaultConfiguration;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Sets the default configuration instance
|
|
464
|
+
*
|
|
465
|
+
* @param Configuration $config An instance of the Configuration Object
|
|
466
|
+
*
|
|
467
|
+
* @return void
|
|
468
|
+
*/
|
|
469
|
+
public static function setDefaultConfiguration(Configuration $config)
|
|
470
|
+
{
|
|
471
|
+
self::$defaultConfiguration = $config;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Gets the essential information for debugging
|
|
476
|
+
*
|
|
477
|
+
* @return string The report for debugging
|
|
478
|
+
*/
|
|
479
|
+
public static function toDebugReport()
|
|
480
|
+
{
|
|
481
|
+
$report = 'PHP SDK ({{invokerPackage}}) Debug Report:' . PHP_EOL;
|
|
482
|
+
$report .= ' OS: ' . php_uname() . PHP_EOL;
|
|
483
|
+
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
|
|
484
|
+
$report .= ' The version of the OpenAPI document: {{version}}' . PHP_EOL;
|
|
485
|
+
{{#artifactVersion}}
|
|
486
|
+
$report .= ' SDK Package Version: {{.}}' . PHP_EOL;
|
|
487
|
+
{{/artifactVersion}}
|
|
488
|
+
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
|
|
489
|
+
|
|
490
|
+
return $report;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Get API key (with prefix if set)
|
|
495
|
+
*
|
|
496
|
+
* @param string $apiKeyIdentifier name of apikey
|
|
497
|
+
*
|
|
498
|
+
* @return null|string API key with the prefix
|
|
499
|
+
*/
|
|
500
|
+
public function getApiKeyWithPrefix($apiKeyIdentifier)
|
|
501
|
+
{
|
|
502
|
+
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
|
|
503
|
+
$apiKey = $this->getApiKey($apiKeyIdentifier);
|
|
504
|
+
|
|
505
|
+
if ($apiKey === null) {
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if ($prefix === null) {
|
|
510
|
+
$keyWithPrefix = $apiKey;
|
|
511
|
+
} else {
|
|
512
|
+
$keyWithPrefix = $prefix . ' ' . $apiKey;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
return $keyWithPrefix;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Returns an array of host settings
|
|
520
|
+
*
|
|
521
|
+
* @return array an array of host settings
|
|
522
|
+
*/
|
|
523
|
+
public function getHostSettings()
|
|
524
|
+
{
|
|
525
|
+
return [
|
|
526
|
+
{{#servers}}
|
|
527
|
+
[
|
|
528
|
+
"url" => "{{{url}}}",
|
|
529
|
+
"description" => "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
|
530
|
+
{{#variables}}
|
|
531
|
+
{{#if @first}}
|
|
532
|
+
"variables" => [
|
|
533
|
+
{{/if}}
|
|
534
|
+
"{{{name}}}" => [
|
|
535
|
+
"description" => "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
|
536
|
+
"default_value" => "{{{defaultValue}}}",
|
|
537
|
+
{{#enumValues}}
|
|
538
|
+
{{#if @first}}
|
|
539
|
+
"enum_values" => [
|
|
540
|
+
{{/if}}
|
|
541
|
+
"{{{.}}}"{{#unless @last}},{{/unless}}
|
|
542
|
+
{{#if @last}}
|
|
543
|
+
]
|
|
544
|
+
{{/if}}
|
|
545
|
+
{{/enumValues}}
|
|
546
|
+
]{{#unless @last}},{{/unless}}
|
|
547
|
+
{{#if @last}}
|
|
548
|
+
]
|
|
549
|
+
{{/if}}
|
|
550
|
+
{{/variables}}
|
|
551
|
+
]{{#unless @last}},{{/unless}}
|
|
552
|
+
{{/servers}}
|
|
553
|
+
];
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Returns URL based on host settings, index and variables
|
|
558
|
+
*
|
|
559
|
+
* @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients
|
|
560
|
+
* @param int $hostIndex index of the host settings
|
|
561
|
+
* @param array|null $variables hash of variable and the corresponding value (optional)
|
|
562
|
+
* @return string URL based on host settings
|
|
563
|
+
*/
|
|
564
|
+
public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null)
|
|
565
|
+
{
|
|
566
|
+
if (null === $variables) {
|
|
567
|
+
$variables = [];
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// check array index out of bound
|
|
571
|
+
if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
|
|
572
|
+
throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostSettings));
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
$host = $hostSettings[$hostIndex];
|
|
576
|
+
$url = $host["url"];
|
|
577
|
+
|
|
578
|
+
// go through variable and assign a value
|
|
579
|
+
foreach ($host["variables"] ?? [] as $name => $variable) {
|
|
580
|
+
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
|
|
581
|
+
if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
|
|
582
|
+
$url = str_replace("{".$name."}", $variables[$name], $url);
|
|
583
|
+
} else {
|
|
584
|
+
throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"]).".");
|
|
585
|
+
}
|
|
586
|
+
} else {
|
|
587
|
+
// use default value
|
|
588
|
+
$url = str_replace("{".$name."}", $variable["default_value"], $url);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return $url;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Returns URL based on the index and variables
|
|
597
|
+
*
|
|
598
|
+
* @param int $index index of the host settings
|
|
599
|
+
* @param array|null $variables hash of variable and the corresponding value (optional)
|
|
600
|
+
* @return string URL based on host settings
|
|
601
|
+
*/
|
|
602
|
+
public function getHostFromSettings($index, $variables = null)
|
|
603
|
+
{
|
|
604
|
+
return self::getHostString($this->getHostSettings(), $index, $variables);
|
|
605
|
+
}
|
|
606
|
+
}
|