Bipin
Bipin

Reputation: 11

WSO2 API Manager 1.8.0 fails to import Swagger definition

I'm trying to import Swagger definition in WSO2 AM 1.8.0 while creating new API. But, the import fails with the exceptions in logs as below,

ERROR {JAGGERY.site.blocks.item-design.ajax.import:jag} -  org.mozilla.javascript.WrappedException: Wrapped com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected EOF at line 1 column 27 (/publisher/site/blocks/item-design/ajax/import.jag#25)

Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected EOF at line 1 column 27

Caused by: com.google.gson.stream.MalformedJsonException: Expected EOF at line 1 column 27

I'm using below configurations:

I create two simple restful services and add Swagger annotations to them. I can see doc in Swagger UI and can invoke them as well. I verify generated JSON for listing and resources and find it valid. But, when I try to import that definition in WSO2AM, it fails to do so.

What Swagger specification does WSO2 AM 1.8.0 support?

Any help is highly appreciated. Thanks.

Upvotes: 1

Views: 748

Answers (1)

Bipin
Bipin

Reputation: 11

I'm able to overcome this problem. The file wso2am-1.8.0\repository\deployment\server\jaggeryapps\publisher\site\blocks\ite‌​m-design\ajax\import.jag has code which sends http requests and fetches json data in loop.

var xhr = new XMLHttpRequest(); for(var i = 0; i < swaggerJson.apis.length; i++){ xhr.open("GET", url + swaggerJson.apis[i].path);

For some reason, it's unable to reuse XMLHttpRequest instance to send subsequent requests. I moved XMLHttpRequest instance creation statement in a for loop and it worked.

//var xhr = new XMLHttpRequest(); for(var i = 0; i < swaggerJson.apis.length; i++){ var xhr = new XMLHttpRequest(); // moved instance creation here xhr.open("GET", url + swaggerJson.apis[i].path);

Upvotes: 0

Related Questions