2016-10-04 32 views
1

我試圖從Swagger(http://petstore.swagger.io/v2/swagger.json)導入PetStore模式,但導致以下錯誤。 你能幫我理解這裏的問題嗎?AWS API網關:導入Swagger API模式的問題

錯誤:

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. 

回答

1

感謝您報告這一點。儘管API網關努力支持完整的swagger 2.0規範,但仍存在API網關強制執行的限制,可能會導致一些有效的swagger文件失敗。

這已經在這裏詳細討論在AWS論壇:https://forums.aws.amazon.com/message.jspa?messageID=720511

希望這澄清。

+0

有些工具可以將模式轉換爲與AWS兼容,例如swaggerhub會在部署到網關之前禁用不支持的功能。 – fehguy

+0

@fehguy我正在嘗試swaggerhub,我已經導入了我的swagger文件,但我無法確定如何導出禁用AWS不支持的功能。 – loretoparisi

0

我得到了很多類似這樣的錯誤,將swagger定義導入到aws api網關中。他們都走了,當我加入傑克遜JSON定義我的模型我的API e.g返回:

@JsonProperty("id") 
private String id; 

@JsonProperty("target") 
private Long target; 

加入JsonProperty全部解決了我所有的進口問題在我的模型中的字段。