Giter Club home page Giter Club logo

aws-apigateway-importer's Introduction

Amazon API Gateway Importer

The Amazon API Gateway Importer lets you create or update Amazon API Gateway APIs from a Swagger or RAML API representation.

To learn more about API Gateway, please see the service documentation or the API documentation.

Build Status

Updates

April 5, 2016: Swagger/OpenAPI import is now generally available in the API Gateway REST API, the AWS CLI and all AWS SDKs. You can also import and export Swagger definitions using the API Gateway console. This release addresses many of the open issues and feedback in this repository.

Customers are encouraged to migrate their workflow to the standard AWS tools. aws-apigateway-importer will receive minimal support from the API Gateway team going forward. Pull requests will be periodically reviewed. Customers using RAML definitions should continue to use aws-apigateway-importer for the time being.

Thanks for all of your feedback and contributions to this tool. Any feedback or issues going forward should be directed to the official API Gateway forums. - @rpgreen

Usage

Prerequisites

Credentials

This tool requires AWS credentials to be configured in at least one of the locations specified by the default credential provider chain.

It will look for configured credentials in environment variables, Java system properties, AWS SDK/CLI profile credentials, and EC2 instance profile credentials.

Build

Build with mvn assembly:assembly

Import a new API

./aws-api-import.sh --create path/to/swagger.json

./aws-api-import.sh -c path/to/api.raml

Update an existing API and deploy it to a stage

./aws-api-import.sh --update API_ID --deploy STAGE_NAME path/to/swagger.yaml

./aws-api-import.sh --update API_ID --deploy STAGE_NAME --raml-config path/to/config.json path/to/api.raml

For Windows environments replace ./aws-api-import.sh with ./aws-api-import.cmd in the examples.

API Gateway Extension Example

You can fully define an API Gateway API in Swagger using the x-amazon-apigateway-auth and x-amazon-apigateway-integration extensions, or in RAML using an external configuration file.

Defined on an Operation:

"x-amazon-apigateway-auth" : {
    "type" : "aws_iam"
},
"x-amazon-apigateway-integration" : {
   "type" : "aws",
   "uri" : "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:MY_ACCT_ID:function:helloWorld/invocations",
   "httpMethod" : "POST",
   "credentials" : "arn:aws:iam::MY_ACCT_ID:role/lambda_exec_role",
   "requestTemplates" : {
       "application/json" : "json request template 2",
       "application/xml" : "xml request template 2"
   },
   "requestParameters" : {
       "integration.request.path.integrationPathParam" : "method.request.querystring.latitude",
       "integration.request.querystring.integrationQueryParam" : "method.request.querystring.longitude"
   },
   "cacheNamespace" : "cache-namespace",
   "cacheKeyParameters" : [],
   "responses" : {
       "2\\d{2}" : {
           "statusCode" : "200",
           "responseParameters" : {
               "method.response.header.test-method-response-header" : "integration.response.header.integrationResponseHeaderParam1"
           },
           "responseTemplates" : {
               "application/json" : "json 200 response template",
               "application/xml" : "xml 200 response template"
           }
       },
       "default" : {
           "statusCode" : "400",
           "responseParameters" : {
               "method.response.header.test-method-response-header" : "'static value'"
           },
           "responseTemplates" : {
               "application/json" : "json 400 response template",
               "application/xml" : "xml 400 response template"
           }
       }
   }
}

Testing

mvn test

aws-apigateway-importer's People

Contributors

arielatmuseami avatar blakeembrey avatar bryancrotaz avatar chriskozak avatar emmacarruthers avatar georgekankava avatar grim-luminal avatar hyandell avatar isabinin avatar jackrk avatar joshuajabbour avatar jt0 avatar mpuittinen avatar rpgreen avatar sam-martin avatar tq-jappy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-apigateway-importer's Issues

How to get identifier of imported API?

How can I get identitfier of API created by importer, in a way that can be reused by following update/deploy commands?
Is it possible to update aws-api-import to return the identifier?

[Question] How do you map response codes?

I hope I'm not out of line asking this question here, but since swagger-importer sits nicely between the technologies at hand, I'm hoping someone here may be able to help out.

How does one map the the response codes appropriately between an API defined in Swagger and AAG? I've seen that we can do regex matching to have all 500 level codes mapped to a single 500 error code. And that might be fine for server side errors, but when we talk about client side errors (the 400s), it seems to me that any number of responses are possible, and it doesn't make sense to map 4XX => 400.

So, I wrote code to manually map app the responses from my API to match those available in AAG. As you can imagine, the resulting Swagger file is huge and Swagger-UI lists every single response code even though it's not really needed (see image below).

swagger_ui

Now, of course, if I omit the definition of the response code, AAG will error out because it doesn't understand what it should do with the response code.

I feel like I'm doing something wrong here, but I don't see any other way. What are others doing.. surely I can't be the only one experiencing this.

Thanks so much for your help.
Aaron.

Error updating API with basePath with more than 1 element

I wonder if someone can help me out here. I'm able to successfully --create my API and from what I can tell, everything is working as expected. However, when I deploy, I'm getting an Invalid Resource identifier specified exception, and I can't figure out while.

Here's my Swagger configuration:

{  
  "swagger":"2.0",
  "info":{  
    "version":"v1",
    "title":"Company API Documentation",
    "description":"Test our API services using I/O Docs. You can also view our written documentation.",
    "termsOfService":"http://www.company.com/docs/SNI-terms.pdf",
    "contact":{  
      "name":"[email protected]"
    }
  },
  "host":"client.company.com",
  "basePath":"/api/v1",
  "consumes":[  
    "application/json"
  ],
  "produces":[  
    "application/json"
  ],
  "definitions":{  

  },
  "paths":{  
    "/categories":{  
      "get":{  
        "summary":"Get all categories",
        "description":"Get all categories in our database",
        "operationId":"index",
        "tags":[  
          "Categories"
        ],
        "responses":{  
          "200":{  

          }
        },
        "parameters":[  
          {  
            "name":"api_key",
            "in":"query",
            "required":true,
            "type":"string"
          }
        ],
        "x-amazon-apigateway-integration":{  
          "type":"http",
          "httpMethod":"GET",
          "uri":"http://client.company.com/api/v1/categories",
          "responses":{  
            "2\\d{2}":{  
              "statusCode":"200"
            }
          },
          "requestParameters":{  
            "integration.request.querystring.api_key":"method.request.querystring.api_key"
          }
        }
      }
    },
    "/players":{  
      "get":{  
        "summary":"Get all your player",
        "description":"Get all players that belong to your company",
        "operationId":"index",
        "tags":[  
          "Players"
        ],
        "responses":{  
          "200":{  

          }
        },
        "parameters":[  
          {  
            "name":"api_key",
            "in":"query",
            "required":true,
            "type":"string"
          }
        ],
        "x-amazon-apigateway-integration":{  
          "type":"http",
          "httpMethod":"GET",
          "uri":"http://client.company.com/api/v1/players",
          "responses":{  
            "2\\d{2}":{  
              "statusCode":"200"
            }
          },
          "requestParameters":{  
            "integration.request.querystring.api_key":"method.request.querystring.api_key"
          }
        }
      }
    }
  }
}

Here, I successfully create the API:

imac5k:aws-apigateway-swagger-importer arustad (master)$ ./aws-api-import.sh --create /tmp/swagger.json
2015-08-27 08:13:49,687 INFO - Attempting to create API from Swagger definition. Swagger file: /tmp/swagger.json
reading from /tmp/swagger.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-08-27 08:13:49,743 INFO - Parsed Swagger with 2 paths
2015-08-27 08:13:49,745 INFO - Creating API with name Company API Documentation
2015-08-27 08:13:50,195 INFO - Removing default model Empty
2015-08-27 08:13:50,328 INFO - Removing default model Error
2015-08-27 08:13:50,564 INFO - Creating resource 'api' with parent 'null'
2015-08-27 08:13:51,425 INFO - Creating resource 'v1' with parent 'api'
2015-08-27 08:13:52,305 INFO - Creating resource 'categories' with parent 'v1'
2015-08-27 08:13:53,250 INFO - Creating method response for api c5ghnjcb91 and method GET and status 200
2015-08-27 08:13:53,250 WARN - No description found for model, will generate a unique model name
2015-08-27 08:13:53,548 INFO - Creating method parameter for api c5ghnjcb91 and method GET with name method.request.querystring.api_key
2015-08-27 08:13:53,673 INFO - Creating integration with type HTTP
2015-08-27 08:13:54,056 INFO - Creating method for api id c5ghnjcb91 and resource id gk4le6 with method get
2015-08-27 08:13:54,896 INFO - Creating resource 'players' with parent 'v1'
2015-08-27 08:13:55,867 INFO - Creating method response for api c5ghnjcb91 and method GET and status 200
2015-08-27 08:13:55,867 WARN - No description found for model, will generate a unique model name
2015-08-27 08:13:56,310 INFO - Creating method parameter for api c5ghnjcb91 and method GET with name method.request.querystring.api_key
2015-08-27 08:13:56,411 INFO - Creating integration with type HTTP
2015-08-27 08:13:56,801 INFO - Creating method for api id c5ghnjcb91 and resource id p7xgzv with method get

But when I update, and Exception is thrown:

imac5k:aws-apigateway-swagger-importer arustad (master)$ ./aws-api-import.sh --update c5ghnjcb91 /tmp/swagger.json --deploy beta
2015-08-27 08:16:47,052 INFO - Attempting to update API from Swagger definition. API identifier: c5ghnjcb91 Swagger file: /tmp/swagger.json
reading from /tmp/swagger.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-08-27 08:16:47,124 INFO - Parsed Swagger with 2 paths
2015-08-27 08:16:48,111 INFO - Cleaning up removed resources
2015-08-27 08:16:48,215 INFO - Removing deleted resource /api
2015-08-27 08:16:48,589 INFO - Removing deleted resource /api/v1
2015-08-27 08:16:48,689 ERROR - Error importing API from Swagger
com.amazonaws.services.apigateway.model.NotFoundException: Invalid Resource identifier specified (Service: null; Status Code: 404; Error Code: null; Request ID: 43f56807-4cc6-11e5-94d8-7b4d30e2740e)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
        at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
        at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
        at com.amazonaws.hal.client.HalClient.deleteResource(HalClient.java:142)
        at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:129)
        at com.sun.proxy.$Proxy30.deleteResource(Unknown Source)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.deleteResource(ApiGatewaySdkSwaggerApiImporter.java:232)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$cleanupResources$11(ApiGatewaySdkSwaggerApiImporter.java:639)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter$$Lambda$5/40191541.accept(Unknown Source)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.cleanupResources(ApiGatewaySdkSwaggerApiImporter.java:637)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateResources(ApiGatewaySdkSwaggerApiImporter.java:547)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:110)
        at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
imac5k:aws-apigateway-swagger-importer arustad (master)$

I'm not sure what the issue is here. If anyone can help that would be great.
Thanks!
Aaron

Conflicting path

Hi,

I get the following error:

2015-10-17 21:17:56,614 ERROR - Error importing API definition
com.amazonaws.services.apigateway.model.BadRequestException: Resource with id 'e3ns0s' has a conflicting path (Service: null; Status Code: 400; Error Code: null; Request ID: 103c2964-7536-11e5-9ae1-5d1d1101b2f0)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)

My schemas is as follow:

swagger: '2.0'
info:
  version: '0.1'
  title: SA Client API
  description: API for SA Fan App and user facing website.
  termsOfService: 'http://swagger.io/terms/'
  contact:
    name: Sport Archive Support
    email: [email protected]
host: sportarchive.tv
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  /assets:
    get:
      description: |
        Get a list of assets in chronological order. 100 max at a time, 10 per
        default. You can limit the number of returns using 'limit' and get more
        by using the return value of 'next' from the result data of your first
        call.
      operationId: listAssets
      parameters:
        - name: limit
          in: query
          description: Limit the max number of assets returned. 100 Max. 10 Default
          required: false
          type: integer
          maximum: 100
          minimum: 1
        - name: startKey
          in: query
          description: StartKey where to start in list
          required: false
          type: string
        - name: endKey
          in: query
          description: EndKey where to stop in list
          required: false
          type: string
      responses:
        '200':
          description: list of assets
          schema:
            type: object
            items:
              $ref: '#/definitions/AssetsList'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/Error'
      x-amazon-apigateway-auth:
        type: aws_iam
      x-amazon-apigateway-integration:
        type: http
        uri: 'https://api.orchestrate.io/v0/assets'
        httpMethod: GET
        requestParameters:
          integration.request.querystring.limit: method.request.querystring.limit
          integration.request.querystring.startKey: method.request.querystring.startKey
          integration.request.querystring.endKey: method.request.querystring.endKey
        cacheNamespace: "cache namespace"
        responses:
          '200':
            statusCode: "200"
  /assets/{asset_id}:
    get:
      description: |
        Get one Asset
      operationId: getAsset
      parameters:
        - name: asset_id
          in: path
          description: ID of the item to get
          required: true
          type: string
      responses:
        '200':
          description: One asset
          schema:
            type: object
            items:
              $ref: '#/definitions/Asset'
        default:
          description: unexpected error
          schema:
            $ref: '#/definitions/Error'
[...]

Apparently it doesn't like '/assets/{asset_id}' and says it conflicts with '/assets/'.
Any any idea why this schemas fails to validate ?

Another point, if instead of {asset_id} I put {id} (which I'd like to do), I get a different error:

2015-10-17 21:12:44,430 ERROR - Error importing API definition
com.amazonaws.services.apigateway.model.BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping identifier specified] (Service: null; Status Code: 400; Error Code: null; Request ID: 562771a0-7535-11e5-9ae1-5d1d1101b2f0)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)

thanks for the help

Provide Some Basic Examples

I'm referencing the README and this deleted file for examples on how to include the Swagger API Gateway Extension for each method.

Could you gents throw together a few more examples? I'm currently looking for examples on:

  • How request and response templates are included
  • How to specify no "Auth" on my method
  • I've hooked up a method to use a lambda via this uri, but it registers the Integration Type as a AWS Service Proxy, instead of Lambda Function. How can I modify this uri to set the Integration Type as a Lambda function: arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:871893991718:function:users_show

Fails occasionally on update due to "mapping expression invalid"

I've got a swagger configuration that imports correctly once, but on a second run/update, it fails with an exception:

2015-10-15 12:02:22,866 INFO - Creating method response for api bpd5pjgkug and method GET and status 504
2015-10-15 12:02:22,866 WARN - No description found for model, will generate a unique model name
2015-10-15 12:02:23,131 INFO - Creating method response for api bpd5pjgkug and method GET and status 505
2015-10-15 12:02:23,131 WARN - No description found for model, will generate a unique model name
2015-10-15 12:02:23,510 INFO - Creating integration with type HTTP
2015-10-15 12:02:23,666 ERROR - Error importing API definition
com.amazonaws.services.apigateway.model.BadRequestException: Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping identifier specified] (Service: null; Status Code: 400; Error Code: null; Request ID: e17aae1c-7366-11e5-91eb-2b89a6ae3421)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1181)
        at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:766)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:485)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:306)
        at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
        at com.amazonaws.hal.client.HalClient.putResource(HalClient.java:122)
        at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:125)
        at com.sun.proxy.$Proxy38.putIntegration(Unknown Source)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createIntegration(ApiGatewaySdkSwaggerApiImporter.java:256)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethod(ApiGatewaySdkSwaggerApiImporter.java:411)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethods(ApiGatewaySdkSwaggerApiImporter.java:134)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:83)
        at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:143)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:74)

The command I am running is ./aws-api-import.sh --update API_ID /tmp/swagger.json

My swagger.json file can be found here

Any ideas why this might be happening?

request parameters, all ok on creation, bug on update.

hi, this is part of my representation:

"/contactform": {
"post": {
"description": "send mail",
"parameters": [{
"name": "SesEmail",
"in": "body",
"required": "true",
"type": "application/json",
"schema": {
"$ref": "#/definitions/SesEmail"
}
}],
"responses": RESPONSES,
"security": SECURITY,
"x-amazon-apigateway-auth": {
"type": AWS_AUTH_TYPE
},
"x-amazon-apigateway-integration": {
"type": "aws",
"uri": LAMBDA_ARN("Ses_SendEmail"),
"httpMethod": "POST",
"credentials": ROLE_ARN("Ses_SendEmail"),
"requestTemplates": {
"application/json": IMPORT("request/contactform_POST.vtl")
},
"responses": RESPONSES_INTEGRATION
}
},
"options": OPTIONS_CORS
}

when i use the --create command to build the representation all goes fine but, if I try to use the command --update my method do not have the request model.
The api that i try to update has only the method without any type of integration

Simple Hello World API Import examples

Instead of the generic command examples

./aws-api-import.sh --create path/to/swagger.json
./aws-api-import.sh -c path/to/api.raml

which really only show me how to use a CLI. It would be nice to have a hello.swagger and a hello.raml file which are in the repo and used in delineated examples in the README documentation. This would help people who are familiar with API Gateway, but not as familiar with Swagger nor this importer.

Example

./aws-api-import.sh -t hello.swagger
...and expected output...
./aws-api-import.sh -c hello.swagger
...and expected output...
./aws-api-import.sh -t hello.raml
...and expected output...
./aws-api-import.sh -c hello.raml
...and expected output...

Swagger body parameter causing NullPointerException

I have an issue updating the API when a body parameter is defined for Swagger.

If I update the API with the following Swagger configuration (note body included) when there are no methods defined in AAG

api_gateway

{  
  "swagger":"2.0",
  "info":{  
    "version":"v1",
    "title":"{hidden} API",
    "description":"Test our API services using I/O Docs. You can also view our written documentation.",
    "termsOfService":"http://www.{hidden}.com/docs/SNI-terms.pdf",
    "contact":{  
      "name":"support@{hidden}.com"
    }
  },
  "host":"api.{hidden}.com",
  "basePath":"/v1",
  "consumes":[  
    "application/json"
  ],
  "produces":[  
    "application/json"
  ],
  "definitions":{  

  },
  "paths":{  
    "/videos/{id}/metadata":{  
      "put":{  
        "summary":"Update Video Metadata",
        "description":"Update metadata for an an existing video",
        "operationId":"metadata",
        "tags":[  
          "Videos"
        ],
        "responses":{  
          "200":{  
            "headers":{  
              "Access-Control-Allow-Headers":{  
                "type":"string"
              },
              "Access-Control-Allow-Methods":{  
                "type":"string"
              },
              "Access-Control-Allow-Origin":{  
                "type":"string"
              }
            }
          }
        },
        "parameters":[  
          {  
            "name":"api_key",
            "in":"query",
            "required":true,
            "type":"string"
          },
          {  
            "name":"id",
            "description":"The hosted location of a video thumbnail (an http or https URL)",
            "in":"path",
            "required":false,
            "type":"string"
          },
          {  
            "name":"body",
            "in":"body",
            "required":true,
            "type":"string"
          }
        ],
        "x-amazon-apigateway-integration":{  
          "type":"http",
          "httpMethod":"PUT",
          "uri":"http://app.{hidden}.com/api/v1/videos/{id}/metadata",
          "responses":{  
            "2\\d{2}":{  
              "statusCode":"200",
              "responseParameters":{  
                "method.response.header.Access-Control-Allow-Headers":"'Content-Type,X-Amz-Date,Authorization'",
                "method.response.header.Access-Control-Allow-Methods":"'GET,POST'",
                "method.response.header.Access-Control-Allow-Origin":"'*'"
              }
            }
          },
          "requestParameters":{  
            "integration.request.querystring.api_key":"method.request.querystring.api_key",
            "integration.request.path.id":"method.request.path.id"
          }
        }
      }
    }
  }
}

I get the following exception:

ip-192-168-2-29:aws-apigateway-swagger-importer arustad (master)$ ./aws-api-import.sh --update cddfwfu745 /tmp/swagger.json --deploy beta
2015-09-08 09:01:43,639 INFO - Attempting to update API from Swagger definition. API identifier: cddfwfu745 Swagger file: /tmp/swagger.json
reading from /tmp/swagger.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-09-08 09:01:43,709 INFO - Parsed Swagger with 1 paths
2015-09-08 09:01:44,448 INFO - Creating resource 'v1' with parent 'null'
2015-09-08 09:01:45,300 INFO - Creating resource 'videos' with parent 'v1'
2015-09-08 09:01:46,139 INFO - Creating resource '{id}' with parent 'videos'
2015-09-08 09:01:47,025 INFO - Creating resource 'metadata' with parent '{id}'
2015-09-08 09:01:47,813 INFO - Cleaning up removed resources
2015-09-08 09:01:48,035 WARN - No description found for model, will generate a unique model name
2015-09-08 09:01:48,035 INFO - Creating new model referenced from parameter: model00dea854
2015-09-08 09:01:48,035 INFO - Creating model for api id cddfwfu745 with name model00dea854
2015-09-08 09:01:48,036 ERROR - Error importing API from Swagger
java.lang.NullPointerException
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModel(ApiGatewaySdkSwaggerApiImporter.java:282)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$createMethod$3(ApiGatewaySdkSwaggerApiImporter.java:377)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter$$Lambda$9/1849015357.accept(Unknown Source)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethod(ApiGatewaySdkSwaggerApiImporter.java:364)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethods(ApiGatewaySdkSwaggerApiImporter.java:348)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:111)
        at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
ip-192-168-2-29:aws-apigateway-swagger-importer arustad (master)$

If I comment out the body parameter, I can update successfully and everything in AAG looks right (as it adds the body for me). However, since the Swagger file is missing the body now, the Swagger API documentation is incorrect. Now, if I uncomment the body and update again, the deploy to AAG succeeds and my Swagger Documentation is now correctly including the body.

Any ideas why this might be happening and how I can work around it?

Thanks!
Aaron.

Feature Request: use EC2 Role temp credentials

Hello,

I'm attempting to use the importer as part of a continuous delivery pipeline (using AWS CodePipeline). As part of this pipeline I'm running the importer from an EC2 instance with an EC2 Role policy to grant write permissions to API Gateway. But the importer is exiting with error because I don't think it can get temp credentials for an EC2 role. The error tells me to use "aws configure". As a stopgap I've created an IAM user for this importer to use, but I'd like to leverage roles and not have credentials on the instance. Is this currently possible? If not, could you please add this feature to your backlog?

Thank you!
Nick

Experienced Error Resulting in ...model.BadRequestException: Invalid AWS URI

I'm running the swagger.yaml file from the newbie example here:
https://github.com/awslabs/api-gateway-secure-pet-store
I've configured everything in AWS and modified the swagger.yaml file per the instructions.

My command is this:
./aws-api-import.sh --create ~/Documents/htdocs/dev/api-gateway-secure-pet-store/src/main/resources/swagger.yaml

and I'm getting the failure below.

(First, a bunch of other INFO statements showing the /login section worked fine.
Then it starts processing the "pets" path.)

2015-10-21 22:07:07,118 INFO - Creating resource 'pets' on 967xzerqi0
2015-10-21 22:07:07,241 INFO - Found input model reference NewPet
2015-10-21 22:07:07,535 INFO - Creating method response for api 7bbgttuyj4 and method POST and status 200
2015-10-21 22:07:07,583 INFO - Found reference to existing model NewPetResponse
2015-10-21 22:07:07,669 INFO - Creating method response for api 7bbgttuyj4 and method POST and status 400
2015-10-21 22:07:07,713 INFO - Found reference to existing model Error
2015-10-21 22:07:07,804 INFO - Creating method response for api 7bbgttuyj4 and method POST and status 500
2015-10-21 22:07:08,058 INFO - Found reference to existing model Error
2015-10-21 22:07:08,159 INFO - Creating integration with type AWS
2015-10-21 22:07:08,243 ERROR - Error creating API, rolling back
com.amazonaws.services.apigateway.model.BadRequestException: Invalid AWS URI (Service: null; Status Code: 400; Error Code: null; Request ID: bb428501-787a-11e5-921e-bd4dfcb63565)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:803)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:505)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:317)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.putResource(HalClient.java:122)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:125)
    at com.sun.proxy.$Proxy35.putIntegration(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createIntegration(ApiGatewaySdkSwaggerApiImporter.java:257)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethod(ApiGatewaySdkSwaggerApiImporter.java:232)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$createMethods$3(ApiGatewaySdkSwaggerApiImporter.java:171)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter$$Lambda$5/1636178473.accept(Unknown Source)
    at java.util.HashMap$EntrySet.forEach(HashMap.java:1035)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethods(ApiGatewaySdkSwaggerApiImporter.java:170)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:162)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:66)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:137)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:74)
2015-10-21 22:07:08,245 INFO - Deleting API 7bbgttuyj4
2015-10-21 22:07:08,742 ERROR - Error importing API definition
com.amazonaws.services.apigateway.model.BadRequestException: Invalid AWS URI (Service: null; Status Code: 400; Error Code: null; Request ID: bb428501-787a-11e5-921e-bd4dfcb63565)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:803)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:505)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:317)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.putResource(HalClient.java:122)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:125)
    at com.sun.proxy.$Proxy35.putIntegration(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createIntegration(ApiGatewaySdkSwaggerApiImporter.java:257)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethod(ApiGatewaySdkSwaggerApiImporter.java:232)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$createMethods$3(ApiGatewaySdkSwaggerApiImporter.java:171)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter$$Lambda$5/1636178473.accept(Unknown Source)
    at java.util.HashMap$EntrySet.forEach(HashMap.java:1035)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethods(ApiGatewaySdkSwaggerApiImporter.java:170)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:162)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:66)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:137)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:74)

I've tried it a couple of times to rule out the 'sporadic' possibility.
Did an API change?
Any guidance would be appreciated!

BadRequestException: Resource with id 'zvhw2k' has a conflicting path

When trying to import, I keep getting the following error, each time.
It seems to be the same issue as #15, but the example swagger into #15 passed on my environnement.

My Swagger file seems good, I attach it in this issue

2015-09-30 11:00:39,602 INFO - Creating method parameter for api fdyjrcvfn1 and method PUT with name method.request.path.deviceId
2015-09-30 11:00:39,671 INFO - Creating method parameter for api fdyjrcvfn1 and method PUT with name method.request.path.userId
2015-09-30 11:00:39,739 INFO - Creating method for api id fdyjrcvfn1 and resource id 6voaif with method put
2015-09-30 11:00:40,394 INFO - Creating resource '{id}' with parent 'device'
2015-09-30 11:00:41,010 ERROR - Error creating API, rolling back
com.amazonaws.services.apigateway.model.BadRequestException: Resource with id 'zvhw2k' has a conflicting path (Service: null; Status Code: 400; Error Code: null; Request ID: b9a10e9e-6751-11e5-8b4c-5fa58aa77440)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy30.createResource(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:158)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:316)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:255)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:93)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
2015-09-30 11:00:41,013 INFO - Deleting API fdyjrcvfn1
2015-09-30 11:00:41,486 ERROR - Error importing API from Swagger
com.amazonaws.services.apigateway.model.BadRequestException: Resource with id 'zvhw2k' has a conflicting path (Service: null; Status Code: 400; Error Code: null; Request ID: b9a10e9e-6751-11e5-8b4c-5fa58aa77440)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy30.createResource(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:158)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:316)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:255)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:93)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Example of basic swagger

I am having issues deploying an existing swagger of mine

./aws-api-import.sh --create ./swagger.json
2015-08-07 14:45:45,108 ERROR - /path/to/swagger.json
2015-08-07 14:45:45,109 INFO - Attempting to create API from Swagger definition. Swagger file:  /path/to/swagger.json
reading from  /path/to/swagger.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
reading from /path/to/swagger.json
2015-08-07 14:45:45,127 ERROR - Error importing API from Swagger
java.lang.NullPointerException
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.getApiName(ApiGatewaySdkSwaggerApiImporter.java:236)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:84)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:102)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Would you mind include a basic example of a working swagger spec, like the petstor API, to check if it's the error is on the way I wrote the swagger spec or on my config?

Thanks

API updates fail when optional basePath field is omitted.

As per title. Setting an explicit basePath of "/" allows side-stepping the issue.

Log + stack trace:

2015-09-25 13:07:03,724 INFO - Cleaning up removed resources
2015-09-25 13:07:03,725 ERROR - Error importing API from Swagger
java.lang.NullPointerException
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.buildResourceSet(ApiGatewaySdkSwaggerApiImporter.java:653)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.cleanupResources(ApiGatewaySdkSwaggerApiImporter.java:637)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateResources(ApiGatewaySdkSwaggerApiImporter.java:552)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:110)
        at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

How to Debug schemas?

Hi guys,

My schemas is getting very long and it's becoming very hard for me to debug it.
Especially as for Swagger it is valid but not for API Gateway.

The error output coming from API Gateway is not helping at all as it doesn't reference any object, name, value, key or anything in the schemas that could help me debug it.

Am I missing something? Is there a method to debug a Schemas and pin point the issue?

For example I get this:

com.amazonaws.services.apigateway.model.BadRequestException: Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified] (Service: null; Status Code: 400; Error Code: null; Request ID: 8dc5c631-7b8a-11e5-a101-6563b98fa5c1)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1219)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:803)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:505)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:317)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy29.createModel(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkApiImporter.createModel(ApiGatewaySdkApiImporter.java:139)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModel(ApiGatewaySdkSwaggerApiImporter.java:108)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModels(ApiGatewaySdkSwaggerApiImporter.java:101)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:65)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:137)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:74)

It doesn't help much.

Thanks

When importing to AWS I am getting error 429 too many requests.

Maybe I am doing something wrong but here is what I have come up with after a little research.
From the docs:

Amazon API Gateway limits the rate at which you can submit requests:
You can submit a maximum of two POSTs to the applications resource per second per AWS account.
You can submit a maximum of four POSTs to an application's sessions resource per second per AWS account.

Stacktrace:

com.amazonaws.services.apigateway.model.LimitExceededException: Too Many Requests (Service: null; Status Code: 429; Error Code: null; Request ID: 01645d77-5721-11e5-b141-a1f953910c1b)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
at com.amazonaws.hal.client.HalClient.putResource(HalClient.java:122)
at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:125)
at com.sun.proxy.$Proxy34.putMethodResponse(Unknown Source)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$createMethodResponses$13(ApiGatewaySdkSwaggerApiImporter.java:729)
at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:663)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethodResponses(ApiGatewaySdkSwaggerApiImporter.java:722)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethodResponses(ApiGatewaySdkSwaggerApiImporter.java:809)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethod(ApiGatewaySdkSwaggerApiImporter.java:583)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateMethods(ApiGatewaySdkSwaggerApiImporter.java:346)
at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:111)
at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

General Problems

We are excited to be able to use this tool. We are hoping it will allow us to make modifications quickly and re-deploy where using the API Gateway GUI requires deleting and adding entire resources and method chains.

After testing for hours and reading all of the issues, I am unable to figure out why:

  • It raises an exception every time we try to use a JSON swagger definition. (YAML works fine)
  • After converting the sample JSON files to YAML (in ./tst/resources) and successfully importing some of those, when trying to test some methods using the API Gateway GUI, we discover only the method verbs are imported. We click on the verb to see that the endpoints, parameters, etc are missing, but ready to fill out using the GUI. In addition when we click on a resource/path the waiting icon spins forever in the right side pane.

I feel fairly certain we are missing something as nobody else has reported issues like these. Please advise.

Example of the persistent JSON import errors:

; line: 12, column: 4]
2015-09-11 10:24:02,266 ERROR - Error importing API from Swagger
java.lang.NullPointerException
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:109)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Example of missing methods in the GUI:

api_gateway

Swagger Test File (YML format):

swagger: '2.0'
info:
  title: RFS Swagger API
  description: Rallyhood File Service API
  version: 1.0.0
host: 4fca387b.ngrok.io
schemes:
  - http
  - https
basePath: /{version}
consumes:
  - application/json
produces:
  - application/json
paths:
  '/folders':
    get:
      summary: Folder Data
      description: |
        The Folder endpoint returns data for all Folder resources.
        Parameters may be passed to filter the response.
      parameters:
        - name: page
          in: query
          description: Return given page of results
          default: 1
          required: false
          type: integer
        - name: per_page
          in: query
          description: Return per_page count of Folders for each given page
          default: 20
          required: false
          type: integer
      tags:
        - Folders
      responses:
        '200':
          description: Folder Array
          schema:
            title: Folders
            type: array
            items:
              $ref: '#/definitions/Folder'
  '/{id}':
    get:
      parameters:
        - name: id
          in: path
          description: ID of the folder
          required: true
          type: integer
      responses:
        '200':
          description: Returns the selected Folder
          schema:
            type: object
            properties:
              data:
                $ref: '#/definitions/Folder'

definitions:
  Folder:
    type: object
    description: Folder Resource
    properties:
      id:
        type: number
        description: ID of the resource
      name:
        type: string
        description: 'Display name of the Folder.'
      user_id:
        type: number
        description: ID of the user to which the folder belongs.
      folderable_id:
        type: number
        description: ID of the Rally or Corp to which the folder belongs.
      folderable_type:
        type: string
        description: Type of object this folder belongs to.
      folder_id:
        type: number
        description: ID of the parent folder. May be blank or null.
      updated_at:
        type: string
        description: Date last updated
      created_at:
        type: string
        description: Date created
  Error:
    type: object
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: string

Error Importing API from Swagger on Create

I'm receiving errors using the importer... I'm not sure of the problem. Output below with sample of file (it's a large file).

Call
./aws-api-import.sh --create ../api-public-deploy/output/1440628343409.json

Output

2015-08-26 15:32:30,900 INFO - Attempting to create API from Swagger definition. Swagger file: ../api-public-deploy/output/1440628343409.json
reading from ../api-public-deploy/output/1440628343409.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
reading from ../api-public-deploy/output/1440628343409.json
2015-08-26 15:32:30,954 ERROR - Error importing API from Swagger
java.lang.NullPointerException
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.getApiName(ApiGatewaySdkSwaggerApiImporter.java:238)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:87)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

1440628343409.json

{
  "apiVersion": 1,
  "swaggerVersion": "1.2",
  "basePath": "https://{hidden}.execute-api.us-west-2.amazonaws.com",
  "resourcePath": "/alpha",
  "apis": [
    {
      "path": "/api/v1/auth",
      "description": "Create a new user authentication (Login)",
      "operations": [
        {
          "method": "POST",
          "authorizations": {},
          "summary": "Create a new user authentication (Login)",
          "nickname": "apiv1auth",
          "notes": "Create a new user authentication (Login).",
          "type": "void",
          "parameters": [
            {
              "type": "apiv1auth",
              "defaultValue": null,
              "required": true,
              "name": "body",
              "paramType": "body"
            },
            {
              "type": "string",
              "description": "Distributed Organization API Key",
              "require": true,
              "name": "x-api-key",
              "paramType": "header"
            }
          ],
          "responseMessages": [],
          "consumes": [
            "application/json"
          ],
          "x-amazon-apigateway-integration": {
            "type": "http",
            "uri": "https://{hidden}/api/v1/auth",
            "httpMethod": "POST",
            "requestParameters": {}
          }
        }
      ]
    },
    {
      "path": "/api/v1/users/{user_id}/devices",
      "description": "Get devices for user",
      "operations": [
        {
          "method": "GET",
          "authorizations": {},
          "summary": "Get devices for user",
          "nickname": "apiv1usersuser_iddevices",
          "notes": "Notes...",
          "type": "void",
          "parameters": [
            {
              "type": "string",
              "description": "Authentication Token",
              "required": true,
              "name": "authorization",
              "paramType": "header"
            },
            {
              "type": "integer",
              "description": "User Id devices belong to.",
              "defaultValue": null,
              "minimum": 0,
              "name": "user_id",
              "paramType": "path"
            },
            {
              "type": "integer",
              "description": "Network ID that devices are on.",
              "defaultValue": null,
              "minimum": 1,
              "name": "network_id",
              "paramType": "query"
            },
            {
              "type": "string",
              "description": "Distributed Organization API Key",
              "require": true,
              "name": "x-api-key",
              "paramType": "header"
            }
          ],
          "responseMessages": [],
          "x-amazon-apigateway-integration": {
            "type": "http",
            "uri": "https://{hidden}/api/v1/users/{user_id}/devices",
            "httpMethod": "GET",
            "requestParameters": {
              "integration.request.header.authorization": "method.request.header.authorization",
              "integration.request.path.user_id": "method.request.path.user_id",
              "integration.request.queryString.network_id": "method.request.queryString.network_id"
            }
          }
        }
      ]
    }
  ],
  "models": {
    "apiv1auth": {
      "id": "apiv1auth",
      "type": "object",
      "properties": {
        "username": {
          "type": "string",
          "description": "Username",
          "required": true
        },
        "password": {
          "type": "string",
          "description": "Password",
          "required": true
        }
      }
    },
    "apiv1users": {
      "id": "apiv1users",
      "type": "object",
      "properties": {
        "firstname": {
          "type": "string",
          "description": "First name",
          "required": true
        },
        "lastname": {
          "type": "string",
          "description": "Last name",
          "required": true
        },
        "company": {
          "type": "string",
          "description": "Company name",
          "required": true
        },
        "email": {
          "type": "string",
          "description": "Email Address",
          "required": true
        },
        "password": {
          "type": "string",
          "description": "Password",
          "required": true
        },
        "confirm": {
          "type": "string",
          "description": "Password Confirmation",
          "required": true
        },
        "phone": {
          "type": "string",
          "description": "Phone number",
          "required": true
        }
      }
    }
  }
}

Auth "none" for x-amazon-apigateway-auth

Hi Ryan,

How is this feature coming along? I'm really excited about this tool, but I'm not using any API Gateway Authorization, so I can't use it yet :( I've got this weekend free to work (GF is out of town), so I'm hoping you guys can pull through before then!

Either way, I still love you guys. Keep up the good work.

Cheers

Update Error: Error Importing API from Swagger

Ok, I have created an API through the import tool. Which was exciting by the way. Really nice work here guys!

Now, I'm attempting to update my API and getting the following error:

  $ ./aws-api-import.sh --update ca82kasf84 ../api_v1.json
  2015-07-21 13:38:19,997 INFO - Attempting to update API from Swagger definition. API identifier: ca82kasf84 Swagger file: ../api_v1.json
  reading from ../api_v1.json
  SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  2015-07-21 13:38:20,075 INFO - Parsed Swagger with 1 paths
  2015-07-21 13:38:20,364 ERROR - Error importing API from Swagger java.lang.NullPointerException
      at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateModels(ApiGatewaySdkSwaggerApiImporter.java:549)
      at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:106)
      at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
      at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:104)
at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:62)

NPE importing valid Swagger 2.0

hi,

After the issue #1, I had a new issue trying to import a valid swagger 2.0 json.

You can download and validate the swagger json here

http://online.swagger.io/validator/debug?url=https://tpaga.co/assets/swagger_engine/tpaga_api-8d343423a16b200b4af363d1841ebc1cc40d8ec2874196586142b3f953830771.json

The NPE is the following

 ./aws-api-import.sh -c tpaga_api-8d343423a16b200b4af363d1841ebc1cc40d8ec2874196586142b3f953830771.json 
2015-07-22 09:40:34,919 WARN - Could not load region configuration. Please ensure AWS CLI is configured via 'aws configure'. Will use default region of us-east-1
2015-07-22 09:40:35,081 INFO - Skip unsupported property name region in profile [default].
2015-07-22 09:40:35,081 INFO - Skip unsupported property name region in profile [readonly].
2015-07-22 09:40:35,081 INFO - Skip unsupported property name region in profile [tappsi].
2015-07-22 09:40:36,128 INFO - Attempting to create API from Swagger definition. Swagger file: tpaga_api-8d343423a16b200b4af363d1841ebc1cc40d8ec2874196586142b3f953830771.json
reading from tpaga_api-8d343423a16b200b4af363d1841ebc1cc40d8ec2874196586142b3f953830771.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
com.fasterxml.jackson.databind.node.NullNode cannot be cast to com.fasterxml.jackson.databind.node.TextNode (through reference chain: com.wordnik.swagger.models.ModelImpl["properties"]->java.util.LinkedHashMap["billingAddress"]) (through reference chain: com.wordnik.swagger.models.Swagger["definitions"]->java.util.LinkedHashMap["CreditCardCreate"])
reading from tpaga_api-8d343423a16b200b4af363d1841ebc1cc40d8ec2874196586142b3f953830771.json
com.fasterxml.jackson.databind.node.NullNode cannot be cast to com.fasterxml.jackson.databind.node.TextNode (through reference chain: com.wordnik.swagger.models.ModelImpl["properties"]->java.util.LinkedHashMap["billingAddress"]) (through reference chain: com.wordnik.swagger.models.Swagger["definitions"]->java.util.LinkedHashMap["CreditCardCreate"])
2015-07-22 09:40:36,205 ERROR - Error importing API from Swagger
java.lang.NullPointerException
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.getApiName(ApiGatewaySdkSwaggerApiImporter.java:236)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:84)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:98)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:62)

Error: Cross-account pass role is not allowed

I'm trying to create the tst/resources/apigateway.json example and I am getting the following error:

2015-08-30 10:21:46,353 ERROR - Error creating API, rolling back
com.amazonaws.AmazonServiceException: Cross-account pass role is not allowed. (Service: null; Status Code: 403; Error Code: null; Request ID: 71dcdc35-4f22-11e5-8606-db848852249c)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.putResource(HalClient.java:122)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:125)
    at com.sun.proxy.$Proxy34.putIntegration(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createIntegration(ApiGatewaySdkSwaggerApiImporter.java:431)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethod(ApiGatewaySdkSwaggerApiImporter.java:386)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.lambda$createMethods$1(ApiGatewaySdkSwaggerApiImporter.java:295)
    at java.util.HashMap$EntrySet.forEach(HashMap.java:1035)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createMethods(ApiGatewaySdkSwaggerApiImporter.java:294)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:261)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:93)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
2015-08-30 10:21:46,355 INFO - Deleting API pyhjculso0
2015-08-30 10:21:47,585 ERROR - Error importing API from Swagger

The profile I am specifying has administrator privileges in the AWS account. What am I missing?

Thanks

Using external references in model definition

Using external references in a way suggested in aws forum (https://forums.aws.amazon.com/thread.jspa?threadID=214765&tstart=0) like ("$ref": "https://apigateway.amazonaws.com/restapis/API_ID/models/MODEL_NAME") in Swagger file is imported to Gateway API in inlined form like that:

{"type":"object","properties":{"name":{"type":"string"},"card":{"$ref":"#/definitions/Card"}},"definitions":{"Card":{"type":"object","properties":{"last4":{"type":"string"}}}}}

Is it possible to preserve external reference in form it was declared in swagger template?

Original model definitions in swagger:

"User": {
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "card" : {
        "$ref": "https://apigateway.amazonaws.com/restapis/r8i8miwg18/models/Card"
    }
  }
},
"Card": {
  "type": "object",
  "properties": {
    "last4": {
      "type": "string"
    }
  }
}

BadRequestException: Invalid model specified (support Swagger models)

After updating the swagger dependency to be

<dependency>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-core</artifactId>
    <version>1.5.0</version>
</dependency>

To get around this issue:

com.fasterxml.jackson.databind.node.BooleanNode cannot be cast to com.fasterxml.jackson.databind.node.TextNode (through reference chain: com.wordnik.swagger.models.ModelImpl["properties"]->java.util.LinkedHashMap["hasAvailableEpisode"]) (through reference chain: com.wordnik.swagger.models.Swagger["definitions"]->java.util.LinkedHashMap["Show"])
reading from swagger.json

I'm now getting this error:

2015-07-31 17:38:26,085 INFO - Generated json-schema for model RokuEpisodes: {"type":"object","properties":{"rokuEpisodes":{"type":"array","items":{"$ref":"#/definitions/RokuEpisode"}}},"xml":{"name":"episodes"},"definitions":{"RokuEpisode":{"type":"object","properties":{"tmsId":{"type":"string"},"title":{"type":"string"},"videos":{"$ref":"#/definitions/RokuVideos"}},"xml":{"name":"episode"}},"RokuOption":{"type":"object","properties":{"price":{"type":"string"},"currency":{"type":"string"},"quality":{"type":"string","enum":["SD","HD","HD_PLUS"]},"license":{"type":"string","enum":["FREE","PURCHASE","RENTAL","SUBSCRIPTION"]}},"xml":{"name":"option"}},"RokuViewOptions":{"type":"object","properties":{"options":{"type":"array","items":{"$ref":"#/definitions/RokuOption"}}},"xml":{"name":"viewOptions"}},"RokuVideo":{"type":"object","properties":{"region":{"type":"string"},"playId":{"type":"string"},"viewOptions":{"$ref":"#/definitions/RokuViewOptions"}},"xml":{"name":"video"}},"RokuVideos":{"type":"object","properties":{"videos":{"type":"array","items":{"$ref":"#/definitions/RokuVideo"}}},"xml":{"name":"videos"}}}}
2015-07-31 17:38:26,161 ERROR - Error creating API, rolling back
com.amazonaws.services.apigateway.model.BadRequestException: Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified, Invalid model schema specified, Invalid model schema specified, Invalid model schema specified, Invalid model schema specified, Invalid model schema specified] (Service: null; Status Code: 400; Error Code: null; Request ID: 79d02c64-37cc-11e5-b6c0-b562a252dc57)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
        at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
        at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
        at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
        at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
        at com.sun.proxy.$Proxy28.createModel(Unknown Source)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModel(ApiGatewaySdkSwaggerApiImporter.java:167)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModel(ApiGatewaySdkSwaggerApiImporter.java:280)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createModels(ApiGatewaySdkSwaggerApiImporter.java:273)
        at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:89)
        at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Have any ideas about what could be going wrong?

My swagger.json was generated by using 'io.swagger:swagger-jersey-jaxrs:1.5.0'.

IntegrationType mock is not supported

Request Template Formatting

How do you specify some of the API Gateway nuances in the requestTemplates property?

I currently am trying this:

              "requestTemplates": {
                    "application/json": {
                        "access_token": "$input.params('access_token')",
                        "body": "$input.json('$')"
                    }
                }

Which results in this error:

ERROR - Error importing API from Swagger
com.amazonaws.services.apigateway.model.BadRequestException: Start of structure or map found where not expected. (Service: null; Status Code: 400; Error Code: null; Request ID: 16cc9814-2ff8-11e5-8525-3dcdef97b04b)

Further, I'm worried the $input.json('$') property won't work with quotes around it, since this has been the case when manually inputting $input.json('$') in the API Gateway Web Console

Conflicting path on Update only

Hi,

The following swagger file loads fine when creating but not when updating.

The issue is with '/assets/{asset_id}': as when I take it out the update works.

The file:

swagger: '2.0'
info:
  version: '0.2'
  title: SA Client API
  description: API for SA Fan App and user facing website.
  termsOfService: 'http://swagger.io/terms/'
  contact:
    name: xx xx Support
    email: [email protected]
host: xxx.tv
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  /assets:
    get:
      description: >
        List of assets sorted by popularity
      operationId: listAssets
      parameters:
        - name: org_id
          in: query
          description: 'ID of the organization to filter with'
          required: false
          type: string
        - name: type
          in: query
          description: 'Type of assets: video | image to filter with'
          required: false
          type: string
          enum:
            - 'video'
            - 'image'
        - name: event_id
          in: query
          description: 'ID of the event to filter with'
          required: false
          type: string
        - name: limit
          in: query
          description: 'Limit the number of assets returned. 100 Max. 10 Default. 1 Min'
          required: false
          type: integer
          maximum: 100
          minimum: 1
        - name: offset
          in: query
          description: 'Where to start searching in the result array'
          required: false
          type: string
      responses:
        '200':
          description: List of organizations videos sorted by popularity
          schema:
            $ref: '#/definitions/AssetsList'
        default:
          description: Error
          schema:
            $ref: '#/definitions/Generic'
      x-amazon-apigateway-auth:
        type: aws_iam
      x-amazon-apigateway-integration:
        type: http
        uri: 'https://api.orchestrate.io/v0/assets'
        httpMethod: GET
        requestParameters:
          integration.request.querystring.org_id: method.request.querystring.org_id
          integration.request.querystring.type: method.request.querystring.type
          integration.request.querystring.limit: method.request.querystring.limit
          integration.request.querystring.offset: method.request.querystring.offset
          integration.request.header.Authorization: "'Basic xxxxxx=='"
        cacheNamespace: cache namespace
        responses:
          '200':
            statusCode: '200'
  '/assets/{asset_id}':
    get:
      description: |
        Get one Asset
      operationId: getAsset
      parameters:
        - name: asset_id
          in: path
          description: ID of the asset to get
          required: true
          type: string
      responses:
        '200':
          description: One asset
          schema:
            $ref: '#/definitions/Asset'
        default:
          description: Error
          schema:
            $ref: '#/definitions/Generic'
      x-amazon-apigateway-auth:
        type: aws_iam
      x-amazon-apigateway-integration:
        type: http
        uri: 'https://api.orchestrate.io/v0/assets/{asset_id}'
        httpMethod: GET
        requestParameters:
          integration.request.path.asset_id: method.request.path.asset_id
          integration.request.header.Authorization: "'Basic xxxxxx=='"
        cacheNamespace: cache namespace
        responses:
          '200':
            statusCode: '200'
definitions:
  AssetsList:
    type: object
    required:
      - count
      - results
    properties:
      count:
        type: integer
      total_count:
        type: integer
      results:
        type: object
        properties:
          path:
            type: object
            $ref: '#/definitions/Path'
          value:
            $ref: '#/definitions/Asset'
          reftime:
            type: integer
        required:
          - path
          - value
          - reftime
      next:
        type: string
  Asset:
    type: object
    properties:
      filename:
        type: string
      title:
        type: string
      description:
        type: string
      thumb_url:
        type: string
      date:
        type: string
      datetime:
        type: integer
      channel_id:
        type: string
      bucket:
        type: string
      published:
        type: boolean
      insert_time:
        type: integer
      update_time:
        type: integer
      vote_up:
        type: integer
      vote_down:
        type: integer
      encodes:
        type: object
      metadata:
        type: object
      inserted_by:
        type: string
      type:
        type: string
      encode_policy:
        type: object
      key:
        type: string
  Path:
    type: object
    properties:
      kind:
        type: string
      collection:
        type: string
      key:
        type: string
      ref:
        type: string
      reftime:
        type: integer
  Generic:
    type: object
    required:
      - status
      - msg
    properties:
      status:
        type: string
      msg:
        type: string

ID of the API: arvfzjukec

Please advise
thanks

ConflictException: Resource with id 'xwdshi' has a conflicting path

When trying to import, I keep getting the following error, on different end points each time:

2015-08-11 08:44:53,074 ERROR - Error creating API, rolling back
com.amazonaws.services.apigateway.model.ConflictException: Resource with id 'xwdshi' has a conflicting path (Service: null; Status Code: 409; Error Code: null; Request ID: 7655b030-4026-11e5-a041-b1519f2f7bca)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy29.createResource(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:155)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:314)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:253)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:90)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
2015-08-11 08:44:53,075 INFO - Deleting API zmum9bq57a
2015-08-11 08:44:55,755 ERROR - Error importing API from Swagger
com.amazonaws.services.apigateway.model.ConflictException: Resource with id 'xwdshi' has a conflicting path (Service: null; Status Code: 409; Error Code: null; Request ID: 7655b030-4026-11e5-a041-b1519f2f7bca)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy29.createResource(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:155)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResource(ApiGatewaySdkSwaggerApiImporter.java:314)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createResources(ApiGatewaySdkSwaggerApiImporter.java:253)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:90)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

I can provide a Swagger file to reproduce it if necessary.

sig mismatch error when query string val contains escape chars

I have a config that looks like this:

{
...
      "RequestTemplates": {
        "application/json": "{\"query\":\"$util.urlDecode($input.params('q'))\"}"
      },
      "RequestParameters": {
        "integration.request.querystring.integrationQueryParam": "method.request.querystring.q"
      },
...
}

And it works fine when I pass a query string value (to q) without escape chars. However when my query string param has escape chars, like space (hi%20there) I get a sig mismatch error from the API Gateway.

Here is full example via the tester:
screen shot 2015-10-19 at 2 52 21 pm 1

When I then delete the query string and change the integration request to mock and back via the web UI, then re-create the query string and integration request via the web UI the query string param with escape chars works just fine.

I think it has something to do with the string integrationQueryParam making it into the Query Strings section of the Integration request:
image

I can't figure out how that gets there - and when I remove the query string q from the method request in the UI, the integrationQueryParam is still in the Query Strings section of the Integration request. The only way I can get rid of it is to convert the Integration request into a mock then move it back to my lambda.

any ideas?

No integration defined for method

Hi,

After some massaging of our existing Swagger docs I have successfully got an API in Amazon API Gateway.

However whenever I try to deploy this resource I'm receiving the following error:

com.amazonaws.services.apigateway.model.BadRequestException: No integration defined for method (Service: null; Status Code: 400; Error Code: null; Request ID: e64dddba-51d3-11e5-b141-a1f953910c1b)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.postResource(HalClient.java:98)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:117)
    at com.sun.proxy.$Proxy27.createDeployment(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.deploy(ApiGatewaySdkSwaggerApiImporter.java:121)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.deploy(ApiGatewaySwaggerFileImporter.java:63)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:111)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Any advice if this is caused by my Swagger docs missing data? (1.2 -> 2.0 upgrade)

swagger 2.0 compatibility?

2015-08-31 17:12:32,751 INFO - Attempting to create API from Swagger definition. Swagger file: ../api-doc/swagger.json
reading from ../api-doc/swagger.json
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: N/A; line: -1, column: -1] (through reference chain: com.wordnik.swagger.models.parameters.PathParameter["default"]) (through reference chain: com.wordnik.swagger.models.Swagger["parameters"]->java.util.LinkedHashMap["asset_types"])
reading from ../api-doc/swagger.json
Can not deserialize instance of java.lang.String out of START_ARRAY token
 at [Source: N/A; line: -1, column: -1] (through reference chain: com.wordnik.swagger.models.parameters.PathParameter["default"]) (through reference chain: com.wordnik.swagger.models.Swagger["parameters"]->java.util.LinkedHashMap["asset_types"])
2015-08-31 17:12:32,912 ERROR - Error importing API from Swagger
java.lang.NullPointerException
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.getApiName(ApiGatewaySdkSwaggerApiImporter.java:238)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.createApi(ApiGatewaySdkSwaggerApiImporter.java:87)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.importApi(ApiGatewaySwaggerFileImporter.java:48)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:101)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

Definitions need to support "Example"

Add support for the "example" property to definitions in Swagger files. This will allow us to keep the example text in our Swagger generated documentation.

Currently if you have the example property:

"definitions": {
        "Project": {
            "required": [
                "name"
            ],
            "properties": {
                "id": {
                    "type": "integer",
                    "format": "int64"
                },
                "name": {
                    "type": "string",
                    "example": "my project name"
                }
            }
        }
    }

Results in the following exception being thrown:

2015-08-14 14:44:47,486 INFO - Parsed Swagger with 2 paths
2015-08-14 14:44:48,232 INFO - Updating model for api id ********* and model name Project
2015-08-14 14:44:48,534 INFO - Generated json-schema for model Project: {"required":["name"],"properties":{"name":{"type":"string","example":"myproject"}},"definitions":{}}
2015-08-14 14:44:49,011 ERROR - Error importing API from Swagger
com.amazonaws.services.apigateway.model.BadRequestException: Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified] (Service: null; Status Code: 400; Error Code: null; Request ID: 6e3405f6-422e-11e5-8811-7975d3f2c549)
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.patchResource(HalClient.java:162)
    at com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:137)
    at com.sun.proxy.$Proxy32.updateModel(Unknown Source)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateModel(ApiGatewaySdkSwaggerApiImporter.java:223)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateModel(ApiGatewaySdkSwaggerApiImporter.java:571)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateModels(ApiGatewaySdkSwaggerApiImporter.java:560)
    at com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:109)
    at com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:107)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)

how can i set a request model?

hi, i have to set a request model for the application/json request but i can't figure out where i can set it in the apigateway-integration...

"x-amazon-apigateway-integration": {
"type": "aws",
"uri": "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:477398036046:function:debug/invocations",
"httpMethod": "POST",
"credentials": "arn:aws:iam::477398036046:role/lambda_exec_role",
"requestTemplates": {
"application/json": ""
},
"requestParameters": {
"integration.request.path.alias": "method.request.path.alias"
},
"responses": {
"2//d{2}": {
"statusCode": "200"
},
"default": {
"statusCode": "400"
}
}
}

Errors thrown when running behind proxy

I run ApiImporterMainTest from behind a proxy and get the below stack trace.

As a hack I added an instance of com.amazonaws.ClientConfiguration in ApiImporterModule.java here and it works.

@Provides
    ApiGateway provideAmazonApiGateway(AWSCredentialsProvider credsProvider,
                                       @Named("region") String region) {
        ClientConfiguration clientConfig = new ClientConfiguration();
        clientConfig.setProxyHost("<PROXY_HOST_NAME>");
        clientConfig.setProxyPort(<PROXY_HOST_PORT>);
        return new AmazonApiGateway(getEndpoint(region)).with(credsProvider).with(clientConfig).getApiGateway();
    }

Stack Trace

2015-08-11 13:32:47,169 INFO - Unable to execute HTTP request: apigateway.us-east-1.amazonaws.com: unknown error
java.net.UnknownHostException: apigateway.us-east-1.amazonaws.com: unknown error
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1255)
    at java.net.InetAddress.getAllByName(InetAddress.java:1171)
    at java.net.InetAddress.getAllByName(InetAddress.java:1105)
    at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:44)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:259)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:159)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:728)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489)
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310)
    at com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)
    at com.amazonaws.hal.client.HalClient.getHalResource(HalClient.java:210)
    at com.amazonaws.hal.client.HalClient.getResource(HalClient.java:200)
    at com.amazonaws.hal.client.HalClient.getResource(HalClient.java:92)
    at com.amazonaws.hal.HalService.getRootResource(HalService.java:128)
    at com.amazonaws.services.apigateway.AmazonApiGateway.getApiGateway(AmazonApiGateway.java:114)
    at com.amazonaws.service.apigateway.importer.config.ApiImporterModule.provideAmazonApiGateway(ApiImporterModule.java:68)
    at com.amazonaws.service.apigateway.importer.config.ApiImporterModule$$FastClassByGuice$$2d612f5f.invoke(<generated>)
    at com.google.inject.internal.ProviderMethod$FastClassProviderMethod.doProvision(ProviderMethod.java:272)
    at com.google.inject.internal.ProviderMethod.get(ProviderMethod.java:172)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:54)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:132)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:96)
    at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:65)
    at com.amazonaws.service.apigateway.importer.ApiImporterMainTest.test(ApiImporterMainTest.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:24)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
2015-08-11 13:32:47,489 INFO - Unable to execute HTTP request: apigateway.us-east-1.amazonaws.com

Support AWS CLI profiles

The tool currently uses the "default" CLI profile. If multiple profiles are defined, it is possible that the wrong region may be used.

Support use of "--profile" parameter to select the profile to use.

HTTP status regex 2//d{2} not matches 200 status in sample files

Hi,
In sample json files ( tst/resources/*.json ), HTTP status regex in x-amazon-apigateway-integration section (e.g. this ) are written like 2//d{2}.
Is this correct?

I experimented under following conditons, 2//d{2} is not match 200 status and 2\\{d} is match it.

  • YAML swagger file
  • Integration type is HTTP Proxy

It seems to me that 2//d{2} is not correct and 2\\{d} is correct.

FYI, in AWS GUI console, tooltip shows:

For example, 5\d{2} matches all 5XX errors

Thanks.

Documentation?

I'm just getting started with this, and it's looking like a great tool! I am wondering about documentation for the x-amazon-apigateway-auth and x-amazon-apigateway-integration objects that get injected into Swagger to hook up things like Lambda functions. Is there anywhere these are documented for reference? When I tried to put them into my JSON file and import into the API gateway I got lots of errors and am not sure how to proceed.

For now I'm just going to hook things up manually. This tool looks like a great start. Thanks!

Fatal error compiling: tools.jar not found

Why is this looking for tools.jar in C:\Program Files\Java\lib? That folder doesn't even exist on my system.

C:\cygwin64\home\Dave.Kennedy\code\aws-apigateway-swagger-importer>mvn assembly:
assembly
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aws-apigateway-swagger-importer 1.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-assembly-plugin:2.2-beta-5:assembly (default-cli) > package @ a
ws-apigateway-swagger-importer >>>
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocate
d to commons-io:commons-io:jar:1.3.2
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ aws-apigat
eway-swagger-importer ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ aws-apigatewa
y-swagger-importer ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 9 source files to C:\cygwin64\home\Dave.Kennedy\code\aws-apigat
eway-swagger-importer\build\private\classes\library
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.366 s
[INFO] Finished at: 2015-10-01T13:04:27-06:00
[INFO] Final Memory: 11M/241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
5.1:compile (default-compile) on project aws-apigateway-swagger-importer: Fatal
error compiling: tools.jar not found: C:\Progra~1\Java\jre1.8.0_60\..\lib\tools.
jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

APIs created via APIG's REST API are slower than apis created in AWS Web Console (not an issue with this importer)

Hi Ryan,

I'm a big fan of your work here and I've created a javascript version for the JAWS Framework that is very similar to this.

I do not know if this issue affects your importer, but it affects mine. Since the API Gateway REST API is your area of expertise, I'm hoping you can point out anything obvious that I am missing.

In short, when people are creating APIG REST APIs with the JAWS command line tool, the response times are ~500ms slower than if the REST API is created in the AWS APIG UI. This seems odd to me, since they both use the APIG REST API. Perhaps there is are missing configuration settings that are resulting in poorer performance.

Further details on this issue can be found here. If there is anything that comes to mind, please let me know. If you're busy, I understand. Please know your work is awesome and it helped me tremendously.

Kindest regards,
Austen
JAWS

P.S. Are you going to be @ Re:invent, and could I buy you a beer?

Internal Error - When Accessing API URL Created Via Importer

I've created an API from the JSON below using the Importer. I deployed the API via the web console.

I'm running into two problems with it:

  • When I go to the api url for the one resource defined below, I get:
message: "Internal server error"

The configuration below is not hitting my lambda function. I can see so in the Lambda monitoring area.

  • Also, when I run --update in the importer with the JSON below I get the following error:
Error importing API from Swagger
com.amazonaws.services.apigateway.model.BadRequestException: AWS_IAM Auth type is required for AWS integrations with identity forwarding specified

Here is the Swagger JSON:

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "api_private_v1",
        "description": "Private API v1"
    },
    "host": "",
    "schemes": [
        "https"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {

        "/user": {

            "get": {
                "summary": "User Profile",
                "description": "",
                "parameters": [{
                    "name": "access_token",
                    "in": "query",
                    "description": "access token",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Successful Response"
                    }
                },
                "x-amazon-apigateway-auth": {
                    "type": "none"
                },
                "x-amazon-apigateway-integration": {
                    "type": "aws",
                    "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789:function:users_show",
                    "httpMethod": "GET",
                    "credentials": "arn:aws:iam::123456789:role/privateapi_lambda",
                    "requestTemplates": {
                        "application/json": "test"
                    },
                    "requestParameters": {
                        "integration.request.querystring.integrationQueryParam": "method.request.querystring.access_token"
                    },
                    "cacheNamespace": "cache-namespace",
                    "cacheKeyParameters": [],
                    "responses": {
                        "2//d{2}": {
                            "statusCode": "200"
                        },
                        "default": {
                            "statusCode": "400"
                        }
                    }
                }
            }
        }
    },
    "definitions": {}
}

requestParameters under "x-amazon-apigateway-integration"

I'm confused about how this 'requestParameters' section relates to the 'parameters' section under 'get'.

Specifically, looking at https://github.com/awslabs/aws-apigateway-swagger-importer/blob/master/tst/resources/apigateway.json you have:

"requestParameters" : {
"integration.request.path.integrationPathParam" : "method.request.querystring.latitude",
"integration.request.querystring.integrationQueryParam" : "method.request.querystring.longitude"
}

which seems to imply that you could only have one path param and one query param.

In the 'parameters' section just above this in apigateway.json, both latitude and longitude are actually specified as "in": "query".

Is there any documentation for these x-amazon extensions other than the examples under tst/?

Determining API ID

As a n00b to this importer it would be nice if the README documented how one can actually determine the API ID that is supposed to be used in the --update command.

Error On Create: Binding to null instances is not allowed

I'm new to the Java world, so forgive me if this is a simple issue. But, I'm running into the following error when I try to create an API from my swagger.json:

    $ ./aws-api-import.sh --create ./swagger.json
    2015-07-21 11:59:09,719 ERROR - Error importing API from Swagger
    com.google.inject.CreationException: Unable to create injector, see the following errors:

    1) Binding to null instances is not allowed. Use toProvider(Providers.of(null)) if this is your intended behaviour.
      at com.amazonaws.service.apigateway.importer.config.ApiImporterModule.configure(ApiImporterModule.java:44)

    1 error
        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
        at com.google.inject.Guice.createInjector(Guice.java:96)
        at com.google.inject.Guice.createInjector(Guice.java:73)
        at com.google.inject.Guice.createInjector(Guice.java:62)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:91)
        at com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:62)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.