@eventcatalog/generator-amazon-apigateway 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -112,9 +112,15 @@ async function hydrate(openApiSpec, routeConfig, version) {
112
112
  operationObj["x-eventcatalog-message-name"] = config.name;
113
113
  }
114
114
  }
115
+ if (operationObj.requestBody?.content?.["application/json"]?.schema?.title === "Empty Schema") {
116
+ operationObj.requestBody.content["application/json"].schema["x-eventcatalog-render"] = false;
117
+ }
115
118
  }
116
119
  }
117
120
  }
121
+ if (modifiedSpec.components?.schemas?.Empty?.title === "Empty Schema") {
122
+ modifiedSpec.components.schemas.Empty["x-eventcatalog-render-schema-viewer"] = false;
123
+ }
118
124
  return modifiedSpec;
119
125
  }
120
126
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n }\n }\n }\n\n return modifiedSpec;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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,IAAI,aAAa,QAAQ,MAAM,QAC5C,uBAAK,QAAQ,IAAI,aAAa,yBAAyB;AAE3D,UAAQ,IAAI,aAAAC,QAAM,MAAM,cAAc,QAAQ,KAAK,MAAM,wBAAwB,CAAC;AAGlF,aAAW,OAAO,QAAQ,MAAM;AAC9B,YAAQ,IAAI,aAAAA,QAAM,KAAK,cAAc,IAAI,IAAI,OAAO,IAAI,MAAM,6BAA6B,CAAC;AAE5F,UAAM,SAAS,IAAI,4CAAiB,EAAE,QAAQ,IAAI,QAAQ,aAAa,QAAQ,YAAY,CAAC;AAE5F,UAAM,UAAU,MAAM,mBAAmB,QAAQ,IAAI,IAAI;AAEzD,QAAI,CAAC,SAAS;AACZ,cAAQ,IAAI,aAAAA,QAAM,OAAO,qBAAqB,IAAI,IAAI,iCAAiC,CAAC;AACxF;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,eAAe,QAAQ,SAAS,IAAI,SAAS;AAEvE,YAAQ,IAAI,aAAAA,QAAM,KAAK,kEAAkE,CAAC;AAC1F,UAAM,eAAe,MAAM,QAAQ,aAAa,IAAI,QAAQ,IAAI,OAAO;AAEvE,UAAM,aAAS,uBAAK,WAAW,GAAG,IAAI,IAAI,OAAO;AAGjD,UAAM,iBAAAC,QAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAE7C,YAAQ,IAAI,aAAAD,QAAM,KAAK,8BAA8B,MAAM,KAAK,CAAC;AACjE,cAAM,2BAAU,QAAQ,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,gEAAmE,CAAC;AAC5F,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,sCAAyC,SAAS,EAAE,CAAC;AAC/E;","names":["import_client_api_gateway","api","import_promises","chalk","fs"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,6BAAiC;;;ACAjC,gCAAuE;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,UAAU,IAAI,2CAAiB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,QAAI;AAEJ,QAAI;AACF,oBAAc,IAAI,YAAY,EAAE,OAAO,SAAS,IAAI;AACpD,aAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,SAAS,OAAO;AACd,aAAO,SAAS;AAA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W,OAAO,QAAQ,MAAM;AAC9B,YAAQ,IAAI,aAAAA,QAAM,KAAK,cAAc,IAAI,IAAI,OAAO,IAAI,MAAM,6BAA6B,CAAC;AAE5F,UAAM,SAAS,IAAI,4CAAiB,EAAE,QAAQ,IAAI,QAAQ,aAAa,QAAQ,YAAY,CAAC;AAE5F,UAAM,UAAU,MAAM,mBAAmB,QAAQ,IAAI,IAAI;AAEzD,QAAI,CAAC,SAAS;AACZ,cAAQ,IAAI,aAAAA,QAAM,OAAO,qBAAqB,IAAI,IAAI,iCAAiC,CAAC;AACxF;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,eAAe,QAAQ,SAAS,IAAI,SAAS;AAEvE,YAAQ,IAAI,aAAAA,QAAM,KAAK,kEAAkE,CAAC;AAC1F,UAAM,eAAe,MAAM,QAAQ,aAAa,IAAI,QAAQ,IAAI,OAAO;AAEvE,UAAM,aAAS,uBAAK,WAAW,GAAG,IAAI,IAAI,OAAO;AAGjD,UAAM,iBAAAC,QAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAE7C,YAAQ,IAAI,aAAAD,QAAM,KAAK,8BAA8B,MAAM,KAAK,CAAC;AACjE,cAAM,2BAAU,QAAQ,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,gEAAmE,CAAC;AAC5F,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,sCAAyC,SAAS,EAAE,CAAC;AAC/E;","names":["import_client_api_gateway","api","import_promises","chalk","fs"]}
package/dist/index.mjs CHANGED
@@ -78,9 +78,15 @@ async function hydrate(openApiSpec, routeConfig, version) {
78
78
  operationObj["x-eventcatalog-message-name"] = config.name;
79
79
  }
80
80
  }
81
+ if (operationObj.requestBody?.content?.["application/json"]?.schema?.title === "Empty Schema") {
82
+ operationObj.requestBody.content["application/json"].schema["x-eventcatalog-render"] = false;
83
+ }
81
84
  }
82
85
  }
83
86
  }
87
+ if (modifiedSpec.components?.schemas?.Empty?.title === "Empty Schema") {
88
+ modifiedSpec.components.schemas.Empty["x-eventcatalog-render-schema-viewer"] = false;
89
+ }
84
90
  return modifiedSpec;
85
91
  }
86
92
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n }\n }\n }\n\n return modifiedSpec;\n}\n"],"mappings":";AAAA,SAAS,oBAAAA,yBAAwB;;;ACAjC,SAA2B,kBAAkB,0BAA0B;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,UAAU,IAAI,iBAAiB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,QAAI;AAEJ,QAAI;AACF,oBAAc,IAAI,YAAY,EAAE,OAAO,SAAS,IAAI;AACpD,aAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,SAAS,OAAO;AACd,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,SAAS,OA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cAAQ,IAAI,MAAM,OAAO,qBAAqB,IAAI,IAAI,iCAAiC,CAAC;AACxF;AAAA,IACF;AAEA,UAAM,cAAc,MAAM,eAAe,QAAQ,SAAS,IAAI,SAAS;AAEvE,YAAQ,IAAI,MAAM,KAAK,kEAAkE,CAAC;AAC1F,UAAM,eAAe,MAAM,QAAQ,aAAa,IAAI,QAAQ,IAAI,OAAO;AAEvE,UAAM,SAAS,KAAK,WAAW,GAAG,IAAI,IAAI,OAAO;AAGjD,UAAM,GAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAE7C,YAAQ,IAAI,MAAM,KAAK,8BAA8B,MAAM,KAAK,CAAC;AACjE,UAAM,UAAU,QAAQ,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,UAAQ,IAAI,MAAM,MAAM;AAAA,gEAAmE,CAAC;AAC5F,UAAQ,IAAI,MAAM,MAAM;AAAA,sCAAyC,SAAS,EAAE,CAAC;AAC/E;","names":["APIGatewayClient","api","APIGatewayClient"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n"],"mappings":";AAAA,SAAS,oBAAAA,yBAAwB;;;ACAjC,SAA2B,kBAAkB,0BAA0B;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,UAAU,IAAI,iBAAiB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,QAAI;AAEJ,QAAI;AACF,oBAAc,IAAI,YAAY,EAAE,OAAO,SAAS,IAAI;AACpD,aAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,SAAS,OAAO;AACd,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,yCAAyC,KAAK;AAC5D,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,mBAAmB,QAA0B,SAAiB;AAClF,MAAI;AACF,QAAI;AACJ,OAAG;AACD,YAAM,UAAU,IAAI,mBAAmB;AAAA,QACrC;AAAA;AAAA,MACF,CAAC;AACD,YAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,YAAM,MAAM,SAAS,OAAO,KAAK,CAACC,SAAQA,KAAI,SAAS,OAAO;AAC9D,UAAI,KAAK;AACP,eAAO,IAAI;AAAA,MACb;AAEA,iBAAW,SAAS;AAAA,IACtB,SAAS;AAET,UAAM,IAAI,MAAM,kBAAkB,OAAO,aAAa;AAAA,EACxD,SAAS,OAAO;AACd,YAAQ,MAAM,+BAA+B,KAAK;AAClD,UAAM;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AAS,KAAK,WAAW,GAAG,IAAI,IAAI,OAAO;AAGjD,UAAM,GAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAE7C,YAAQ,IAAI,MAAM,KAAK,8BAA8B,MAAM,KAAK,CAAC;AACjE,UAAM,UAAU,QAAQ,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,UAAQ,IAAI,MAAM,MAAM;AAAA,gEAAmE,CAAC;AAC5F,UAAQ,IAAI,MAAM,MAAM;AAAA,sCAAyC,SAAS,EAAE,CAAC;AAC/E;","names":["APIGatewayClient","api","APIGatewayClient"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventcatalog/generator-amazon-apigateway",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Generator for Amazon API Gateway",
5
5
  "scripts": {
6
6
  "build": "tsup",