From cc2a444c24e27e010f48edc01f533222634f6f7f Mon Sep 17 00:00:00 2001 From: Kaitlin Davis Date: Fri, 30 May 2025 12:11:27 -0600 Subject: [PATCH 1/3] Detect AWS IAM Auth by looking for common patterns --- .../openapitools/codegen/CodegenSecurity.java | 7 +- .../TypeScriptAxiosClientCodegen.java | 114 ++++++++++++++++-- .../TypeScriptAxiosClientCodegenTest.java | 82 ++++++++++++- 3 files changed, 189 insertions(+), 14 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java index 00b4c2e1e0b4..3ea9363c0725 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenSecurity.java @@ -30,7 +30,7 @@ public class CodegenSecurity { // Those are to differentiate basic and bearer authentication // isHttpSignature is to support HTTP signature authorization scheme. // https://datatracker.ietf.org/doc/draft-cavage-http-signatures/ - public Boolean isBasicBasic, isBasicBearer, isHttpSignature; + public Boolean isBasicBasic, isBasicBearer, isHttpSignature, isAWSV4Signature; public String bearerFormat; public Map vendorExtensions = new HashMap(); // ApiKey specific @@ -56,6 +56,7 @@ public CodegenSecurity(CodegenSecurity original) { this.isBasic = original.isBasic; this.isBasicBasic = original.isBasicBasic; this.isHttpSignature = original.isHttpSignature; + this.isAWSV4Signature = original.isAWSV4Signature; this.bearerFormat = original.bearerFormat; this.isBasicBearer = original.isBasicBearer; this.isApiKey = original.isApiKey; @@ -134,6 +135,7 @@ public boolean equals(Object o) { Objects.equals(isApiKey, that.isApiKey) && Objects.equals(isBasicBasic, that.isBasicBasic) && Objects.equals(isHttpSignature, that.isHttpSignature) && + Objects.equals(isAWSV4Signature, that.isAWSV4Signature) && Objects.equals(isBasicBearer, that.isBasicBearer) && Objects.equals(bearerFormat, that.bearerFormat) && Objects.equals(vendorExtensions, that.vendorExtensions) && @@ -157,7 +159,7 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(name, description, type, scheme, isBasic, isOAuth, isOpenId, isApiKey, - isBasicBasic, isHttpSignature, isBasicBearer, bearerFormat, vendorExtensions, + isBasicBasic, isHttpSignature, isAWSV4Signature, isBasicBearer, bearerFormat, vendorExtensions, keyParamName, isKeyInQuery, isKeyInHeader, isKeyInCookie, flow, authorizationUrl, tokenUrl, refreshUrl, scopes, isCode, isPassword, isApplication, isImplicit, openIdConnectUrl); @@ -176,6 +178,7 @@ public String toString() { sb.append(", isApiKey=").append(isApiKey); sb.append(", isBasicBasic=").append(isBasicBasic); sb.append(", isHttpSignature=").append(isHttpSignature); + sb.append(", isAWSV4Signature=").append(isAWSV4Signature); sb.append(", isBasicBearer=").append(isBasicBearer); sb.append(", bearerFormat='").append(bearerFormat).append('\''); sb.append(", vendorExtensions=").append(vendorExtensions); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java index 53580ea51627..51e26a37c3a0 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java @@ -17,10 +17,12 @@ package org.openapitools.codegen.languages; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.parser.util.SchemaTypeUtil; -import lombok.Getter; -import lombok.Setter; +import java.io.File; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TreeSet; + import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.meta.features.DocumentationFeature; @@ -30,12 +32,15 @@ import org.openapitools.codegen.model.OperationMap; import org.openapitools.codegen.model.OperationsMap; import org.openapitools.codegen.utils.ModelUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TreeSet; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.parser.util.SchemaTypeUtil; +import lombok.Getter; +import lombok.Setter; public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodegen { @@ -53,6 +58,8 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege public static final String AXIOS_VERSION = "axiosVersion"; public static final String DEFAULT_AXIOS_VERSION = "^1.6.1"; + private final Logger LOGGER = LoggerFactory.getLogger(TypeScriptAxiosClientCodegen.class); + @Getter @Setter protected String npmRepository = null; protected Boolean stringEnums = false; @@ -121,6 +128,76 @@ private static String getRelativeToRoot(String path) { return sb.toString(); } + @Override + public void preprocessOpenAPI(OpenAPI openAPI) { + super.preprocessOpenAPI(openAPI); + + boolean hasAwsV4Signature = detectAwsV4Signature(openAPI); + additionalProperties.put("withAWSV4Signature", hasAwsV4Signature); + } + + /** + * Detects if the OpenAPI specification uses AWS V4 signature authentication + * by checking for common patterns used in AWS API Gateway specifications. + */ + private boolean detectAwsV4Signature(OpenAPI openAPI) { + // Check security schemes for AWS V4 signature patterns + if (openAPI.getComponents() != null && openAPI.getComponents().getSecuritySchemes() != null) { + return openAPI.getComponents().getSecuritySchemes().entrySet().stream() + .anyMatch(entry -> isAwsV4SecurityScheme(entry.getKey(), entry.getValue(), openAPI)); + } + + return false; + } + + /** + * Determines if a security scheme represents AWS V4 signature authentication + */ + private boolean isAwsV4SecurityScheme(String schemeName, SecurityScheme scheme, OpenAPI openAPI) { + if (scheme == null) { + return false; + } + + // Pattern 1: Check for AWS-specific extension + if (scheme.getExtensions() != null) { + Object authType = scheme.getExtensions().get("x-amazon-apigateway-authtype"); + if ("awsSigv4".equals(authType)) { + return true; + } + } + + // Pattern 2: Check for common AWS V4 signature scheme names + String lowerSchemeName = schemeName.toLowerCase(Locale.ROOT); + if (lowerSchemeName.contains("sigv4") || + lowerSchemeName.contains("aws") || + lowerSchemeName.contains("iam")) { + + // Additional validation: should be apiKey type with Authorization header + if (SecurityScheme.Type.APIKEY.equals(scheme.getType()) && + "Authorization".equalsIgnoreCase(scheme.getName()) && + SecurityScheme.In.HEADER.equals(scheme.getIn())) { + return true; + } + } + + // Pattern 3: Check for AWS API Gateway URL patterns in servers + if (openAPI.getServers() != null) { + boolean hasAwsApiGatewayUrl = openAPI.getServers().stream() + .anyMatch(server -> server.getUrl() != null && + (server.getUrl().contains("execute-api") && server.getUrl().contains("amazonaws.com"))); + + // If we have AWS API Gateway URL and an Authorization header scheme, likely AWS V4 + if (hasAwsApiGatewayUrl && + SecurityScheme.Type.APIKEY.equals(scheme.getType()) && + "Authorization".equalsIgnoreCase(scheme.getName()) && + SecurityScheme.In.HEADER.equals(scheme.getIn())) { + return true; + } + } + + return false; + } + @Override public void processOpts() { super.processOpts(); @@ -182,7 +259,6 @@ public void processOpts() { setAxiosVersion(additionalProperties.get(AXIOS_VERSION).toString()); } additionalProperties.put("axiosVersion", getAxiosVersion()); - } @Override @@ -363,4 +439,22 @@ protected void addImport(Schema composed, Schema childSchema, CodegenModel model // import everything (including child schema of a composed schema) addImport(model, modelName); } + + @Override + public List fromSecurity(Map securitySchemeMap) { + List securities = super.fromSecurity(securitySchemeMap); + + // Post-process security schemes to detect AWS V4 signature + for (CodegenSecurity security : securities) { + if (securitySchemeMap.containsKey(security.name)) { + SecurityScheme scheme = securitySchemeMap.get(security.name); + if (isAwsV4SecurityScheme(security.name, scheme, this.openAPI)) { + security.isAWSV4Signature = true; + LOGGER.info("Detected AWS V4 signature security scheme: {}", security.name); + } + } + } + + return securities; + } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java index 185366b9b0d3..871d5fe9e4e1 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/axios/TypeScriptAxiosClientCodegenTest.java @@ -1,13 +1,23 @@ package org.openapitools.codegen.typescript.axios; +import static org.assertj.core.api.Assertions.assertThat; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.util.List; +import java.util.Map; + import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenSecurity; import org.openapitools.codegen.SupportingFile; +import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.languages.TypeScriptAxiosClientCodegen; import org.openapitools.codegen.typescript.TypeScriptGroups; import org.testng.annotations.Test; -import static org.assertj.core.api.Assertions.assertThat; -import static org.testng.Assert.assertEquals; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.SecurityScheme; @Test(groups = {TypeScriptGroups.TYPESCRIPT, TypeScriptGroups.TYPESCRIPT_AXIOS}) public class TypeScriptAxiosClientCodegenTest { @@ -130,4 +140,72 @@ public void testAppliesCustomAxiosVersion() { assertEquals(codegen.additionalProperties().get("axiosVersion"), "^1.2.3"); } + + @Test + public void testDetectsAwsIamAuthenticationWithExtension() { + OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/typescript-axios/with-aws-iam.yaml"); + TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen(); + + // Call preprocessOpenAPI which will detect AWS and set the property + codegen.preprocessOpenAPI(openAPI); + + // Should detect AWS V4 signature due to x-amazon-apigateway-authtype extension + assertTrue((Boolean) codegen.additionalProperties().get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)); + } + + @Test + public void testDetectsAwsIamAuthenticationWithNaming() { + OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/typescript-axios/with-aws-iam.yaml"); + TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen(); + + // Call preprocessOpenAPI which will detect AWS and set the property + codegen.preprocessOpenAPI(openAPI); + + // Should detect AWS V4 signature due to scheme name patterns and AWS API Gateway URL + assertTrue((Boolean) codegen.additionalProperties().get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)); + } + + @Test + public void testDoesNotDetectAwsIamInRegularPetstore() { + OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore.yaml"); + TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen(); + + // Call preprocessOpenAPI + codegen.preprocessOpenAPI(openAPI); + + // Should NOT detect AWS V4 signature in regular petstore + assertFalse(codegen.additionalProperties().containsKey(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT) && + (Boolean) codegen.additionalProperties().get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)); + } + + @Test + public void testDoesNotDetectAwsIamInSwagger2Petstore() { + OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/petstore.yaml"); + TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen(); + + // Call preprocessOpenAPI + codegen.preprocessOpenAPI(openAPI); + + // Should NOT detect AWS V4 signature in Swagger 2.0 petstore either + assertFalse(codegen.additionalProperties().containsKey(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT) && + (Boolean) codegen.additionalProperties().get(CodegenConstants.WITH_AWSV4_SIGNATURE_COMMENT)); + } + + @Test + public void testFromSecuritySetsAwsV4Flag() { + OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/typescript-axios/with-aws-iam.yaml"); + TypeScriptAxiosClientCodegen codegen = new TypeScriptAxiosClientCodegen(); + + // Call preprocessOpenAPI first to set up the openAPI object + codegen.preprocessOpenAPI(openAPI); + + // Test fromSecurity method directly + Map securitySchemes = + openAPI.getComponents().getSecuritySchemes(); + List securities = codegen.fromSecurity(securitySchemes); + + // Should have AWS V4 signature flagged on individual security schemes + boolean hasAwsV4 = securities.stream().anyMatch(s -> Boolean.TRUE.equals(s.isAWSV4Signature)); + assertTrue(hasAwsV4, "fromSecurity should set isAWSV4Signature=true for AWS schemes"); + } } From 910a15d32c92325a2ec8d3470099416c6fc233b4 Mon Sep 17 00:00:00 2001 From: Kaitlin Davis Date: Fri, 30 May 2025 13:11:58 -0600 Subject: [PATCH 2/3] Add sample demonstrating passed withAwsSignature variable works --- bin/configs/typescript-axios-aws-iam.yaml | 14 + .../typescript-axios/package.mustache | 4 +- .../3_0/typescript-axios/with-aws-iam.yaml | 85 ++++++ .../typescript-axios/builds/aws-iam/README.md | 169 +++++++++++ .../builds/aws-iam/client/default-api.ts | 284 ++++++++++++++++++ .../builds/aws-iam/models/index.ts | 1 + .../builds/aws-iam/models/pet.ts | 42 +++ .../builds/aws-iam/package.json | 38 +++ .../builds/aws-iam/tsconfig.esm.json | 7 + .../builds/aws-iam/tsconfig.json | 18 ++ .../builds/with-aws-iam/.gitignore | 4 + .../builds/with-aws-iam/.npmignore | 1 + .../with-aws-iam/.openapi-generator-ignore | 23 ++ .../with-aws-iam/.openapi-generator/FILES | 17 ++ .../with-aws-iam/.openapi-generator/VERSION | 1 + .../builds/with-aws-iam/README.md | 75 +++++ .../builds/with-aws-iam/api.ts | 18 ++ .../builds/with-aws-iam/base.ts | 86 ++++++ .../builds/with-aws-iam/client/default-api.ts | 269 +++++++++++++++++ .../builds/with-aws-iam/common.ts | 151 ++++++++++ .../builds/with-aws-iam/configuration.ts | 115 +++++++ .../builds/with-aws-iam/docs/DefaultApi.md | 149 +++++++++ .../builds/with-aws-iam/docs/Pet.md | 24 ++ .../builds/with-aws-iam/git_push.sh | 57 ++++ .../builds/with-aws-iam/index.ts | 18 ++ .../builds/with-aws-iam/models/index.ts | 1 + .../builds/with-aws-iam/models/pet.ts | 42 +++ .../builds/with-aws-iam/package.json | 38 +++ .../builds/with-aws-iam/tsconfig.esm.json | 7 + .../builds/with-aws-iam/tsconfig.json | 18 ++ 30 files changed, 1775 insertions(+), 1 deletion(-) create mode 100644 bin/configs/typescript-axios-aws-iam.yaml create mode 100644 modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/README.md create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/client/default-api.ts create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/models/index.ts create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/models/pet.ts create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/package.json create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.esm.json create mode 100644 samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.json create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/.gitignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/.npmignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator-ignore create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/FILES create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/VERSION create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/README.md create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/api.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/base.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/client/default-api.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/common.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/configuration.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/DefaultApi.md create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/Pet.md create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/git_push.sh create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/index.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/models/index.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/models/pet.ts create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/package.json create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.esm.json create mode 100644 samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.json diff --git a/bin/configs/typescript-axios-aws-iam.yaml b/bin/configs/typescript-axios-aws-iam.yaml new file mode 100644 index 000000000000..480653637155 --- /dev/null +++ b/bin/configs/typescript-axios-aws-iam.yaml @@ -0,0 +1,14 @@ +generatorName: typescript-axios +outputDir: samples/client/petstore/typescript-axios/builds/with-aws-iam +inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml +templateDir: modules/openapi-generator/src/main/resources/typescript-axios +additionalProperties: + npmVersion: 1.0.0 + npmName: '@openapitools/typescript-axios-with-aws-iam' + npmRepository: https://skimdb.npmjs.com/registry + supportsES6: true + withNodeImports: true + withSeparateModelsAndApi: true + apiPackage: client + modelPackage: models + enumPropertyNaming: UPPERCASE diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache index f05b33ed1eed..49f954eb3373 100644 --- a/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/package.mustache @@ -26,7 +26,9 @@ "prepare": "npm run build" }, "dependencies": { - "axios": "{{axiosVersion}}" + "axios": "{{axiosVersion}}"{{#withAWSV4Signature}}, + "aws4": "^1.11.0", + "@aws-sdk/credential-provider-node": "^3.400.0"{{/withAWSV4Signature}} }, "devDependencies": { "@types/node": "12.11.5 - 12.20.42", diff --git a/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml new file mode 100644 index 000000000000..de99cca6b415 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml @@ -0,0 +1,85 @@ +openapi: 3.0.1 +info: + title: OpenAPI Petstore with AWS IAM + version: 1.0.0 + description: Test API for AWS IAM authentication detection +servers: + - url: https://abc123.execute-api.us-east-1.amazonaws.com/prod +security: + - iam: [] +paths: + /pet: + get: + summary: Find pet by ID + operationId: getPetById + security: + - iam: [] + responses: + '200': + description: successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + '404': + description: Pet not found + post: + summary: Create a new pet + operationId: createPet + security: + - iam: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + responses: + '201': + description: Pet created + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + '400': + description: Invalid input + /store/inventory: + get: + summary: Returns pet inventories by status + operationId: getInventory + security: + - iam: [] + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + format: int32 +components: + securitySchemes: + iam: + type: apiKey + name: Authorization + in: header + x-amazon-apigateway-authtype: awsSigv4 + schemas: + Pet: + type: object + required: + - name + - photoUrls + properties: + id: + type: integer + format: int64 + name: + type: string + example: doggie + photoUrls: + type: array + items: + type: string diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/README.md b/samples/client/petstore/typescript-axios/builds/aws-iam/README.md new file mode 100644 index 000000000000..615fda1d9d64 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/README.md @@ -0,0 +1,169 @@ +## @openapitools/typescript-axios-with-aws-iam@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). 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 will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.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-axios-with-aws-iam@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` + +### Documentation for API Endpoints + +All URIs are relative to *https://abc123.execute-api.us-east-1.amazonaws.com/prod* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**createPet**](docs/DefaultApi.md#createpet) | **POST** /pet | Create a new pet +*DefaultApi* | [**getInventory**](docs/DefaultApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*DefaultApi* | [**getPetById**](docs/DefaultApi.md#getpetbyid) | **GET** /pet | Find pet by ID + + +### Documentation For Models + + - [Pet](docs/Pet.md) + + + +## Documentation For Authorization + + +Authentication schemes defined for the API: + +### aws_iam + +- **Type**: API key +- **API key parameter name**: Authorization +- **Location**: HTTP header + + +### sigv4_auth + +- **Type**: API key +- **API key parameter name**: Authorization +- **Location**: HTTP header + + + +### AWS V4 Signature + +This client supports AWS Signature Version 4 for authenticating requests to AWS services. + +#### Configuration + +```typescript +import { Configuration } from '@openapitools/typescript-axios-with-aws-iam'; + +const configuration = new Configuration({ + awsv4: { + credentials: { + accessKeyId: 'your-access-key-id', + secretAccessKey: 'your-secret-access-key', + sessionToken: 'your-session-token' // Optional, for temporary credentials + }, + options: { + region: 'us-east-1', // AWS region + service: 'execute-api' // AWS service name, typically 'execute-api' for API Gateway + } + } +}); +``` + +#### Environment Variables + +You can also use environment variables for AWS credentials: + +```bash +export AWS_ACCESS_KEY_ID=your-access-key-id +export AWS_SECRET_ACCESS_KEY=your-secret-access-key +export AWS_SESSION_TOKEN=your-session-token # Optional +``` + +When environment variables are set, they will be used as fallbacks if not provided in the configuration. + +#### Usage Example + +```typescript +import { DefaultApi, Configuration } from '@openapitools/typescript-axios-with-aws-iam'; + +const configuration = new Configuration({ + basePath: 'https://your-api-gateway-id.execute-api.us-east-1.amazonaws.com/stage', + awsv4: { + credentials: { + accessKeyId: process.env.AWS_ACCESS_KEY_ID, + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, + sessionToken: process.env.AWS_SESSION_TOKEN + }, + options: { + region: 'us-east-1', + service: 'execute-api' + } + } +}); + +const apiInstance = new DefaultApi(configuration); + +// All requests will now be signed with AWS V4 signature +apiInstance.someMethod().then((response) => { + console.log(response.data); +}).catch((error) => { + console.error(error); +}); +``` + +#### IAM Permissions + +Ensure your AWS credentials have the necessary IAM permissions to access the API endpoints. For API Gateway, this typically includes: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "execute-api:Invoke" + ], + "Resource": "arn:aws:execute-api:region:account-id:api-id/*" + } + ] +} +``` + diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/client/default-api.ts b/samples/client/petstore/typescript-axios/builds/aws-iam/client/default-api.ts new file mode 100644 index 000000000000..719f6788ada4 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/client/default-api.ts @@ -0,0 +1,284 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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 type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +// URLSearchParams not necessarily used +// @ts-ignore +import { URL, URLSearchParams } from 'url'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base'; +// @ts-ignore +import { getSignedAwsHeaders } from '../common'; +// @ts-ignore +import type { Pet } from '../models'; +/** + * DefaultApi - axios parameter creator + * @export + */ +export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createPet: async (pet: Pet, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'pet' is not null or undefined + assertParamExists('createPet', 'pet', pet) + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + let awsSignatureHeaders = {}; + + // Set search params BEFORE auth methods (including AWS signing) + setSearchParams(localVarUrlObj, localVarQueryParameter); + + // AWS V4 Signature auth detected - need to set body/form data before signing + // Set body before AWS signing + localVarHeaderParameter['Content-Type'] = 'application/json'; + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + + + // authentication aws_iam required + // aws v4 signature required + awsSignatureHeaders = await getSignedAwsHeaders(localVarRequestOptions, localVarUrlObj, configuration) + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...awsSignatureHeaders, ...options.headers}; + // Only serialize body if not already set (e.g., by AWS signing) + if (localVarRequestOptions.data === undefined) { + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + } + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/store/inventory`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + let awsSignatureHeaders = {}; + + // Set search params BEFORE auth methods (including AWS signing) + setSearchParams(localVarUrlObj, localVarQueryParameter); + + // AWS V4 Signature auth detected - need to set body/form data before signing + + + // authentication sigv4_auth required + // aws v4 signature required + awsSignatureHeaders = await getSignedAwsHeaders(localVarRequestOptions, localVarUrlObj, configuration) + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...awsSignatureHeaders, ...options.headers}; + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + let awsSignatureHeaders = {}; + + // Set search params BEFORE auth methods (including AWS signing) + setSearchParams(localVarUrlObj, localVarQueryParameter); + + // AWS V4 Signature auth detected - need to set body/form data before signing + + + // authentication aws_iam required + // aws v4 signature required + awsSignatureHeaders = await getSignedAwsHeaders(localVarRequestOptions, localVarUrlObj, configuration) + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...awsSignatureHeaders, ...options.headers}; + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DefaultApi - functional programming interface + * @export + */ +export const DefaultApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createPet(pet: Pet, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createPet(pet, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.createPet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getInventory(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: number; }>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getInventory(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.getInventory']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getPetById(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getPetById(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.getPetById']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * DefaultApi - factory interface + * @export + */ +export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = DefaultApiFp(configuration) + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createPet(pet: Pet, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.createPet(pet, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options?: RawAxiosRequestConfig): AxiosPromise<{ [key: string]: number; }> { + return localVarFp.getInventory(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.getPetById(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +export class DefaultApi extends BaseAPI { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public createPet(pet: Pet, options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).createPet(pet, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public getInventory(options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).getInventory(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public getPetById(options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).getPetById(options).then((request) => request(this.axios, this.basePath)); + } +} + diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/models/index.ts b/samples/client/petstore/typescript-axios/builds/aws-iam/models/index.ts new file mode 100644 index 000000000000..eccf4ec59cbb --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/models/index.ts @@ -0,0 +1 @@ +export * from './pet'; diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/models/pet.ts b/samples/client/petstore/typescript-axios/builds/aws-iam/models/pet.ts new file mode 100644 index 000000000000..0a84c4066c5e --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/models/pet.ts @@ -0,0 +1,42 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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. + */ + + + +/** + * + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + 'id'?: number; + /** + * + * @type {string} + * @memberof Pet + */ + 'name': string; + /** + * + * @type {Array} + * @memberof Pet + */ + 'photoUrls': Array; +} + diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/package.json b/samples/client/petstore/typescript-axios/builds/aws-iam/package.json new file mode 100644 index 000000000000..825f6def065d --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/package.json @@ -0,0 +1,38 @@ +{ + "name": "@openapitools/typescript-axios-with-aws-iam", + "version": "1.0.0", + "description": "OpenAPI client for @openapitools/typescript-axios-with-aws-iam", + "author": "OpenAPI-Generator Contributors", + "repository": { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + }, + "keywords": [ + "axios", + "typescript", + "openapi-client", + "openapi-generator", + "@openapitools/typescript-axios-with-aws-iam" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "module": "./dist/esm/index.js", + "sideEffects": false, + "scripts": { + "build": "tsc && tsc -p tsconfig.esm.json", + "prepare": "npm run build" + }, + "dependencies": { + "axios": "^1.6.1", + "aws4": "^1.11.0", + "@aws-sdk/credential-provider-node": "^3.400.0" + }, + "devDependencies": { + "@types/node": "12.11.5 - 12.20.42", + "typescript": "^4.0 || ^5.0" + }, + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.esm.json b/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.esm.json new file mode 100644 index 000000000000..2c0331cce040 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.json b/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.json new file mode 100644 index 000000000000..30dc264ec731 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/aws-iam/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "ES6", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + "moduleResolution": "node", + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/.gitignore b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.gitignore new file mode 100644 index 000000000000..149b57654723 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/.npmignore b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.npmignore new file mode 100644 index 000000000000..999d88df6939 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm \ No newline at end of file diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator-ignore b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.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-axios/builds/with-aws-iam/.openapi-generator/FILES b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/FILES new file mode 100644 index 000000000000..0239af220ea6 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/FILES @@ -0,0 +1,17 @@ +.gitignore +.npmignore +README.md +api.ts +base.ts +client/default-api.ts +common.ts +configuration.ts +docs/DefaultApi.md +docs/Pet.md +git_push.sh +index.ts +models/index.ts +models/pet.ts +package.json +tsconfig.esm.json +tsconfig.json diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/VERSION b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/VERSION new file mode 100644 index 000000000000..4c631cf217a2 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.14.0-SNAPSHOT diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/README.md b/samples/client/petstore/typescript-axios/builds/with-aws-iam/README.md new file mode 100644 index 000000000000..bd7ee29ef08c --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/README.md @@ -0,0 +1,75 @@ +## @openapitools/typescript-axios-with-aws-iam@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). 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 will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.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-axios-with-aws-iam@1.0.0 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` + +### Documentation for API Endpoints + +All URIs are relative to *https://abc123.execute-api.us-east-1.amazonaws.com/prod* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**createPet**](docs/DefaultApi.md#createpet) | **POST** /pet | Create a new pet +*DefaultApi* | [**getInventory**](docs/DefaultApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*DefaultApi* | [**getPetById**](docs/DefaultApi.md#getpetbyid) | **GET** /pet | Find pet by ID + + +### Documentation For Models + + - [Pet](docs/Pet.md) + + + +## Documentation For Authorization + + +Authentication schemes defined for the API: + +### iam + +- **Type**: API key +- **API key parameter name**: Authorization +- **Location**: HTTP header + diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/api.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/api.ts new file mode 100644 index 000000000000..fb8af79ee862 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/api.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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. + */ + + + +export * from './client/default-api'; + diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/base.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/base.ts new file mode 100644 index 000000000000..601d1c9ad7fb --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/base.ts @@ -0,0 +1,86 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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 type { Configuration } from './configuration'; +// Some imports not used depending on template conditions +// @ts-ignore +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; + +export const BASE_PATH = "https://abc123.execute-api.us-east-1.amazonaws.com/prod".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: RawAxiosRequestConfig; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath ?? basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + constructor(public field: string, msg?: string) { + super(msg); + this.name = "RequiredError" + } +} + +interface ServerMap { + [key: string]: { + url: string, + description: string, + }[]; +} + +/** + * + * @export + */ +export const operationServerMap: ServerMap = { +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/client/default-api.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/client/default-api.ts new file mode 100644 index 000000000000..8c092e4f28ec --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/client/default-api.ts @@ -0,0 +1,269 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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 type { Configuration } from '../configuration'; +import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; +import globalAxios from 'axios'; +// URLSearchParams not necessarily used +// @ts-ignore +import { URL, URLSearchParams } from 'url'; +// Some imports not used depending on template conditions +// @ts-ignore +import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common'; +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base'; +// @ts-ignore +import type { Pet } from '../models'; +/** + * DefaultApi - axios parameter creator + * @export + */ +export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createPet: async (pet: Pet, options: RawAxiosRequestConfig = {}): Promise => { + // verify required parameter 'pet' is not null or undefined + assertParamExists('createPet', 'pet', pet) + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication iam required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + localVarHeaderParameter['Content-Type'] = 'application/json'; + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + localVarRequestOptions.data = serializeDataIfNeeded(pet, localVarRequestOptions, configuration) + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/store/inventory`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication iam required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById: async (options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/pet`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + // authentication iam required + await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration) + + + + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DefaultApi - functional programming interface + * @export + */ +export const DefaultApiFp = function(configuration?: Configuration) { + const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration) + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async createPet(pet: Pet, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.createPet(pet, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.createPet']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getInventory(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{ [key: string]: number; }>> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getInventory(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.getInventory']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getPetById(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getPetById(options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['DefaultApi.getPetById']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, + } +}; + +/** + * DefaultApi - factory interface + * @export + */ +export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + const localVarFp = DefaultApiFp(configuration) + return { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + createPet(pet: Pet, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.createPet(pet, options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getInventory(options?: RawAxiosRequestConfig): AxiosPromise<{ [key: string]: number; }> { + return localVarFp.getInventory(options).then((request) => request(axios, basePath)); + }, + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getPetById(options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.getPetById(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +export class DefaultApi extends BaseAPI { + /** + * + * @summary Create a new pet + * @param {Pet} pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public createPet(pet: Pet, options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).createPet(pet, options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public getInventory(options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).getInventory(options).then((request) => request(this.axios, this.basePath)); + } + + /** + * + * @summary Find pet by ID + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public getPetById(options?: RawAxiosRequestConfig) { + return DefaultApiFp(this.configuration).getPetById(options).then((request) => request(this.axios, this.basePath)); + } +} + diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/common.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/common.ts new file mode 100644 index 000000000000..961578e694c4 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/common.ts @@ -0,0 +1,151 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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 type { Configuration } from "./configuration"; +import type { RequestArgs } from "./base"; +import type { AxiosInstance, AxiosResponse } from 'axios'; +import { RequiredError } from "./base"; +import { URL, URLSearchParams } from 'url'; + +/** + * + * @export + */ +export const DUMMY_BASE_URL = 'https://example.com' + +/** + * + * @throws {RequiredError} + * @export + */ +export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) { + if (paramValue === null || paramValue === undefined) { + throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`); + } +} + +/** + * + * @export + */ +export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) { + if (configuration && configuration.apiKey) { + const localVarApiKeyValue = typeof configuration.apiKey === 'function' + ? await configuration.apiKey(keyParamName) + : await configuration.apiKey; + object[keyParamName] = localVarApiKeyValue; + } +} + +/** + * + * @export + */ +export const setBasicAuthToObject = function (object: any, configuration?: Configuration) { + if (configuration && (configuration.username || configuration.password)) { + object["auth"] = { username: configuration.username, password: configuration.password }; + } +} + +/** + * + * @export + */ +export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const accessToken = typeof configuration.accessToken === 'function' + ? await configuration.accessToken() + : await configuration.accessToken; + object["Authorization"] = "Bearer " + accessToken; + } +} + +/** + * + * @export + */ +export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) { + if (configuration && configuration.accessToken) { + const localVarAccessTokenValue = typeof configuration.accessToken === 'function' + ? await configuration.accessToken(name, scopes) + : await configuration.accessToken; + object["Authorization"] = "Bearer " + localVarAccessTokenValue; + } +} + +function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; + if (typeof parameter === "object") { + if (Array.isArray(parameter)) { + (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); + } + else { + Object.keys(parameter).forEach(currentKey => + setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`) + ); + } + } + else { + if (urlSearchParams.has(key)) { + urlSearchParams.append(key, parameter); + } + else { + urlSearchParams.set(key, parameter); + } + } +} + +/** + * + * @export + */ +export const setSearchParams = function (url: URL, ...objects: any[]) { + const searchParams = new URLSearchParams(url.search); + setFlattenedQueryParams(searchParams, objects); + url.search = searchParams.toString(); +} + +/** + * + * @export + */ +export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) { + const nonString = typeof value !== 'string'; + const needsSerialization = nonString && configuration && configuration.isJsonMime + ? configuration.isJsonMime(requestOptions.headers['Content-Type']) + : nonString; + return needsSerialization + ? JSON.stringify(value !== undefined ? value : {}) + : (value || ""); +} + +/** + * + * @export + */ +export const toPathString = function (url: URL) { + return url.pathname + url.search + url.hash +} + +/** + * + * @export + */ +export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) { + return >(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url}; + return axios.request(axiosRequestArgs); + }; +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/configuration.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/configuration.ts new file mode 100644 index 000000000000..958d883c198c --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/configuration.ts @@ -0,0 +1,115 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + serverIndex?: number; + baseOptions?: any; + formDataCtor?: new () => any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * override server index + * + * @type {number} + * @memberof Configuration + */ + serverIndex?: number; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + /** + * The FormData constructor that will be used to create multipart form data + * requests. You can inject this here so that execution environments that + * do not support the FormData class can still run the generated client. + * + * @type {new () => FormData} + */ + formDataCtor?: new () => any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.serverIndex = param.serverIndex; + this.baseOptions = { + ...param.baseOptions, + headers: { + ...param.baseOptions?.headers, + }, + }; + this.formDataCtor = param.formDataCtor; + } + + /** + * 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. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/DefaultApi.md b/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/DefaultApi.md new file mode 100644 index 000000000000..800bd208bad0 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/DefaultApi.md @@ -0,0 +1,149 @@ +# DefaultApi + +All URIs are relative to *https://abc123.execute-api.us-east-1.amazonaws.com/prod* + +|Method | HTTP request | Description| +|------------- | ------------- | -------------| +|[**createPet**](#createpet) | **POST** /pet | Create a new pet| +|[**getInventory**](#getinventory) | **GET** /store/inventory | Returns pet inventories by status| +|[**getPetById**](#getpetbyid) | **GET** /pet | Find pet by ID| + +# **createPet** +> Pet createPet(pet) + + +### Example + +```typescript +import { + DefaultApi, + Configuration, + Pet +} from '@openapitools/typescript-axios-with-aws-iam'; + +const configuration = new Configuration(); +const apiInstance = new DefaultApi(configuration); + +let pet: Pet; // + +const { status, data } = await apiInstance.createPet( + pet +); +``` + +### Parameters + +|Name | Type | Description | Notes| +|------------- | ------------- | ------------- | -------------| +| **pet** | **Pet**| | | + + +### Return type + +**Pet** + +### Authorization + +[iam](../README.md#iam) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +|**201** | Pet created | - | +|**400** | Invalid input | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getInventory** +> { [key: string]: number; } getInventory() + + +### Example + +```typescript +import { + DefaultApi, + Configuration +} from '@openapitools/typescript-axios-with-aws-iam'; + +const configuration = new Configuration(); +const apiInstance = new DefaultApi(configuration); + +const { status, data } = await apiInstance.getInventory(); +``` + +### Parameters +This endpoint does not have any parameters. + + +### Return type + +**{ [key: string]: number; }** + +### Authorization + +[iam](../README.md#iam) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +|**200** | successful operation | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getPetById** +> Pet getPetById() + + +### Example + +```typescript +import { + DefaultApi, + Configuration +} from '@openapitools/typescript-axios-with-aws-iam'; + +const configuration = new Configuration(); +const apiInstance = new DefaultApi(configuration); + +const { status, data } = await apiInstance.getPetById(); +``` + +### Parameters +This endpoint does not have any parameters. + + +### Return type + +**Pet** + +### Authorization + +[iam](../README.md#iam) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +|**200** | successful operation | - | +|**404** | Pet not found | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/Pet.md b/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/Pet.md new file mode 100644 index 000000000000..d5f0190cc538 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/docs/Pet.md @@ -0,0 +1,24 @@ +# Pet + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **number** | | [optional] [default to undefined] +**name** | **string** | | [default to undefined] +**photoUrls** | **Array<string>** | | [default to undefined] + +## Example + +```typescript +import { Pet } from '@openapitools/typescript-axios-with-aws-iam'; + +const instance: Pet = { + id, + name, + photoUrls, +}; +``` + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/git_push.sh b/samples/client/petstore/typescript-axios/builds/with-aws-iam/git_push.sh new file mode 100644 index 000000000000..f53a75d4fabe --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/index.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/index.ts new file mode 100644 index 000000000000..11f5c26f65ce --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/index.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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. + */ + + +export * from "./api"; +export * from "./configuration"; +export * from "./models"; diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/index.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/index.ts new file mode 100644 index 000000000000..eccf4ec59cbb --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/index.ts @@ -0,0 +1 @@ +export * from './pet'; diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/pet.ts b/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/pet.ts new file mode 100644 index 000000000000..0a84c4066c5e --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/models/pet.ts @@ -0,0 +1,42 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * OpenAPI Petstore with AWS IAM + * Test API for AWS IAM authentication detection + * + * 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. + */ + + + +/** + * + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + 'id'?: number; + /** + * + * @type {string} + * @memberof Pet + */ + 'name': string; + /** + * + * @type {Array} + * @memberof Pet + */ + 'photoUrls': Array; +} + diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/package.json b/samples/client/petstore/typescript-axios/builds/with-aws-iam/package.json new file mode 100644 index 000000000000..825f6def065d --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/package.json @@ -0,0 +1,38 @@ +{ + "name": "@openapitools/typescript-axios-with-aws-iam", + "version": "1.0.0", + "description": "OpenAPI client for @openapitools/typescript-axios-with-aws-iam", + "author": "OpenAPI-Generator Contributors", + "repository": { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git" + }, + "keywords": [ + "axios", + "typescript", + "openapi-client", + "openapi-generator", + "@openapitools/typescript-axios-with-aws-iam" + ], + "license": "Unlicense", + "main": "./dist/index.js", + "typings": "./dist/index.d.ts", + "module": "./dist/esm/index.js", + "sideEffects": false, + "scripts": { + "build": "tsc && tsc -p tsconfig.esm.json", + "prepare": "npm run build" + }, + "dependencies": { + "axios": "^1.6.1", + "aws4": "^1.11.0", + "@aws-sdk/credential-provider-node": "^3.400.0" + }, + "devDependencies": { + "@types/node": "12.11.5 - 12.20.42", + "typescript": "^4.0 || ^5.0" + }, + "publishConfig": { + "registry": "https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.esm.json b/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.esm.json new file mode 100644 index 000000000000..2c0331cce040 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.esm.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "esnext", + "outDir": "dist/esm" + } +} diff --git a/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.json b/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.json new file mode 100644 index 000000000000..30dc264ec731 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/with-aws-iam/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "declaration": true, + "target": "ES6", + "module": "commonjs", + "noImplicitAny": true, + "outDir": "dist", + "rootDir": ".", + "moduleResolution": "node", + "typeRoots": [ + "node_modules/@types" + ] + }, + "exclude": [ + "dist", + "node_modules" + ] +} From d145b9edde9219b05153de3d868b3b50ab66e922 Mon Sep 17 00:00:00 2001 From: Kaitlin Davis Date: Fri, 20 Jun 2025 12:51:58 -0600 Subject: [PATCH 3/3] Add comments to yaml example file calling out the patterns --- .../src/test/resources/3_0/typescript-axios/with-aws-iam.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml index de99cca6b415..37ffc0751040 100644 --- a/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-aws-iam.yaml @@ -4,6 +4,7 @@ info: version: 1.0.0 description: Test API for AWS IAM authentication detection servers: + # Pattern 3 Check for AWS API Gateway URL patterns in servers - url: https://abc123.execute-api.us-east-1.amazonaws.com/prod security: - iam: [] @@ -61,10 +62,12 @@ paths: format: int32 components: securitySchemes: + # Pattern 2: Check for common AWS V4 signature scheme names iam: type: apiKey name: Authorization in: header + # Pattern 1: Check for AWS-specific extension x-amazon-apigateway-authtype: awsSigv4 schemas: Pet: