swift-server / swift-openapi-lambda

An AWS Lambda transport for Swift OpenAPI
Apache License 2.0
10 stars 1 forks source link

Missing @events/GetQuote.json #6

Closed atacan closed 4 months ago

atacan commented 8 months ago

in the README we see

curl -v -X POST --header "Content-Type: application/json" --data @events/GetQuote.json  http://127.0.0.1:7000/invoke

but this repository doesn't not have events folder or json file.

sebsto commented 6 months ago

Hello @atacan You can figure out the JSON passed to your Lambda function by printing a String representation of the input object.

For the AWS API Gateway (HTTP API), the event reference is here https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html

The Swift implementation is defined here https://github.com/swift-server/swift-aws-lambda-events/blob/main/Sources/AWSLambdaEvents/APIGateway%2BV2.swift

Here is the JSON file I use:

{
  "rawQueryString": "",
  "headers": {
    "host": "b2k1t8fon7.execute-api.us-east-1.amazonaws.com",
    "x-forwarded-port": "443",
    "content-length": "0",
    "x-amzn-trace-id": "Root=1-6571d134-63dbe8ee21efa87555d59265",
    "x-forwarded-for": "191.95.148.219",
    "x-forwarded-proto": "https",
    "accept": "*/*",
    "user-agent": "curl/8.1.2"
  },
  "requestContext": {
    "apiId": "b2k1t8fon7",
    "http": {
      "sourceIp": "191.95.148.219",
      "userAgent": "curl/8.1.2",
      "method": "GET",
      "path": "/stocks/AAPL",
      "protocol": "HTTP/1.1"
    },
    "timeEpoch": 1701957940365,
    "domainPrefix": "b2k1t8fon7",
    "accountId": "486652066693",
    "time": "07/Dec/2023:14:05:40 +0000",
    "stage": "$default",
    "domainName": "b2k1t8fon7.execute-api.us-east-1.amazonaws.com",
    "requestId": "Pk2gOia2IAMEPOw="
  },
  "isBase64Encoded": false,
  "version": "2.0",
  "routeKey": "$default",
  "rawPath": "/stocks/AAPL"
}
sebsto commented 4 months ago

I added a sample JSON file for ease of use https://github.com/swift-server/swift-openapi-lambda/commit/2b01689bcc2c3cc228e2c556f124345ddd6344bf