Seleccione sus preferencias de cookies

Usamos cookies esenciales y herramientas similares que son necesarias para proporcionar nuestro sitio y nuestros servicios. Usamos cookies de rendimiento para recopilar estadísticas anónimas para que podamos entender cómo los clientes usan nuestro sitio y hacer mejoras. Las cookies esenciales no se pueden desactivar, pero puede hacer clic en “Personalizar” o “Rechazar” para rechazar las cookies de rendimiento.

Si está de acuerdo, AWS y los terceros aprobados también utilizarán cookies para proporcionar características útiles del sitio, recordar sus preferencias y mostrar contenido relevante, incluida publicidad relevante. Para aceptar o rechazar todas las cookies no esenciales, haga clic en “Aceptar” o “Rechazar”. Para elegir opciones más detalladas, haga clic en “Personalizar”.

Definición de OpenAPI de la API de calculadora sencilla

Modo de enfoque
Definición de OpenAPI de la API de calculadora sencilla - Amazon API Gateway

A continuación, se muestra la definición de OpenAPI de la API de calculadora sencilla. Puede importarla en su cuenta. Sin embargo, debe restablecer los permisos basados en los recursos en la función de Lambda después de la importación. Para ello, vuelva a seleccionar la función de Lambda que ha creado en su cuenta desde Integration Request (Solicitud de integración) en la consola de API Gateway. Esto hará que la consola de API Gateway restablezca los permisos necesarios. También puede utilizar AWS Command Line Interface para el comando add-permission de Lambda.

OpenAPI 2.0
{ "swagger": "2.0", "info": { "version": "2016-09-29T20:27:30Z", "title": "SimpleCalc" }, "host": "t6dve4zn25.execute-api.us-west-2.amazonaws.com", "basePath": "/demo", "schemes": [ "https" ], "paths": { "/": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "op", "in": "query", "required": false, "type": "string" }, { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_templates", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } }, "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "in": "body", "name": "Input", "required": true, "schema": { "$ref": "#/definitions/Input" } } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_match", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } } }, "/{a}": { "x-amazon-apigateway-any-method": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" } ], "responses": { "404": { "description": "404 response" } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "{\"statusCode\": 200}" }, "passthroughBehavior": "when_no_match", "responses": { "default": { "statusCode": "404", "responseTemplates": { "application/json": "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "type": "mock" } } }, "/{a}/{b}": { "x-amazon-apigateway-any-method": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" } ], "responses": { "404": { "description": "404 response" } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "{\"statusCode\": 200}" }, "passthroughBehavior": "when_no_match", "responses": { "default": { "statusCode": "404", "responseTemplates": { "application/json": "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "type": "mock" } } }, "/{a}/{b}/{op}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "op", "in": "path", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_templates", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } } } }, "definitions": { "Input": { "type": "object", "properties": { "a": { "type": "number" }, "b": { "type": "number" }, "op": { "type": "string" } }, "title": "Input" }, "Output": { "type": "object", "properties": { "c": { "type": "number" } }, "title": "Output" }, "Result": { "type": "object", "properties": { "input": { "$ref": "#/definitions/Input" }, "output": { "$ref": "#/definitions/Output" } }, "title": "Result" } } }
OpenAPI 3.0
{ "openapi" : "3.0.1", "info" : { "title" : "SimpleCalc", "version" : "2016-09-29T20:27:30Z" }, "servers" : [ { "url" : "https://t6dve4zn25.execute-api.us-west-2.amazonaws.com/{basePath}", "variables" : { "basePath" : { "default" : "demo" } } } ], "paths" : { "/{a}/{b}" : { "x-amazon-apigateway-any-method" : { "parameters" : [ { "name" : "a", "in" : "path", "required" : true, "schema" : { "type" : "string" } }, { "name" : "b", "in" : "path", "required" : true, "schema" : { "type" : "string" } } ], "responses" : { "404" : { "description" : "404 response", "content" : { } } }, "x-amazon-apigateway-integration" : { "type" : "mock", "responses" : { "default" : { "statusCode" : "404", "responseTemplates" : { "application/json" : "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "requestTemplates" : { "application/json" : "{\"statusCode\": 200}" }, "passthroughBehavior" : "when_no_match" } } }, "/{a}/{b}/{op}" : { "get" : { "parameters" : [ { "name" : "a", "in" : "path", "required" : true, "schema" : { "type" : "string" } }, { "name" : "b", "in" : "path", "required" : true, "schema" : { "type" : "string" } }, { "name" : "op", "in" : "path", "required" : true, "schema" : { "type" : "string" } } ], "responses" : { "200" : { "description" : "200 response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Result" } } } } }, "x-amazon-apigateway-integration" : { "type" : "aws", "httpMethod" : "POST", "uri" : "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:111122223333:function:Calc/invocations", "responses" : { "default" : { "statusCode" : "200", "responseTemplates" : { "application/json" : "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "requestTemplates" : { "application/json" : "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "passthroughBehavior" : "when_no_templates" } } }, "/" : { "get" : { "parameters" : [ { "name" : "op", "in" : "query", "schema" : { "type" : "string" } }, { "name" : "a", "in" : "query", "schema" : { "type" : "string" } }, { "name" : "b", "in" : "query", "schema" : { "type" : "string" } } ], "responses" : { "200" : { "description" : "200 response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Result" } } } } }, "x-amazon-apigateway-integration" : { "type" : "aws", "httpMethod" : "POST", "uri" : "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:111122223333:function:Calc/invocations", "responses" : { "default" : { "statusCode" : "200", "responseTemplates" : { "application/json" : "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "requestTemplates" : { "application/json" : "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "passthroughBehavior" : "when_no_templates" } }, "post" : { "requestBody" : { "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Input" } } }, "required" : true }, "responses" : { "200" : { "description" : "200 response", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/Result" } } } } }, "x-amazon-apigateway-integration" : { "type" : "aws", "httpMethod" : "POST", "uri" : "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:111122223333:function:Calc/invocations", "responses" : { "default" : { "statusCode" : "200", "responseTemplates" : { "application/json" : "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "passthroughBehavior" : "when_no_match" } } }, "/{a}" : { "x-amazon-apigateway-any-method" : { "parameters" : [ { "name" : "a", "in" : "path", "required" : true, "schema" : { "type" : "string" } } ], "responses" : { "404" : { "description" : "404 response", "content" : { } } }, "x-amazon-apigateway-integration" : { "type" : "mock", "responses" : { "default" : { "statusCode" : "404", "responseTemplates" : { "application/json" : "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "requestTemplates" : { "application/json" : "{\"statusCode\": 200}" }, "passthroughBehavior" : "when_no_match" } } } }, "components" : { "schemas" : { "Input" : { "title" : "Input", "type" : "object", "properties" : { "a" : { "type" : "number" }, "b" : { "type" : "number" }, "op" : { "type" : "string" } } }, "Output" : { "title" : "Output", "type" : "object", "properties" : { "c" : { "type" : "number" } } }, "Result" : { "title" : "Result", "type" : "object", "properties" : { "input" : { "$ref" : "#/components/schemas/Input" }, "output" : { "$ref" : "#/components/schemas/Output" } } } } } }
{ "swagger": "2.0", "info": { "version": "2016-09-29T20:27:30Z", "title": "SimpleCalc" }, "host": "t6dve4zn25.execute-api.us-west-2.amazonaws.com", "basePath": "/demo", "schemes": [ "https" ], "paths": { "/": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "op", "in": "query", "required": false, "type": "string" }, { "name": "a", "in": "query", "required": false, "type": "string" }, { "name": "b", "in": "query", "required": false, "type": "string" } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_templates", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } }, "post": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "in": "body", "name": "Input", "required": true, "schema": { "$ref": "#/definitions/Input" } } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_match", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } } }, "/{a}": { "x-amazon-apigateway-any-method": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" } ], "responses": { "404": { "description": "404 response" } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "{\"statusCode\": 200}" }, "passthroughBehavior": "when_no_match", "responses": { "default": { "statusCode": "404", "responseTemplates": { "application/json": "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "type": "mock" } } }, "/{a}/{b}": { "x-amazon-apigateway-any-method": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" } ], "responses": { "404": { "description": "404 response" } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "{\"statusCode\": 200}" }, "passthroughBehavior": "when_no_match", "responses": { "default": { "statusCode": "404", "responseTemplates": { "application/json": "{ \"Message\" : \"Can't $context.httpMethod $context.resourcePath\" }" } } }, "type": "mock" } } }, "/{a}/{b}/{op}": { "get": { "consumes": [ "application/json" ], "produces": [ "application/json" ], "parameters": [ { "name": "a", "in": "path", "required": true, "type": "string" }, { "name": "b", "in": "path", "required": true, "type": "string" }, { "name": "op", "in": "path", "required": true, "type": "string" } ], "responses": { "200": { "description": "200 response", "schema": { "$ref": "#/definitions/Result" } } }, "x-amazon-apigateway-integration": { "requestTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"a\" : $input.params('a'),\n \"b\" : $input.params('b'),\n \"op\" : \"$input.params('op')\"\n}" }, "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", "passthroughBehavior": "when_no_templates", "httpMethod": "POST", "responses": { "default": { "statusCode": "200", "responseTemplates": { "application/json": "#set($inputRoot = $input.path('$'))\n{\n \"input\" : {\n \"a\" : $inputRoot.a,\n \"b\" : $inputRoot.b,\n \"op\" : \"$inputRoot.op\"\n },\n \"output\" : {\n \"c\" : $inputRoot.c\n }\n}" } } }, "type": "aws" } } } }, "definitions": { "Input": { "type": "object", "properties": { "a": { "type": "number" }, "b": { "type": "number" }, "op": { "type": "string" } }, "title": "Input" }, "Output": { "type": "object", "properties": { "c": { "type": "number" } }, "title": "Output" }, "Result": { "type": "object", "properties": { "input": { "$ref": "#/definitions/Input" }, "output": { "$ref": "#/definitions/Output" } }, "title": "Result" } } }
PrivacidadTérminos del sitioPreferencias de cookies
© 2025, Amazon Web Services, Inc o sus afiliados. Todos los derechos reservados.