diff --git a/bin/configs/typescript-fetch-with-awsv4-signature.yaml b/bin/configs/typescript-fetch-with-awsv4-signature.yaml new file mode 100644 index 000000000000..05dedc393de6 --- /dev/null +++ b/bin/configs/typescript-fetch-with-awsv4-signature.yaml @@ -0,0 +1,10 @@ +generatorName: typescript-fetch +outputDir: samples/client/petstore/typescript-fetch/builds/with-awsv4-signature +inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/typescript-fetch +additionalProperties: + npmVersion: 1.0.0 + npmName: '@openapitools/typescript-fetch-petstore' + npmRepository: https://skimdb.npmjs.com/registry + withAWSV4Signature: true + snapshot: false \ No newline at end of file diff --git a/bin/configs/typescript-fetch-with-npm-version.yaml b/bin/configs/typescript-fetch-with-npm-version.yaml index cd669c5e0d2a..e90426909bbe 100644 --- a/bin/configs/typescript-fetch-with-npm-version.yaml +++ b/bin/configs/typescript-fetch-with-npm-version.yaml @@ -5,5 +5,4 @@ templateDir: modules/openapi-generator/src/main/resources/typescript-fetch additionalProperties: npmVersion: 1.0.0 npmName: '@openapitools/typescript-fetch-petstore' - npmRepository: https://skimdb.npmjs.com/registry - snapshot: false + npmRepository: https://skimdb.npmjs.com/registry \ No newline at end of file diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md index 3eb9ff975901..cecc7fed7dec 100644 --- a/docs/generators/typescript-fetch.md +++ b/docs/generators/typescript-fetch.md @@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |stringEnums|Generate string enums instead of objects for enum values.| |false| |supportsES6|Generate code that conforms to ES6.| |false| |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true| +|withAWSV4Signature|whether to include AWS v4 signature support| |false| |withInterfaces|Setting this property to true will generate interfaces next to the default class implementations.| |false| |withoutRuntimeChecks|Setting this property to true will remove any runtime checks on the request and response payloads. Payloads will be casted to their expected types.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 2feca0467c1d..54e958bc2410 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -245,6 +245,7 @@ protected String nullableQuotedJSString(@Nullable String string) { protected HashSet languageGenericTypes; protected String npmName = null; protected String npmVersion = "1.0.0"; + protected Boolean withAWSV4Signature = false; protected String enumSuffix = "Enum"; @@ -404,6 +405,10 @@ public void processOpts() { if (additionalProperties.containsKey(NPM_NAME)) { this.setNpmName(additionalProperties.get(NPM_NAME).toString()); } + + if (additionalProperties.containsKey(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)) { + this.setWithAWSV4Signature(Boolean.valueOf(additionalProperties.get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT).toString())); + } } @Override @@ -1013,6 +1018,14 @@ public void setNpmVersion(String npmVersion) { this.npmVersion = npmVersion; } + public Boolean getWithAWSV4Signature() { + return this.withAWSV4Signature; + } + + public void setWithAWSV4Signature(Boolean withAWSV4Signature) { + this.withAWSV4Signature = withAWSV4Signature; + } + private void setDiscriminatorValue(CodegenModel model, String baseName, String value) { for (CodegenProperty prop : model.allVars) { if (prop.baseName.equals(baseName)) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java index 2892c2ca29f9..021547fa985c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java @@ -58,6 +58,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege protected boolean addedModelIndex = false; protected boolean withoutRuntimeChecks = false; protected boolean stringEnums = false; + private boolean withAWSV4Signature = false; // "Saga and Record" mode. public static final String SAGAS_AND_RECORDS = "sagasAndRecords"; @@ -105,6 +106,7 @@ public TypeScriptFetchClientCodegen() { this.cliOptions.add(new CliOption(SAGAS_AND_RECORDS, "Setting this property to true will generate additional files for use with redux-saga and immutablejs.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(IMPORT_FILE_EXTENSION_SWITCH, IMPORT_FILE_EXTENSION_SWITCH_DESC).defaultValue("")); + this.cliOptions.add(new CliOption(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString())); } @Override @@ -196,6 +198,10 @@ public void setPackageAsSourceOnlyLibrary(boolean packageAsSourceOnlyLibrary) { this.packageAsSourceOnlyLibrary = packageAsSourceOnlyLibrary; } + public void setWithAWSV4Signature(boolean withAWSV4Signature) { + this.withAWSV4Signature = withAWSV4Signature; + } + public boolean isUniqueIdAccordingToNameSuffix(String name) { if (name == null) { return false; @@ -286,6 +292,9 @@ public void processOpts() { } } } + if (additionalProperties.containsKey(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)) { + this.setWithAWSV4Signature(convertPropertyToBoolean(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)); + } } @Override diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index eabc8e9f9d3c..2682f7e5884e 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -258,40 +258,73 @@ export class {{classname}} extends runtime.BaseAPI { {{/isArray}} {{/formParams}} {{/hasFormParams}} - const response = await this.request({ + + + {{#hasBodyParam}} + {{#bodyParam}} + {{#isContainer}} + {{^withoutRuntimeChecks}} + const body: any = requestParameters.{{paramName}}{{#isArray}}{{#items}}{{^isPrimitiveType}}.map({{datatype}}ToJSON){{/isPrimitiveType}}{{/items}}{{/isArray}}; + {{/withoutRuntimeChecks}} + {{#withoutRuntimeChecks}} + const body: any = requestParameters.{{paramName}}; + {{/withoutRuntimeChecks}} + {{/isContainer}} + {{^isContainer}} + {{^isPrimitiveType}} + {{^withoutRuntimeChecks}} + const body: any = {{dataType}}ToJSON(requestParameters.{{paramName}}); + {{/withoutRuntimeChecks}} + {{#withoutRuntimeChecks}} + const body: any = requestParameters.{{paramName}}; + {{/withoutRuntimeChecks}} + {{/isPrimitiveType}} + {{#isPrimitiveType}} + const body: any = requestParameters.{{paramName}} as any; + {{/isPrimitiveType}} + {{/isContainer}} + {{/bodyParam}} + {{/hasBodyParam}} + {{#hasFormParams}} + const body: any = formParams; + {{/hasFormParams}} + + const request: runtime.RequestOpts = { path: `{{{path}}}`{{#pathParams}}.replace(`{${"{{baseName}}"}}`, encodeURIComponent(String(requestParameters.{{paramName}}))){{/pathParams}}, method: '{{httpMethod}}', headers: headerParameters, query: queryParameters, {{#hasBodyParam}} + body: body, + {{/hasBodyParam}} + {{#hasFormParams}} + body: body, + {{/hasFormParams}} + } + {{#withAWSV4Signature}} + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; {{#bodyParam}} - {{#isContainer}} - {{^withoutRuntimeChecks}} - body: requestParameters.{{paramName}}{{#isArray}}{{#items}}{{^isPrimitiveType}}.map({{datatype}}ToJSON){{/isPrimitiveType}}{{/items}}{{/isArray}}, - {{/withoutRuntimeChecks}} - {{#withoutRuntimeChecks}} - body: requestParameters.{{paramName}}, - {{/withoutRuntimeChecks}} - {{/isContainer}} - {{^isContainer}} - {{^isPrimitiveType}} + {{#hasBodyParam}} {{^withoutRuntimeChecks}} - body: {{dataType}}ToJSON(requestParameters.{{paramName}}), + const SignBody = JSON.stringify(request.body); {{/withoutRuntimeChecks}} {{#withoutRuntimeChecks}} - body: requestParameters.{{paramName}}, + const SignBody = request.body; {{/withoutRuntimeChecks}} - {{/isPrimitiveType}} - {{#isPrimitiveType}} - body: requestParameters.{{paramName}} as any, - {{/isPrimitiveType}} - {{/isContainer}} - {{/bodyParam}} {{/hasBodyParam}} - {{#hasFormParams}} - body: formParams, - {{/hasFormParams}} - }, initOverrides); + {{/bodyParam}} + {{^bodyParam}} + const SignBody = null; + {{/bodyParam}} + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('{{httpMethod}}', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + {{/withAWSV4Signature}} + const response = await this.request(request, initOverrides); {{#returnType}} {{#isResponseFile}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache index add4643dfe31..fe07c2881009 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache @@ -23,6 +23,9 @@ }, {{/packageAsSourceOnlyLibrary}} "devDependencies": { +{{#withAWSV4Signature}} + "aws4fetch": "^1.0.13" +{{/withAWSV4Signature}} {{#sagasAndRecords}} "immutable": "^4.0.0-rc.12", "normalizr": "^3.6.1", diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache index 0ffada861280..49e5f021f9b0 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache @@ -2,6 +2,10 @@ /* eslint-disable */ {{>licenseInfo}} +{{#withAWSV4Signature}} +import { AwsV4Signer as AwsV4SignerLib } from "aws4fetch"; +{{/withAWSV4Signature}} + export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -15,7 +19,42 @@ export interface ConfigurationParameters { accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security headers?: HTTPHeaders; //header params we want to use on every request credentials?: RequestCredentials; //value for the credentials param we want to use on each request + {{#withAWSV4Signature}} + awsV4SignParameters?: AwsV4SignerParameters; // parameter for aws v4 signature security + {{/withAWSV4Signature}} +} + +{{#withAWSV4Signature}} +export interface AwsV4SignerParameters { + accessKeyId: string; + secretAccessKey: string; + region: string; + service?: string; +} + +export class AwsV4Signer { + constructor(private configuration: AwsV4SignerParameters) {} + async sign(method: string, url: string, headers: HTTPHeaders, body: any): Promise<{url: URL, headers: HTTPHeaders}> { + const signer = new AwsV4SignerLib({ + method: method, + url: url, + headers: headers, + body: body, + accessKeyId: this.configuration.accessKeyId, + secretAccessKey: this.configuration.secretAccessKey, + service: this.configuration.service, + region: this.configuration.region, + }); + const signResult = await signer.sign(); + // Convert Headers to HTTPHeaders + let newHeaders: HTTPHeaders = {}; + for (const [key, value] of signResult.headers.entries()) { + newHeaders[key] = value; + } + return {url: signResult.url, headers: newHeaders}; + } } + {{/withAWSV4Signature}} export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} @@ -71,6 +110,11 @@ export class Configuration { get credentials(): RequestCredentials | undefined { return this.configuration.credentials; } +{{#withAWSV4Signature}} + get awsV4SignerParameters(): AwsV4SignerParameters | undefined { + return this.configuration.awsV4SignParameters; + } +{{/withAWSV4Signature}} } export const DefaultConfig = new Configuration(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java index 40adcda666f6..d2e9de24beef 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java @@ -44,6 +44,7 @@ public class TypeScriptFetchClientOptionsProvider implements OptionsProvider { public static final String SAGAS_AND_RECORDS = "false"; public static final String ENUM_UNKNOWN_DEFAULT_CASE_VALUE = "false"; public static final String STRING_ENUMS = "false"; + public static final String WITH_AWSV4_SIGNATURE = "false"; @Override public String getLanguage() { @@ -78,6 +79,7 @@ public Map createOptions() { .put(CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, "true") .put(CodegenConstants.ENUM_UNKNOWN_DEFAULT_CASE, ENUM_UNKNOWN_DEFAULT_CASE_VALUE) .put(TypeScriptFetchClientCodegen.STRING_ENUMS, STRING_ENUMS) + .put(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT, WITH_AWSV4_SIGNATURE) .build(); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java index afbf555beb34..c01b1ed5081b 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java @@ -53,5 +53,6 @@ protected void verifyOptions() { verify(clientCodegen).setSagasAndRecords(Boolean.valueOf(TypeScriptFetchClientOptionsProvider.SAGAS_AND_RECORDS)); verify(clientCodegen).setEnumUnknownDefaultCase(Boolean.parseBoolean(TypeScriptFetchClientOptionsProvider.ENUM_UNKNOWN_DEFAULT_CASE_VALUE)); verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptFetchClientOptionsProvider.STRING_ENUMS)); + verify(clientCodegen).setWithAWSV4Signature(Boolean.parseBoolean(TypeScriptFetchClientOptionsProvider.WITH_AWSV4_SIGNATURE)); } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java index fdef7148df8b..311758aecc7f 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java @@ -471,13 +471,13 @@ public void testNestedReadonlySchemas() { Assert.assertEquals(schemaBefore.keySet(), Sets.newHashSet("club", "owner")); } - @Test(description = "Don't generate new schemas for nullable references") - public void testNestedNullableSchemas() { - final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/allOf-nullable.yaml"); + @Test(description = "Don't add AWSv4 signature support by default") + public void testWithoutAWSV4SignatureAdditionalProps() { + final Schema model = new Schema() + .additionalProperties(new StringSchema()); final DefaultCodegen codegen = new TypeScriptFetchClientCodegen(); + codegen.additionalProperties().put("withAWSV4Signature", false); codegen.processOpts(); - codegen.setOpenAPI(openAPI); - final Map schemaBefore = openAPI.getComponents().getSchemas(); - Assert.assertEquals(schemaBefore.keySet(), Sets.newHashSet("club", "owner")); + Assert.assertEquals(codegen.getTypeDeclaration(model), "{ [key: string]: string; }"); } } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts index c682b272ac58..0acdfc71ac12 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/apis/DefaultApi.ts @@ -42,12 +42,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters.personId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClubFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts index b92abe556179..afddd7d871a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-nullable/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://api.example.xyz/v1".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts index c682b272ac58..0acdfc71ac12 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/apis/DefaultApi.ts @@ -42,12 +42,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/person/display/{personId}`.replace(`{${"personId"}}`, encodeURIComponent(String(requestParameters.personId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClubFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts index b92abe556179..afddd7d871a0 100644 --- a/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/allOf-readonly/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://api.example.xyz/v1".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts index 4248cc6d062e..d59b98f1e736 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/AnotherFakeApi.ts @@ -46,13 +46,18 @@ export class AnotherFakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/another-fake/dummy`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/DefaultApi.ts index ef9dde7a0809..041d8e8e049e 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/DefaultApi.ts @@ -34,12 +34,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/foo`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FooGetDefaultResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 0d9ea6361d7c..38d214b40262 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -159,12 +159,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/BigDecimalMap`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeBigDecimalMap200ResponseFromJSON(jsonValue)); } @@ -185,12 +189,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/health`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => HealthCheckResultFromJSON(jsonValue)); } @@ -225,13 +233,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['header_1'] = String(requestParameters.header1); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/fake/http-signature-test`, method: 'GET', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -253,13 +266,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/boolean`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -286,13 +304,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OuterCompositeToJSON(requestParameters.outerComposite); + + const request: runtime.RequestOpts = { path: `/fake/outer/composite`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterCompositeToJSON(requestParameters.outerComposite), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterCompositeFromJSON(jsonValue)); } @@ -315,13 +338,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/number`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -348,13 +376,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/string`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -385,13 +418,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty); + + const request: runtime.RequestOpts = { path: `/fake/property/enum-int`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterObjectWithEnumPropertyFromJSON(jsonValue)); } @@ -418,13 +456,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'image/png'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/body-with-binary`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -450,13 +493,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass); + + const request: runtime.RequestOpts = { path: `/fake/body-with-file-schema`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -489,13 +537,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/fake/body-with-query-params`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -521,13 +574,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/fake`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } @@ -641,13 +699,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('callback', requestParameters.callback as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake`, method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -719,13 +782,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('enum_form_string', requestParameters.enumFormString as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake`, method: 'GET', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -791,12 +859,16 @@ export class FakeApi extends runtime.BaseAPI { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake`, method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -824,13 +896,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.requestBody; + + const request: runtime.RequestOpts = { path: `/fake/inline-additionalProperties`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -882,13 +959,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('param2', requestParameters.param2 as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake/jsonFormData`, method: 'GET', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -961,12 +1043,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/test-query-parameters`, method: 'PUT', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts index 59d4fa0cad84..8aa83207ae1f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeClassnameTags123Api.ts @@ -50,13 +50,18 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { queryParameters["api_key_query"] = this.configuration.apiKey("api_key_query"); // api_key_query authentication } - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/fake_classname_test`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts index 59470c6e5385..afa70ea0d989 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/PetApi.ts @@ -93,13 +93,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -134,12 +139,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -174,12 +183,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -215,12 +228,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => new Set(jsonValue.map(PetFromJSON))); } @@ -251,12 +268,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -290,13 +311,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -349,13 +375,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -410,13 +441,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } @@ -476,13 +512,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('requiredFile', requestParameters.requiredFile as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts index 19475d0ed9f3..b6d2aa846e32 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -149,13 +161,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.order); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.order), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts index df5c8f4efcd4..f76e3f37c61b 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -106,13 +111,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.user.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -140,13 +150,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.user.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -172,12 +187,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -203,12 +222,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -247,12 +270,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -279,12 +306,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -316,13 +347,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts index c95b2ac453e5..ac86f9a6d365 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io:80/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts index 3a82dd1e7fb1..d74462998f3f 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/PetApi.ts @@ -86,13 +86,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -125,12 +130,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +173,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -205,12 +218,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -241,12 +258,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -279,13 +300,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -336,13 +362,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -395,13 +426,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts index dd007df3588c..af56308e6871 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts index 58f6a7e5d3af..fee1edb46dd2 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -105,13 +110,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -137,13 +147,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -168,12 +183,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -198,12 +217,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -240,12 +263,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -270,12 +297,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -306,13 +337,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/default/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/default/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts index 198072bfc065..b2009f3bb886 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/apis/DefaultApi.ts @@ -81,12 +81,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/enum-request-inline`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); } @@ -121,12 +125,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/enum-request-ref`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); } @@ -147,13 +155,18 @@ export class DefaultApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response); + + const request: runtime.RequestOpts = { path: `/fake/enum-request-inline`, method: 'POST', headers: headerParameters, query: queryParameters, - body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); } @@ -174,13 +187,18 @@ export class DefaultApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = EnumPatternObjectToJSON(requestParameters.enumPatternObject); + + const request: runtime.RequestOpts = { path: `/fake/enum-request-ref`, method: 'POST', headers: headerParameters, query: queryParameters, - body: EnumPatternObjectToJSON(requestParameters.enumPatternObject), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts index d4d2025e1e3c..53efb6d16fb1 100644 --- a/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/enum/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://localhost:3000".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/package-lock.json b/samples/client/petstore/typescript-fetch/builds/es6-target/package-lock.json new file mode 100644 index 000000000000..ddb785290d04 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "devDependencies": { + "typescript": "^4.0" + } + }, + "node_modules/typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true + } + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts index 3a82dd1e7fb1..d74462998f3f 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/PetApi.ts @@ -86,13 +86,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -125,12 +130,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +173,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -205,12 +218,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -241,12 +258,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -279,13 +300,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -336,13 +362,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -395,13 +426,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts index dd007df3588c..af56308e6871 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts index 58f6a7e5d3af..fee1edb46dd2 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -105,13 +110,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -137,13 +147,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -168,12 +183,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -198,12 +217,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -240,12 +263,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -270,12 +297,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -306,13 +337,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/es6-target/src/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts index 353bc45bd7c5..fac8b1a29e11 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/PetApi.ts @@ -86,13 +86,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -125,12 +130,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +173,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -205,12 +218,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -241,12 +258,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -279,13 +300,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -336,13 +362,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -395,13 +426,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts index d40d4aeceb06..da992c32b382 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts index 4397fef0a0eb..62dbed5c957d 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -105,13 +110,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -137,13 +147,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -168,12 +183,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -198,12 +217,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -240,12 +263,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -270,12 +297,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -306,13 +337,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/multiple-parameters/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/package-lock.json b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/package-lock.json new file mode 100644 index 000000000000..ddb785290d04 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "devDependencies": { + "typescript": "^4.0" + } + }, + "node_modules/typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true + } + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts index 9373a1f215a0..1f3293258134 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/PetApi.ts @@ -86,13 +86,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -125,12 +130,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +173,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -205,12 +218,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -241,12 +258,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -279,13 +300,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -336,13 +362,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -395,13 +426,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts index c51295bc1d03..5b965dc50a95 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts index 9738d83f9c64..e7b1e62909b0 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -105,13 +110,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -137,13 +147,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -168,12 +183,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -198,12 +217,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -240,12 +263,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -270,12 +297,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -306,13 +337,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/prefix-parameter-interfaces/src/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts index f1fbb107ba1a..c05f3bec12e9 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/BehaviorApi.ts @@ -50,12 +50,16 @@ export class BehaviorApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake_behavior/{behavior-id}/permissions`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters.behaviorId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetBehaviorPermissionsResponseFromJSON(jsonValue)); } @@ -80,12 +84,16 @@ export class BehaviorApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake_behavior/{behavior-id}/type`.replace(`{${"behavior-id"}}`, encodeURIComponent(String(requestParameters.behaviorId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetBehaviorTypeResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts index 9d6e88587dfe..f40b510ebc05 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts @@ -115,13 +115,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = CategoryToJSON(requestParameters.dummyCat); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: CategoryToJSON(requestParameters.dummyCat), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -154,12 +159,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -193,12 +202,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByIds`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -234,12 +247,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FindPetsByStatusResponseFromJSON(jsonValue)); } @@ -275,12 +292,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -316,12 +337,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByUserIds`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FindPetsByUserResponseFromJSON(jsonValue)); } @@ -352,12 +377,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -383,12 +412,16 @@ export class PetApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetRegionsResponseFromJSON(jsonValue)); } @@ -420,13 +453,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -456,13 +494,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.newRegions; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/regions`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.newRegions, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetRegionsResponseFromJSON(jsonValue)); } @@ -514,13 +557,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -573,13 +621,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts index 93fdede05ee7..e525830d47e1 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetPartApi.ts @@ -55,12 +55,16 @@ export class PetPartApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake_petParts/{fake_petPart-id}/part-type`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters.fakePetPartId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetPetPartTypeResponseFromJSON(jsonValue)); } @@ -117,12 +121,16 @@ export class PetPartApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake_petParts/{fake_petPart-id}/matching-parts`.replace(`{${"fake_petPart-id"}}`, encodeURIComponent(String(requestParameters.fakePetPartId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetMatchingPartsResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts index d40d4aeceb06..da992c32b382 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts index 2392a0df4c13..97f7faa550fd 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/UserApi.ts @@ -75,13 +75,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -108,13 +113,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -140,13 +150,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -171,12 +186,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -201,12 +220,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -243,12 +266,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -273,12 +300,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -309,13 +340,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => DefaultMetaOnlyResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts index 4248cc6d062e..d59b98f1e736 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/AnotherFakeApi.ts @@ -46,13 +46,18 @@ export class AnotherFakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/another-fake/dummy`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/DefaultApi.ts index ef9dde7a0809..041d8e8e049e 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/DefaultApi.ts @@ -34,12 +34,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/foo`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FooGetDefaultResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts index 0d9ea6361d7c..38d214b40262 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts @@ -159,12 +159,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/BigDecimalMap`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeBigDecimalMap200ResponseFromJSON(jsonValue)); } @@ -185,12 +189,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/health`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => HealthCheckResultFromJSON(jsonValue)); } @@ -225,13 +233,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['header_1'] = String(requestParameters.header1); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/fake/http-signature-test`, method: 'GET', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -253,13 +266,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/boolean`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -286,13 +304,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OuterCompositeToJSON(requestParameters.outerComposite); + + const request: runtime.RequestOpts = { path: `/fake/outer/composite`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterCompositeToJSON(requestParameters.outerComposite), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterCompositeFromJSON(jsonValue)); } @@ -315,13 +338,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/number`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -348,13 +376,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/outer/string`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -385,13 +418,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty); + + const request: runtime.RequestOpts = { path: `/fake/property/enum-int`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OuterObjectWithEnumPropertyToJSON(requestParameters.outerObjectWithEnumProperty), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OuterObjectWithEnumPropertyFromJSON(jsonValue)); } @@ -418,13 +456,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'image/png'; - const response = await this.request({ + + + const body: any = requestParameters.body as any; + + const request: runtime.RequestOpts = { path: `/fake/body-with-binary`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body as any, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -450,13 +493,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass); + + const request: runtime.RequestOpts = { path: `/fake/body-with-file-schema`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: FileSchemaTestClassToJSON(requestParameters.fileSchemaTestClass), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -489,13 +537,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/fake/body-with-query-params`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -521,13 +574,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/fake`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } @@ -641,13 +699,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('callback', requestParameters.callback as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake`, method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -719,13 +782,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('enum_form_string', requestParameters.enumFormString as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake`, method: 'GET', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -791,12 +859,16 @@ export class FakeApi extends runtime.BaseAPI { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake`, method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -824,13 +896,18 @@ export class FakeApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.requestBody; + + const request: runtime.RequestOpts = { path: `/fake/inline-additionalProperties`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.requestBody, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -882,13 +959,18 @@ export class FakeApi extends runtime.BaseAPI { formParams.append('param2', requestParameters.param2 as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake/jsonFormData`, method: 'GET', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -961,12 +1043,16 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/test-query-parameters`, method: 'PUT', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts index 59d4fa0cad84..8aa83207ae1f 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeClassnameTags123Api.ts @@ -50,13 +50,18 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI { queryParameters["api_key_query"] = this.configuration.apiKey("api_key_query"); // api_key_query authentication } - const response = await this.request({ + + + const body: any = ClientToJSON(requestParameters.client); + + const request: runtime.RequestOpts = { path: `/fake_classname_test`, method: 'PATCH', headers: headerParameters, query: queryParameters, - body: ClientToJSON(requestParameters.client), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ClientFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts index 59470c6e5385..afa70ea0d989 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/PetApi.ts @@ -93,13 +93,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -134,12 +139,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -174,12 +183,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -215,12 +228,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => new Set(jsonValue.map(PetFromJSON))); } @@ -251,12 +268,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -290,13 +311,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.pet); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.pet), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -349,13 +375,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -410,13 +441,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } @@ -476,13 +512,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('requiredFile', requestParameters.requiredFile as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/fake/{petId}/uploadImageWithRequiredFile`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts index 19475d0ed9f3..b6d2aa846e32 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{order_id}`.replace(`{${"order_id"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -149,13 +161,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.order); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.order), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts index df5c8f4efcd4..f76e3f37c61b 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -106,13 +111,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.user.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -140,13 +150,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.user.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.user.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -172,12 +187,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -203,12 +222,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -247,12 +270,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -279,12 +306,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -316,13 +347,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.user); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.user), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts index c95b2ac453e5..ac86f9a6d365 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io:80/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.gitignore b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.gitignore new file mode 100644 index 000000000000..149b57654723 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.npmignore b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.npmignore new file mode 100644 index 000000000000..42061c01a1c7 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.npmignore @@ -0,0 +1 @@ +README.md \ No newline at end of file diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator-ignore b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/FILES b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/FILES new file mode 100644 index 000000000000..38feffe8896a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/FILES @@ -0,0 +1,18 @@ +.gitignore +.npmignore +README.md +package.json +src/apis/PetApi.ts +src/apis/StoreApi.ts +src/apis/UserApi.ts +src/apis/index.ts +src/index.ts +src/models/Category.ts +src/models/ModelApiResponse.ts +src/models/Order.ts +src/models/Pet.ts +src/models/Tag.ts +src/models/User.ts +src/models/index.ts +src/runtime.ts +tsconfig.json diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/VERSION b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/VERSION new file mode 100644 index 000000000000..757e67400401 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/README.md b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/README.md new file mode 100644 index 000000000000..8c188be0ead2 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/README.md @@ -0,0 +1,45 @@ +## @openapitools/typescript-fetch-petstore@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments: + +Environment +* Node.js +* Webpack +* Browserify + +Language level +* ES5 - you must have a Promises/A+ library installed +* ES6 + +Module system +* CommonJS +* ES6 module system + +It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) + +### Building + +To build and compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### Publishing + +First build the package then run ```npm publish``` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +``` +npm install @openapitools/typescript-fetch-petstore@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/PetApi.ts new file mode 100644 index 000000000000..a62c7111a673 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/PetApi.ts @@ -0,0 +1,533 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + ModelApiResponse, + ModelApiResponseFromJSON, + ModelApiResponseToJSON, + Pet, + PetFromJSON, + PetToJSON, +} from '../models'; + +export interface AddPetRequest { + body: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + body: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: Blob; +} + +/** + * + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + const body: any = PetToJSON(requestParameters.body), + + const request: runtime.RequestOpts = { + path: `/pet`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.addPetRaw(requestParameters, initOverrides); + } + + /** + * Deletes a pet + */ + async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.deletePetRaw(requestParameters, initOverrides); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise>> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: any = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise>> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: any = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.getPetByIdRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Update an existing pet + */ + async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + const body: any = PetToJSON(requestParameters.body), + + const request: runtime.RequestOpts = { + path: `/pet`, + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('PUT', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.updatePetRaw(requestParameters, initOverrides); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + const consumes: runtime.Consume[] = [ + { contentType: 'application/x-www-form-urlencoded' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters.name !== undefined) { + formParams.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formParams.append('status', requestParameters.status as any); + } + + + + const body: any = formParams, + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.updatePetWithFormRaw(requestParameters, initOverrides); + } + + /** + * uploads an image + */ + async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + const consumes: runtime.Consume[] = [ + { contentType: 'multipart/form-data' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + // use FormData to transmit files using content-type "multipart/form-data" + useForm = canConsumeForm; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters.additionalMetadata !== undefined) { + formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formParams.append('file', requestParameters.file as any); + } + + + + const body: any = formParams, + + const request: runtime.RequestOpts = { + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.uploadFileRaw(requestParameters, initOverrides); + return await response.value(); + } + +} + +/** + * @export + */ +export const FindPetsByStatusStatusEnum = { + Available: 'available', + Pending: 'pending', + Sold: 'sold' +} as const; +export type FindPetsByStatusStatusEnum = typeof FindPetsByStatusStatusEnum[keyof typeof FindPetsByStatusStatusEnum]; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/StoreApi.ts new file mode 100644 index 000000000000..0b0a01208fff --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/StoreApi.ts @@ -0,0 +1,221 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + Order, + OrderFromJSON, + OrderToJSON, +} from '../models'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + body: Order; +} + +/** + * + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.deleteOrderRaw(requestParameters, initOverrides); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventoryRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + + + + const request: runtime.RequestOpts = { + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(initOverrides); + return await response.value(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.getOrderByIdRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Place an order for a pet + */ + async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = OrderToJSON(requestParameters.body), + + const request: runtime.RequestOpts = { + path: `/store/order`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.placeOrderRaw(requestParameters, initOverrides); + return await response.value(); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/UserApi.ts new file mode 100644 index 000000000000..c1fe985297c0 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/UserApi.ts @@ -0,0 +1,430 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import { + User, + UserFromJSON, + UserToJSON, +} from '../models'; + +export interface CreateUserRequest { + body: User; +} + +export interface CreateUsersWithArrayInputRequest { + body: Array; +} + +export interface CreateUsersWithListInputRequest { + body: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + body: User; +} + +/** + * + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = UserToJSON(requestParameters.body), + + const request: runtime.RequestOpts = { + path: `/user`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.createUserRaw(requestParameters, initOverrides); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = requestParameters.body.map(UserToJSON), + + const request: runtime.RequestOpts = { + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.createUsersWithArrayInputRaw(requestParameters, initOverrides); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = requestParameters.body.map(UserToJSON), + + const request: runtime.RequestOpts = { + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.createUsersWithListInputRaw(requestParameters, initOverrides); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.deleteUserRaw(requestParameters, initOverrides); + } + + /** + * Get user by user name + */ + async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.getUserByNameRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Logs user into the system + */ + async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: any = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.TextApiResponse(response) as any; + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + const response = await this.loginUserRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Logs out current logged in user session + */ + async logoutUserRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.logoutUserRaw(initOverrides); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = UserToJSON(requestParameters.body), + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('PUT', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + await this.updateUserRaw(requestParameters, initOverrides); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/index.ts new file mode 100644 index 000000000000..3b870e5c4aa8 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/apis/index.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/index.ts new file mode 100644 index 000000000000..be9d1edeefeb --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/index.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './runtime'; +export * from './apis'; +export * from './models'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Category.ts new file mode 100644 index 000000000000..fe0e21ffb8bc --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Category.ts @@ -0,0 +1,64 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], + }; +} + +export function CategoryToJSON(value?: Category | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/ModelApiResponse.ts new file mode 100644 index 000000000000..6812901c3770 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/ModelApiResponse.ts @@ -0,0 +1,72 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Order.ts new file mode 100644 index 000000000000..2e4f44f6469f --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Order.ts @@ -0,0 +1,108 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {Date} + * @memberof Order + */ + shipDate?: Date; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: OrderStatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + + +/** + * @export + */ +export const OrderStatusEnum = { + Placed: 'placed', + Approved: 'approved', + Delivered: 'delivered' +} as const; +export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum]; + + +export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], + }; +} + +export function OrderToJSON(value?: Order | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), + 'status': value.status, + 'complete': value.complete, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Pet.ts new file mode 100644 index 000000000000..1866bcb149e7 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Pet.ts @@ -0,0 +1,121 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import { + Category, + CategoryFromJSON, + CategoryFromJSONTyped, + CategoryToJSON, +} from './Category'; +import { + Tag, + TagFromJSON, + TagFromJSONTyped, + TagToJSON, +} from './Tag'; + +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: PetStatusEnum; +} + + +/** + * @export + */ +export const PetStatusEnum = { + Available: 'available', + Pending: 'pending', + Sold: 'sold' +} as const; +export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; + + +export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), + 'status': !exists(json, 'status') ? undefined : json['status'], + }; +} + +export function PetToJSON(value?: Pet | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), + 'status': value.status, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Tag.ts new file mode 100644 index 000000000000..0c26039df46a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/Tag.ts @@ -0,0 +1,64 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], + }; +} + +export function TagToJSON(value?: Tag | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/User.ts new file mode 100644 index 000000000000..89a7de983b01 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/User.ts @@ -0,0 +1,112 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} + +export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], + }; +} + +export function UserToJSON(value?: User | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/index.ts new file mode 100644 index 000000000000..9e4859f3b39a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/models/index.ts @@ -0,0 +1,8 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './Category'; +export * from './ModelApiResponse'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/package.json b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/package.json new file mode 100644 index 000000000000..750b1c7a15ad --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/package.json @@ -0,0 +1,23 @@ +{ + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "description": "OpenAPI client for @openapitools/typescript-fetch-petstore", + "author": "OpenAPI-Generator", + "repository": { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + }, + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "scripts": { + "build": "tsc", + "prepare": "npm run build" + }, + "devDependencies": { + "aws4fetch": "^1.0.13" + "typescript": "^4.0" + }, + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/runtime.ts new file mode 100644 index 000000000000..a05ffec8191f --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/runtime.ts @@ -0,0 +1,400 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { AwsV4Signer as AwsV4SignerLib } from "aws4fetch"; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request + awsV4SignParameters?: AwsV4SignerParameters; // parameter for aws v4 signature security +} + +export interface AwsV4SignerParameters { + accessKeyId: string; + secretAccessKey: string; + region: string; + service?: string; +} + +export class AwsV4Signer { + constructor(private configuration: AwsV4SignerParameters) {} + async sign(method: string, url: string, headers: HTTPHeaders, body: any): Promise<{url: URL, headers: HTTPHeaders}> { + const signer = new AwsV4SignerLib({ + method: method, + url: url, + headers: headers, + body: body, + accessKeyId: this.configuration.accessKeyId, + secretAccessKey: this.configuration.secretAccessKey, + service: this.configuration.service, + region: this.configuration.region, + }); + const signResult = await signer.sign(); + // Convert Headers to HTTPHeaders + let newHeaders: HTTPHeaders = {}; + for (const [key, value] of signResult.headers.entries()) { + newHeaders[key] = value; + } + return {url: signResult.url, headers: newHeaders}; + } +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } + get awsV4SignerParameters(): AwsV4SignerParameters | undefined { + return this.configuration.awsV4SignParameters; + } +} + +export const DefaultConfig = new Configuration(); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response.status >= 200 && response.status < 300) { + return response; + } + throw new ResponseError(response, 'Response returned an error code'); + } + + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + this.configuration.queryParamsStringify(context.query); + } + + const headers = Object.assign({}, this.configuration.headers, context.headers); + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; + + const overridedInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + } + + const init: RequestInit = { + ...overridedInit, + body: + isFormData(overridedInit.body) || + overridedInit.body instanceof URLSearchParams || + isBlob(overridedInit.body) + ? overridedInit.body + : JSON.stringify(overridedInit.body), + }; + + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +function isBlob(value: any): value is Blob { + return typeof Blob !== 'undefined' && value instanceof Blob +} + +function isFormData(value: any): value is FormData { + return typeof FormData !== "undefined" && value instanceof FormData +} + +export class ResponseError extends Error { + name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } +} + +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | HTTPQuery }; +export type HTTPBody = Json | FormData | URLSearchParams; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody } +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export type InitOverideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +export function exists(json: any, key: string) { + const value = json[key]; + return value !== null && value !== undefined; +} + +export function querystring(params: HTTPQuery, prefix: string = ''): string { + return Object.keys(params) + .map((key) => { + const fullKey = prefix + (prefix.length ? `[${key}]` : key); + const value = params[key]; + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; + }) + .filter(part => part.length > 0) + .join('&'); +} + +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + +export function canConsumeForm(consumes: Consume[]): boolean { + for (const consume of consumes) { + if ('multipart/form-data' === consume.contentType) { + return true; + } + } + return false; +} + +export interface Consume { + contentType: string +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; +} + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/PetApi.ts new file mode 100644 index 000000000000..5efc64cf8138 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/PetApi.ts @@ -0,0 +1,535 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + ModelApiResponse, + Pet, +} from '../models/index'; +import { + ModelApiResponseFromJSON, + ModelApiResponseToJSON, + PetFromJSON, + PetToJSON, +} from '../models/index'; + +export interface AddPetRequest { + body: Pet; +} + +export interface DeletePetRequest { + petId: number; + apiKey?: string; +} + +export interface FindPetsByStatusRequest { + status: Array; +} + +export interface FindPetsByTagsRequest { + tags: Array; +} + +export interface GetPetByIdRequest { + petId: number; +} + +export interface UpdatePetRequest { + body: Pet; +} + +export interface UpdatePetWithFormRequest { + petId: number; + name?: string; + status?: string; +} + +export interface UploadFileRequest { + petId: number; + additionalMetadata?: string; + file?: Blob; +} + +/** + * + */ +export class PetApi extends runtime.BaseAPI { + + /** + * Add a new pet to the store + */ + async addPetRaw(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling addPet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { + path: `/pet`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Add a new pet to the store + */ + async addPet(requestParameters: AddPetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.addPetRaw(requestParameters, initOverrides); + } + + /** + * Deletes a pet + */ + async deletePetRaw(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling deletePet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (requestParameters.apiKey !== undefined && requestParameters.apiKey !== null) { + headerParameters['api_key'] = String(requestParameters.apiKey); + } + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Deletes a pet + */ + async deletePet(requestParameters: DeletePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deletePetRaw(requestParameters, initOverrides); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatusRaw(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters.status === null || requestParameters.status === undefined) { + throw new runtime.RequiredError('status','Required parameter requestParameters.status was null or undefined when calling findPetsByStatus.'); + } + + const queryParameters: any = {}; + + if (requestParameters.status) { + queryParameters['status'] = requestParameters.status.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/findByStatus`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple status values can be provided with comma separated strings + * Finds Pets by status + */ + async findPetsByStatus(requestParameters: FindPetsByStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.findPetsByStatusRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTagsRaw(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + if (requestParameters.tags === null || requestParameters.tags === undefined) { + throw new runtime.RequiredError('tags','Required parameter requestParameters.tags was null or undefined when calling findPetsByTags.'); + } + + const queryParameters: any = {}; + + if (requestParameters.tags) { + queryParameters['tags'] = requestParameters.tags.join(runtime.COLLECTION_FORMATS["csv"]); + } + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/findByTags`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * Finds Pets by tags + */ + async findPetsByTags(requestParameters: FindPetsByTagsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.findPetsByTagsRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetByIdRaw(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling getPetById.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + + + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); + } + + /** + * Returns a single pet + * Find pet by ID + */ + async getPetById(requestParameters: GetPetByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getPetByIdRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Update an existing pet + */ + async updatePetRaw(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updatePet.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { + path: `/pet`, + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('PUT', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Update an existing pet + */ + async updatePet(requestParameters: UpdatePetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updatePetRaw(requestParameters, initOverrides); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithFormRaw(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling updatePetWithForm.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + const consumes: runtime.Consume[] = [ + { contentType: 'application/x-www-form-urlencoded' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters.name !== undefined) { + formParams.append('name', requestParameters.name as any); + } + + if (requestParameters.status !== undefined) { + formParams.append('status', requestParameters.status as any); + } + + + + const body: any = formParams; + + const request: runtime.RequestOpts = { + path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Updates a pet in the store with form data + */ + async updatePetWithForm(requestParameters: UpdatePetWithFormRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updatePetWithFormRaw(requestParameters, initOverrides); + } + + /** + * uploads an image + */ + async uploadFileRaw(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.petId === null || requestParameters.petId === undefined) { + throw new runtime.RequiredError('petId','Required parameter requestParameters.petId was null or undefined when calling uploadFile.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.accessToken) { + // oauth required + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); + } + + const consumes: runtime.Consume[] = [ + { contentType: 'multipart/form-data' }, + ]; + // @ts-ignore: canConsumeForm may be unused + const canConsumeForm = runtime.canConsumeForm(consumes); + + let formParams: { append(param: string, value: any): any }; + let useForm = false; + // use FormData to transmit files using content-type "multipart/form-data" + useForm = canConsumeForm; + if (useForm) { + formParams = new FormData(); + } else { + formParams = new URLSearchParams(); + } + + if (requestParameters.additionalMetadata !== undefined) { + formParams.append('additionalMetadata', requestParameters.additionalMetadata as any); + } + + if (requestParameters.file !== undefined) { + formParams.append('file', requestParameters.file as any); + } + + + + const body: any = formParams; + + const request: runtime.RequestOpts = { + path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); + } + + /** + * uploads an image + */ + async uploadFile(requestParameters: UploadFileRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.uploadFileRaw(requestParameters, initOverrides); + return await response.value(); + } + +} + +/** + * @export + */ +export const FindPetsByStatusStatusEnum = { + Available: 'available', + Pending: 'pending', + Sold: 'sold' +} as const; +export type FindPetsByStatusStatusEnum = typeof FindPetsByStatusStatusEnum[keyof typeof FindPetsByStatusStatusEnum]; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/StoreApi.ts new file mode 100644 index 000000000000..dd787d9d8310 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/StoreApi.ts @@ -0,0 +1,223 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + Order, +} from '../models/index'; +import { + OrderFromJSON, + OrderToJSON, +} from '../models/index'; + +export interface DeleteOrderRequest { + orderId: string; +} + +export interface GetOrderByIdRequest { + orderId: number; +} + +export interface PlaceOrderRequest { + body: Order; +} + +/** + * + */ +export class StoreApi extends runtime.BaseAPI { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrderRaw(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling deleteOrder.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * Delete purchase order by ID + */ + async deleteOrder(requestParameters: DeleteOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteOrderRaw(requestParameters, initOverrides); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventoryRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + if (this.configuration && this.configuration.apiKey) { + headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication + } + + + + + const request: runtime.RequestOpts = { + path: `/store/inventory`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * Returns a map of status codes to quantities + * Returns pet inventories by status + */ + async getInventory(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{ [key: string]: number; }> { + const response = await this.getInventoryRaw(initOverrides); + return await response.value(); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * Find purchase order by ID + */ + async getOrderByIdRaw(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.orderId === null || requestParameters.orderId === undefined) { + throw new runtime.RequiredError('orderId','Required parameter requestParameters.orderId was null or undefined when calling getOrderById.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + * Find purchase order by ID + */ + async getOrderById(requestParameters: GetOrderByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getOrderByIdRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Place an order for a pet + */ + async placeOrderRaw(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling placeOrder.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { + path: `/store/order`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); + } + + /** + * Place an order for a pet + */ + async placeOrder(requestParameters: PlaceOrderRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.placeOrderRaw(requestParameters, initOverrides); + return await response.value(); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/UserApi.ts new file mode 100644 index 000000000000..ef35ef56612e --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/UserApi.ts @@ -0,0 +1,436 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + User, +} from '../models/index'; +import { + UserFromJSON, + UserToJSON, +} from '../models/index'; + +export interface CreateUserRequest { + body: User; +} + +export interface CreateUsersWithArrayInputRequest { + body: Array; +} + +export interface CreateUsersWithListInputRequest { + body: Array; +} + +export interface DeleteUserRequest { + username: string; +} + +export interface GetUserByNameRequest { + username: string; +} + +export interface LoginUserRequest { + username: string; + password: string; +} + +export interface UpdateUserRequest { + username: string; + body: User; +} + +/** + * + */ +export class UserApi extends runtime.BaseAPI { + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUserRaw(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { + path: `/user`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Create user + */ + async createUser(requestParameters: CreateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createUserRaw(requestParameters, initOverrides); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInputRaw(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithArrayInput.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { + path: `/user/createWithArray`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithArrayInput(requestParameters: CreateUsersWithArrayInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createUsersWithArrayInputRaw(requestParameters, initOverrides); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInputRaw(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling createUsersWithListInput.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { + path: `/user/createWithList`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('POST', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Creates list of users with given input array + */ + async createUsersWithListInput(requestParameters: CreateUsersWithListInputRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.createUsersWithListInputRaw(requestParameters, initOverrides); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUserRaw(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling deleteUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'DELETE', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('DELETE', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Delete user + */ + async deleteUser(requestParameters: DeleteUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.deleteUserRaw(requestParameters, initOverrides); + } + + /** + * Get user by user name + */ + async getUserByNameRaw(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling getUserByName.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + * Get user by user name + */ + async getUserByName(requestParameters: GetUserByNameRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.getUserByNameRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Logs user into the system + */ + async loginUserRaw(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling loginUser.'); + } + + if (requestParameters.password === null || requestParameters.password === undefined) { + throw new runtime.RequiredError('password','Required parameter requestParameters.password was null or undefined when calling loginUser.'); + } + + const queryParameters: any = {}; + + if (requestParameters.username !== undefined) { + queryParameters['username'] = requestParameters.username; + } + + if (requestParameters.password !== undefined) { + queryParameters['password'] = requestParameters.password; + } + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/login`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + if (this.isJsonMime(response.headers.get('content-type'))) { + return new runtime.JSONApiResponse(response); + } else { + return new runtime.TextApiResponse(response) as any; + } + } + + /** + * Logs user into the system + */ + async loginUser(requestParameters: LoginUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.loginUserRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Logs out current logged in user session + */ + async logoutUserRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + + + + const request: runtime.RequestOpts = { + path: `/user/logout`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = null; + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('GET', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * Logs out current logged in user session + */ + async logoutUser(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.logoutUserRaw(initOverrides); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUserRaw(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.username === null || requestParameters.username === undefined) { + throw new runtime.RequiredError('username','Required parameter requestParameters.username was null or undefined when calling updateUser.'); + } + + if (requestParameters.body === null || requestParameters.body === undefined) { + throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling updateUser.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { + path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: body, + } + if (this.configuration && this.configuration.awsV4SignerParameters) { + const SignUrl = this.configuration.basePath + request.path; + const SignBody = JSON.stringify(request.body); + const signer = new runtime.AwsV4Signer(this.configuration.awsV4SignerParameters); + const signResult = await signer.sign('PUT', SignUrl, headerParameters, SignBody); + //request.url = signResult.url; + //request.method = signResult.method; + request.headers = signResult.headers; + } + const response = await this.request(request, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + * This can only be done by the logged in user. + * Updated user + */ + async updateUser(requestParameters: UpdateUserRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.updateUserRaw(requestParameters, initOverrides); + } + +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/index.ts new file mode 100644 index 000000000000..3b870e5c4aa8 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/apis/index.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './PetApi'; +export * from './StoreApi'; +export * from './UserApi'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/index.ts new file mode 100644 index 000000000000..bebe8bbbe206 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/index.ts @@ -0,0 +1,5 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './runtime'; +export * from './apis/index'; +export * from './models/index'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Category.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Category.ts new file mode 100644 index 000000000000..882567387201 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Category.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + +/** + * Check if a given object implements the Category interface. + */ +export function instanceOfCategory(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function CategoryFromJSON(json: any): Category { + return CategoryFromJSONTyped(json, false); +} + +export function CategoryFromJSONTyped(json: any, ignoreDiscriminator: boolean): Category { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], + }; +} + +export function CategoryToJSON(value?: Category | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/ModelApiResponse.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/ModelApiResponse.ts new file mode 100644 index 000000000000..bf50981fc2e2 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/ModelApiResponse.ts @@ -0,0 +1,81 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * Describes the result of uploading an image resource + * @export + * @interface ModelApiResponse + */ +export interface ModelApiResponse { + /** + * + * @type {number} + * @memberof ModelApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ModelApiResponse + */ + message?: string; +} + +/** + * Check if a given object implements the ModelApiResponse interface. + */ +export function instanceOfModelApiResponse(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ModelApiResponseFromJSON(json: any): ModelApiResponse { + return ModelApiResponseFromJSONTyped(json, false); +} + +export function ModelApiResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ModelApiResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'code': !exists(json, 'code') ? undefined : json['code'], + 'type': !exists(json, 'type') ? undefined : json['type'], + 'message': !exists(json, 'message') ? undefined : json['message'], + }; +} + +export function ModelApiResponseToJSON(value?: ModelApiResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'code': value.code, + 'type': value.type, + 'message': value.message, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Order.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Order.ts new file mode 100644 index 000000000000..0d69755d4887 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Order.ts @@ -0,0 +1,117 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {Date} + * @memberof Order + */ + shipDate?: Date; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: OrderStatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + + +/** + * @export + */ +export const OrderStatusEnum = { + Placed: 'placed', + Approved: 'approved', + Delivered: 'delivered' +} as const; +export type OrderStatusEnum = typeof OrderStatusEnum[keyof typeof OrderStatusEnum]; + + +/** + * Check if a given object implements the Order interface. + */ +export function instanceOfOrder(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function OrderFromJSON(json: any): Order { + return OrderFromJSONTyped(json, false); +} + +export function OrderFromJSONTyped(json: any, ignoreDiscriminator: boolean): Order { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'petId': !exists(json, 'petId') ? undefined : json['petId'], + 'quantity': !exists(json, 'quantity') ? undefined : json['quantity'], + 'shipDate': !exists(json, 'shipDate') ? undefined : (new Date(json['shipDate'])), + 'status': !exists(json, 'status') ? undefined : json['status'], + 'complete': !exists(json, 'complete') ? undefined : json['complete'], + }; +} + +export function OrderToJSON(value?: Order | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'petId': value.petId, + 'quantity': value.quantity, + 'shipDate': value.shipDate === undefined ? undefined : (value.shipDate.toISOString()), + 'status': value.status, + 'complete': value.complete, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Pet.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Pet.ts new file mode 100644 index 000000000000..73c70f03a3e5 --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Pet.ts @@ -0,0 +1,132 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { Category } from './Category'; +import { + CategoryFromJSON, + CategoryFromJSONTyped, + CategoryToJSON, +} from './Category'; +import type { Tag } from './Tag'; +import { + TagFromJSON, + TagFromJSONTyped, + TagToJSON, +} from './Tag'; + +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: PetStatusEnum; +} + + +/** + * @export + */ +export const PetStatusEnum = { + Available: 'available', + Pending: 'pending', + Sold: 'sold' +} as const; +export type PetStatusEnum = typeof PetStatusEnum[keyof typeof PetStatusEnum]; + + +/** + * Check if a given object implements the Pet interface. + */ +export function instanceOfPet(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "name" in value; + isInstance = isInstance && "photoUrls" in value; + + return isInstance; +} + +export function PetFromJSON(json: any): Pet { + return PetFromJSONTyped(json, false); +} + +export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'category': !exists(json, 'category') ? undefined : CategoryFromJSON(json['category']), + 'name': json['name'], + 'photoUrls': json['photoUrls'], + 'tags': !exists(json, 'tags') ? undefined : ((json['tags'] as Array).map(TagFromJSON)), + 'status': !exists(json, 'status') ? undefined : json['status'], + }; +} + +export function PetToJSON(value?: Pet | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'category': CategoryToJSON(value.category), + 'name': value.name, + 'photoUrls': value.photoUrls, + 'tags': value.tags === undefined ? undefined : ((value.tags as Array).map(TagToJSON)), + 'status': value.status, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Tag.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Tag.ts new file mode 100644 index 000000000000..e4902aa53cfd --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/Tag.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + +/** + * Check if a given object implements the Tag interface. + */ +export function instanceOfTag(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function TagFromJSON(json: any): Tag { + return TagFromJSONTyped(json, false); +} + +export function TagFromJSONTyped(json: any, ignoreDiscriminator: boolean): Tag { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'name': !exists(json, 'name') ? undefined : json['name'], + }; +} + +export function TagToJSON(value?: Tag | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'name': value.name, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/User.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/User.ts new file mode 100644 index 000000000000..f22da928907c --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/User.ts @@ -0,0 +1,121 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} + +/** + * Check if a given object implements the User interface. + */ +export function instanceOfUser(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function UserFromJSON(json: any): User { + return UserFromJSONTyped(json, false); +} + +export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'id': !exists(json, 'id') ? undefined : json['id'], + 'username': !exists(json, 'username') ? undefined : json['username'], + 'firstName': !exists(json, 'firstName') ? undefined : json['firstName'], + 'lastName': !exists(json, 'lastName') ? undefined : json['lastName'], + 'email': !exists(json, 'email') ? undefined : json['email'], + 'password': !exists(json, 'password') ? undefined : json['password'], + 'phone': !exists(json, 'phone') ? undefined : json['phone'], + 'userStatus': !exists(json, 'userStatus') ? undefined : json['userStatus'], + }; +} + +export function UserToJSON(value?: User | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'id': value.id, + 'username': value.username, + 'firstName': value.firstName, + 'lastName': value.lastName, + 'email': value.email, + 'password': value.password, + 'phone': value.phone, + 'userStatus': value.userStatus, + }; +} + diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/index.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/index.ts new file mode 100644 index 000000000000..9e4859f3b39a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/models/index.ts @@ -0,0 +1,8 @@ +/* tslint:disable */ +/* eslint-disable */ +export * from './Category'; +export * from './ModelApiResponse'; +export * from './Order'; +export * from './Pet'; +export * from './Tag'; +export * from './User'; diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/runtime.ts new file mode 100644 index 000000000000..e72997cd24bc --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/src/runtime.ts @@ -0,0 +1,467 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { AwsV4Signer as AwsV4SignerLib } from "aws4fetch"; + +export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request + awsV4SignParameters?: AwsV4SignerParameters; // parameter for aws v4 signature security +} + +export interface AwsV4SignerParameters { + accessKeyId: string; + secretAccessKey: string; + region: string; + service?: string; +} + +export class AwsV4Signer { + constructor(private configuration: AwsV4SignerParameters) {} + async sign(method: string, url: string, headers: HTTPHeaders, body: any): Promise<{url: URL, headers: HTTPHeaders}> { + const signer = new AwsV4SignerLib({ + method: method, + url: url, + headers: headers, + body: body, + accessKeyId: this.configuration.accessKeyId, + secretAccessKey: this.configuration.secretAccessKey, + service: this.configuration.service, + region: this.configuration.region, + }); + const signResult = await signer.sign(); + // Convert Headers to HTTPHeaders + let newHeaders: HTTPHeaders = {}; + for (const [key, value] of signResult.headers.entries()) { + newHeaders[key] = value; + } + return {url: signResult.url, headers: newHeaders}; + } +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } + get awsV4SignerParameters(): AwsV4SignerParameters | undefined { + return this.configuration.awsV4SignParameters; + } +} + +export const DefaultConfig = new Configuration(); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private static readonly jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i'); + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param mime - MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + protected isJsonMime(mime: string | null | undefined): boolean { + if (!mime) { + return false; + } + return BaseAPI.jsonRegex.test(mime); + } + + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response && (response.status >= 200 && response.status < 300)) { + return response; + } + throw new ResponseError(response, 'Response returned an error code'); + } + + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a "?" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + this.configuration.queryParamsStringify(context.query); + } + + const headers = Object.assign({}, this.configuration.headers, context.headers); + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === "function" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; + + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + }; + + let body: any; + if (isFormData(overriddenInit.body) + || (overriddenInit.body instanceof URLSearchParams) + || isBlob(overriddenInit.body)) { + body = overriddenInit.body; + } else if (this.isJsonMime(headers['Content-Type'])) { + body = JSON.stringify(overriddenInit.body); + } else { + body = overriddenInit.body; + } + + const init: RequestInit = { + ...overriddenInit, + body + }; + + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of `this` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +function isBlob(value: any): value is Blob { + return typeof Blob !== 'undefined' && value instanceof Blob; +} + +function isFormData(value: any): value is FormData { + return typeof FormData !== "undefined" && value instanceof FormData; +} + +export class ResponseError extends Error { + override name: "ResponseError" = "ResponseError"; + constructor(public response: Response, msg?: string) { + super(msg); + } +} + +export class FetchError extends Error { + override name: "FetchError" = "FetchError"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + +export class RequiredError extends Error { + override name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; +export type HTTPBody = Json | FormData | URLSearchParams; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +export function exists(json: any, key: string) { + const value = json[key]; + return value !== null && value !== undefined; +} + +export function querystring(params: HTTPQuery, prefix: string = ''): string { + return Object.keys(params) + .map(key => querystringSingleKey(key, params[key], prefix)) + .filter(part => part.length > 0) + .join('&'); +} + +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { + const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key); + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(`&${encodeURIComponent(fullKey)}=`); + return `${encodeURIComponent(fullKey)}=${multiValue}`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`; +} + +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + +export function canConsumeForm(consumes: Consume[]): boolean { + for (const consume of consumes) { + if ('multipart/form-data' === consume.contentType) { + return true; + } + } + return false; +} + +export interface Consume { + contentType: string; +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; +} + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.text(); + }; +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/tsconfig.json new file mode 100644 index 000000000000..4567ec19899a --- /dev/null +++ b/samples/client/petstore/typescript-fetch/builds/with-awsv4-signature/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "outDir": "dist", + "lib": [ + "es6", + "dom" + ], + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts index eb7a25c6d01c..d44350e130ed 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/PetApi.ts @@ -224,13 +224,18 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -263,12 +268,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -302,12 +311,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -343,12 +356,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -379,12 +396,16 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -417,13 +438,18 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -474,13 +500,18 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -533,13 +564,18 @@ export class PetApi extends runtime.BaseAPI implements PetApiInterface { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts index c76e200d9349..24c7a6ac26aa 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/StoreApi.ts @@ -123,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -154,12 +158,16 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -186,12 +194,16 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -219,13 +231,18 @@ export class StoreApi extends runtime.BaseAPI implements StoreApiInterface { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts index a55ab1d48f5c..455dcb7d151f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/apis/UserApi.ts @@ -205,13 +205,18 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -238,13 +243,18 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -270,13 +280,18 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -301,12 +316,16 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -331,12 +350,16 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -373,12 +396,16 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -403,12 +430,16 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -439,13 +470,18 @@ export class UserApi extends runtime.BaseAPI implements UserApiInterface { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-interfaces/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts index 3a82dd1e7fb1..d74462998f3f 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/PetApi.ts @@ -86,13 +86,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -125,12 +130,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +173,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -205,12 +218,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(PetFromJSON)); } @@ -241,12 +258,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PetFromJSON(jsonValue)); } @@ -279,13 +300,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = PetToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: PetToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -336,13 +362,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -395,13 +426,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ModelApiResponseFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts index dd007df3588c..af56308e6871 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/StoreApi.ts @@ -52,12 +52,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -83,12 +87,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -115,12 +123,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } @@ -148,13 +160,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = OrderToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: OrderToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => OrderFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts index 58f6a7e5d3af..fee1edb46dd2 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/apis/UserApi.ts @@ -72,13 +72,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -105,13 +110,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -137,13 +147,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body.map(UserToJSON); + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body.map(UserToJSON), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -168,12 +183,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -198,12 +217,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); } @@ -240,12 +263,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -270,12 +297,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -306,13 +337,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = UserToJSON(requestParameters.body); + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: UserToJSON(requestParameters.body), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts index 2a90ca5b632c..e3e2687b5e74 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-npm-version/src/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts index 09bc772a5856..01972ce706ff 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/apis/DefaultApi.ts @@ -81,12 +81,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/enum-request-inline`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); } @@ -121,12 +125,16 @@ export class DefaultApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/fake/enum-request-ref`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); } @@ -147,13 +155,18 @@ export class DefaultApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response); + + const request: runtime.RequestOpts = { path: `/fake/enum-request-inline`, method: 'POST', headers: headerParameters, query: queryParameters, - body: FakeEnumRequestGetInline200ResponseToJSON(requestParameters.fakeEnumRequestGetInline200Response), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => FakeEnumRequestGetInline200ResponseFromJSON(jsonValue)); } @@ -174,13 +187,18 @@ export class DefaultApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = EnumPatternObjectToJSON(requestParameters.enumPatternObject); + + const request: runtime.RequestOpts = { path: `/fake/enum-request-ref`, method: 'POST', headers: headerParameters, query: queryParameters, - body: EnumPatternObjectToJSON(requestParameters.enumPatternObject), - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EnumPatternObjectFromJSON(jsonValue)); } diff --git a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts index d4d2025e1e3c..53efb6d16fb1 100644 --- a/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/with-string-enums/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://localhost:3000".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts index effff57e9a99..0e320c9ac774 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/PetApi.ts @@ -80,13 +80,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/pet`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -119,12 +124,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -158,12 +167,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByStatus`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -199,12 +212,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/findByTags`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -235,12 +252,16 @@ export class PetApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -273,13 +294,18 @@ export class PetApi extends runtime.BaseAPI { headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/pet`, method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -330,13 +356,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('status', requestParameters.status as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -389,13 +420,18 @@ export class PetApi extends runtime.BaseAPI { formParams.append('file', requestParameters.file as any); } - const response = await this.request({ + + + const body: any = formParams; + + const request: runtime.RequestOpts = { path: `/pet/{petId}/uploadImage`.replace(`{${"petId"}}`, encodeURIComponent(String(requestParameters.petId))), method: 'POST', headers: headerParameters, query: queryParameters, - body: formParams, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts index e43d223f7e1d..cbd4eb5218ca 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/StoreApi.ts @@ -48,12 +48,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -79,12 +83,16 @@ export class StoreApi extends runtime.BaseAPI { headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication } - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/inventory`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -111,12 +119,16 @@ export class StoreApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/store/order/{orderId}`.replace(`{${"orderId"}}`, encodeURIComponent(String(requestParameters.orderId))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -144,13 +156,18 @@ export class StoreApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/store/order`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts index 08676b352e5d..9b540b736ec8 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/apis/UserApi.ts @@ -68,13 +68,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/user`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -101,13 +106,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/user/createWithArray`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -133,13 +143,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/user/createWithList`, method: 'POST', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -164,12 +179,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'DELETE', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -194,12 +213,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.JSONApiResponse(response); } @@ -236,12 +259,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/login`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); if (this.isJsonMime(response.headers.get('content-type'))) { return new runtime.JSONApiResponse(response); @@ -266,12 +293,16 @@ export class UserApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; - const response = await this.request({ + + + + const request: runtime.RequestOpts = { path: `/user/logout`, method: 'GET', headers: headerParameters, query: queryParameters, - }, initOverrides); + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } @@ -302,13 +333,18 @@ export class UserApi extends runtime.BaseAPI { headerParameters['Content-Type'] = 'application/json'; - const response = await this.request({ + + + const body: any = requestParameters.body; + + const request: runtime.RequestOpts = { path: `/user/{username}`.replace(`{${"username"}}`, encodeURIComponent(String(requestParameters.username))), method: 'PUT', headers: headerParameters, query: queryParameters, - body: requestParameters.body, - }, initOverrides); + body: body, + } + const response = await this.request(request, initOverrides); return new runtime.VoidApiResponse(response); } diff --git a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts index 8b52e158ff08..7a0485d6d827 100644 --- a/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/without-runtime-checks/src/runtime.ts @@ -13,6 +13,7 @@ */ + export const BASE_PATH = "http://petstore.swagger.io/v2".replace(/\/+$/, ""); export interface ConfigurationParameters { @@ -28,6 +29,7 @@ export interface ConfigurationParameters { credentials?: RequestCredentials; //value for the credentials param we want to use on each request } + export class Configuration { constructor(private configuration: ConfigurationParameters = {}) {} diff --git a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json index b2049c8b249c..1635d3e87576 100644 --- a/samples/client/petstore/typescript-fetch/tests/default/package-lock.json +++ b/samples/client/petstore/typescript-fetch/tests/default/package-lock.json @@ -32,20 +32,14 @@ "webpack": "^1.13.0" } }, - "../../builds/with-npm-version": { - "name": "@openapitools/typescript-fetch-petstore", - "version": "1.0.0", - "devDependencies": { - "typescript": "^4.0" - } - }, "node_modules/@openapitools/typescript-fetch-petstore": { - "resolved": "../../builds/with-npm-version", - "link": true + "version": "1.0.0", + "resolved": "file:../../builds/with-npm-version" }, "node_modules/@swagger/typescript-fetch-petstore": { - "resolved": "../../builds/with-npm-version", - "link": true + "name": "@openapitools/typescript-fetch-petstore", + "version": "1.0.0", + "resolved": "file:../../builds/with-npm-version" }, "node_modules/@types/chai": { "version": "4.1.6", @@ -6621,16 +6615,10 @@ }, "dependencies": { "@openapitools/typescript-fetch-petstore": { - "version": "file:../../builds/with-npm-version", - "requires": { - "typescript": "^4.0" - } + "version": "1.0.0" }, "@swagger/typescript-fetch-petstore": { - "version": "file:../../builds/with-npm-version", - "requires": { - "typescript": "^4.0" - } + "version": "npm:@openapitools/typescript-fetch-petstore@1.0.0" }, "@types/chai": { "version": "4.1.6",