Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway: Issues with importing Swagger API schema

I tried to import PetStore schema from Swagger (http://petstore.swagger.io/v2/swagger.json) but resulted in following errors. Can you pls help me understand the issue here?

Errors:

Your API was not imported due to errors in the Swagger file.
Unable to create model for 'Order': Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
Unable to create model for 'User': Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
Unable to create model for 'Category': Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
Unable to create model for 'Tag': Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
Unable to put method 'POST' on resource at path '/pet': Invalid model name specified: null
Unable to put method 'PUT' on resource at path '/pet': Invalid model name specified: null
Unable to put method 'POST' on resource at path '/store/order': Invalid model name specified: null
Unable to put method 'POST' on resource at path '/user': Invalid model name specified: null
Unable to put method 'PUT' on resource at path '/user/{username}': Invalid model name specified: null
Additionally, these warnings were found:
Unsupported security definition type 'oauth2' for 'petstore_auth'. Ignoring.
API Key security definition 'api_key' has unexpected name or location. Ignoring.
Unable to insert model 'Pet' due to an unsatisfied schema reference.
Reference to model 'Pet' not found. Ignoring.
Reference to model 'Pet' not found. Ignoring.
Reference to model 'Pet' not found. Ignoring.
Reference to model 'Pet' in 200 response to method 'GET /pet/findByStatus' not found. Ignoring.
Reference to model 'Pet' not found. Ignoring.
Reference to model 'Pet' in 200 response to method 'GET /pet/findByTags' not found. Ignoring.
Reference to model 'Pet' not found. Ignoring.
Invalid format for model application/json for method GET
Parameter type formData for parameter name not supported. Ignoring.
Parameter type formData for parameter status not supported. Ignoring.
Parameter type formData for parameter additionalMetadata not supported. Ignoring.
Parameter type formData for parameter file not supported. Ignoring.
Unsupported model type 'MapProperty' in 200 response to method 'GET /store/inventory'. Ignoring.
Reference to model 'Order' not found. Ignoring.
Reference to model 'Order' not found. Ignoring.
Invalid format for model application/json for method GET
Reference to model 'User' not found. Ignoring.
Reference to model 'User' not found. Ignoring.
Request schema for 'POST /user/createWithArray' has a reference to unknown model 'User'. Ignoring.
API Gateway does not support Swagger's 'default' method response (found on 'POST /user/createWithArray')
Reference to model 'User' not found. Ignoring.
Request schema for 'POST /user/createWithList' has a reference to unknown model 'User'. Ignoring.
API Gateway does not support Swagger's 'default' method response (found on 'POST /user/createWithList')
Unsupported model type 'StringProperty' in 200 response to method 'GET /user/login'. Ignoring.
API Gateway does not support Swagger's 'default' method response (found on 'GET /user/logout')
Reference to model 'User' not found. Ignoring.
Invalid format for model application/json for method GET
Reference to model 'User' not found. Ignoring.
like image 861
Satish Gadhave Avatar asked Oct 04 '16 15:10

Satish Gadhave


2 Answers

Thanks for reporting this. While API Gateway strives to support the full swagger 2.0 spec, there are still restrictions that API Gateway enforces that may cause some valid swagger files to fail.

This has been discussed in detail here in AWS forum: https://forums.aws.amazon.com/message.jspa?messageID=720511

Hope this clarifies.

like image 110
Balaji Avatar answered Oct 19 '22 04:10

Balaji


I was getting a lot of errors like this importing swagger definitions into aws api gateway. All of them went away when I added jackson json definitions to my models being returned by my api e.g:

@JsonProperty("id")
private String id;

@JsonProperty("target")
private Long target;

the addition of JsonProperty to all of the fields in my models resolved all of my import problems.

like image 30
bsautner Avatar answered Oct 19 '22 04:10

bsautner