AWS variabel untuk impor OpenAPI - Amazon API Gateway

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

AWS variabel untuk impor OpenAPI

Anda dapat menggunakan AWS variabel berikut dalam definisi OpenAPI. API Gateway menyelesaikan variabel saat API diimpor. Untuk menentukan variabel, gunakan${variable-name}.

AWS variabel
Nama variabel Deskripsi
AWS::AccountId ID AWS akun yang mengimpor API — misalnya, 123456789012.
AWS::Partition AWS Partisi di mana API diimpor. Untuk AWS Wilayah standar, partisi adalahaws.
AWS::Region AWS Wilayah tempat API diimpor—misalnya,. us-east-2

AWS variabel contoh

Contoh berikut menggunakan AWS variabel untuk menentukan AWS Lambda fungsi untuk integrasi.

OpenAPI 3.0
openapi: "3.0.1" info: title: "tasks-api" version: "v1.0" paths: /: get: summary: List tasks description: Returns a list of tasks responses: 200: description: "OK" content: application/json: schema: type: array items: $ref: "#/components/schemas/Task" 500: description: "Internal Server Error" content: {} x-amazon-apigateway-integration: uri: arn:${AWS::Partition}:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:${AWS::Partition}:lambda:${AWS::Region}:${AWS::AccountId}:function:LambdaFunctionName/invocations responses: default: statusCode: "200" passthroughBehavior: "when_no_match" httpMethod: "POST" contentHandling: "CONVERT_TO_TEXT" type: "aws_proxy" components: schemas: Task: type: object properties: id: type: integer name: type: string description: type: string