{"action":"created","issue":{"url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/144","repository_url":"https://api.github.com/repos/awslabs/aws-apigateway-importer","labels_url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/144/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/144/comments","events_url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/144/events","html_url":"https://github.com/awslabs/aws-apigateway-importer/issues/144","id":126449406,"number":144,"title":"Can't deploy stage because of \"ConflictException: Cannot delete model\"","user":{"login":"linuxby","id":5016269,"avatar_url":"https://avatars.githubusercontent.com/u/5016269?v=3","gravatar_id":"","url":"https://api.github.com/users/linuxby","html_url":"https://github.com/linuxby","followers_url":"https://api.github.com/users/linuxby/followers","following_url":"https://api.github.com/users/linuxby/following{/other_user}","gists_url":"https://api.github.com/users/linuxby/gists{/gist_id}","starred_url":"https://api.github.com/users/linuxby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linuxby/subscriptions","organizations_url":"https://api.github.com/users/linuxby/orgs","repos_url":"https://api.github.com/users/linuxby/repos","events_url":"https://api.github.com/users/linuxby/events{/privacy}","received_events_url":"https://api.github.com/users/linuxby/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-13T15:53:09Z","updated_at":"2016-03-17T10:59:43Z","closed_at":null,"body":"```\r\n./aws-api-import.sh --update ID --deploy s swagger.yaml\r\n```\r\ni got \r\n```\r\nERROR - Error importing API definition\r\ncom.amazonaws.services.apigateway.model.ConflictException: Cannot delete model 'newisPinnedvalue', is referenced in method request: /session/{sessionId}/pin/POST (Service: null; Status Code: 409; Error Code: null; Request ID: fcb5cc7f-ba0a-11e5-b87c-41b4d3c5dca3)\r\n\tat com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1275)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:873)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:576)\r\n\tat com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:362)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:328)\r\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:307)\r\n\tat com.amazonaws.hal.client.HalClient.invoke(HalClient.java:235)\r\n\tat com.amazonaws.hal.client.HalClient.deleteResource(HalClient.java:142)\r\n\tat com.amazonaws.hal.client.HalResourceInvocationHandler.invoke(HalResourceInvocationHandler.java:129)\r\n\tat com.sun.proxy.$Proxy33.deleteModel(Unknown Source)\r\n\tat com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkApiImporter.lambda$cleanupModels$2(ApiGatewaySdkApiImporter.java:161)\r\n\tat java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)\r\n\tat java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)\r\n\tat java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)\r\n\tat java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)\r\n\tat java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)\r\n\tat java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)\r\n\tat java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)\r\n\tat java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\r\n\tat java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)\r\n\tat com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkApiImporter.cleanupModels(ApiGatewaySdkApiImporter.java:159)\r\n\tat com.amazonaws.service.apigateway.importer.impl.sdk.ApiGatewaySdkSwaggerApiImporter.updateApi(ApiGatewaySdkSwaggerApiImporter.java:92)\r\n\tat com.amazonaws.service.apigateway.importer.impl.ApiGatewaySwaggerFileImporter.updateApi(ApiGatewaySwaggerFileImporter.java:58)\r\n\tat com.amazonaws.service.apigateway.importer.ApiImporterMain.importSwagger(ApiImporterMain.java:161)\r\n\tat com.amazonaws.service.apigateway.importer.ApiImporterMain.execute(ApiImporterMain.java:145)\r\n\tat com.amazonaws.service.apigateway.importer.ApiImporterMain.main(ApiImporterMain.java:83)\r\n```\r\ncreate api method works fine with the same swagger file."},"comment":{"url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/comments/197819745","html_url":"https://github.com/awslabs/aws-apigateway-importer/issues/144#issuecomment-197819745","issue_url":"https://api.github.com/repos/awslabs/aws-apigateway-importer/issues/144","id":197819745,"user":{"login":"rdewaele","id":1044505,"avatar_url":"https://avatars.githubusercontent.com/u/1044505?v=3","gravatar_id":"","url":"https://api.github.com/users/rdewaele","html_url":"https://github.com/rdewaele","followers_url":"https://api.github.com/users/rdewaele/followers","following_url":"https://api.github.com/users/rdewaele/following{/other_user}","gists_url":"https://api.github.com/users/rdewaele/gists{/gist_id}","starred_url":"https://api.github.com/users/rdewaele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rdewaele/subscriptions","organizations_url":"https://api.github.com/users/rdewaele/orgs","repos_url":"https://api.github.com/users/rdewaele/repos","events_url":"https://api.github.com/users/rdewaele/events{/privacy}","received_events_url":"https://api.github.com/users/rdewaele/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T10:59:43Z","updated_at":"2016-03-17T10:59:43Z","body":"I had the same issue, found this error report and proceeded to do some testing.\r\n\r\nContext: I have an input swagger file which I automatically augment with AWS integrations. As a part of this process, I validate the input swagger (https://github.com/BigstickCarpet/swagger-parser/blob/master/docs/swagger-parser.md#validateapi-options-callback) which *fully dereferences* the swagger object.\r\n\r\nScenario: After a few weeks in development and regularly deploying new versions to our development stages, I began experiencing this error.\r\n\r\nTesting:\r\n - First I tried deploying the API as a new API, which worked. However, when trying to redeploy to the same stage, I received this error.\r\n - Then I decided to stop dereferencing the swagger object, and just write out the parsed version (https://github.com/BigstickCarpet/swagger-parser/blob/master/docs/swagger-parser.md#parseapi-options-callback) instead, as input to this tool. This  did not resolve the issue.\r\n - Next I tried deleting the 'new' API and executing the scenario again. This time I did *not* observe the issue.\r\n - I reverted the API name to its original value to test whether the problem was solved in the actual development stage - it was *not*.\r\n\r\nThese results lead me to believe that having a stage where a dereferenced swagger has been deployed confuses the importer tool. The current workaround I have is to *not* dereference anything in the generated files that form the input for the importer tool.\r\n\r\nHope this helps."}}