Skip to content
This repository has been archived by the owner on Aug 8, 2018. It is now read-only.

Error updating API with basePath with more than 1 element #24

Closed
AaronRustad opened this issue Aug 27, 2015 · 4 comments
Closed

Error updating API with basePath with more than 1 element #24

AaronRustad opened this issue Aug 27, 2015 · 4 comments

Comments

@AaronRustad
Copy link

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":"support@company.com"
    }
  },
  "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

@rpgreen
Copy link
Contributor

rpgreen commented Aug 27, 2015

Hi Aaron,

Let me take a look. In the meantime you could run in a debugger to troubleshoot. Curious - do you still see the issue if you change the basepath to "/v1" (single path element)?

@rpgreen
Copy link
Contributor

rpgreen commented Aug 27, 2015

Confirmed as a bug. For now you can delete this API and update your Swagger so that basePath is "/api" and your paths are "/v1/categories", "/v1/players", etc and import with "--create". I have confirmed that this will update successfully once it has been created.

I will update this ticket once the original bug is fixed.

@rpgreen rpgreen changed the title Invalid Resource identifier specified Error updating API with basePath with more than 1 element Aug 27, 2015
@rpgreen
Copy link
Contributor

rpgreen commented Aug 27, 2015

Fixed in 28f64a3

Please confirm

@rpgreen rpgreen closed this as completed Aug 27, 2015
@AaronRustad
Copy link
Author

Hi @rpgreen thanks for digging into this. Sorry for the slow response, but your original suggestion to change '/api/vi' to '/v1' worked for me. I'll take a look at your commit tomorrow and confirm.

Thanks!
Aaron.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants