Bulk importing swagger files using wso2 API Manager

251 Views Asked by At

I'd like to know if it's possible to automate the process of importing swagger files in wso2 api manager. If so how can it be done?

thanks

2

There are 2 best solutions below

0
On

You write a script to create an API using Publisher's API.

You can add resources, including scopes, as a Swagger payload.

https://docs.wso2.com/display/AM210/Publisher+APIs#PublisherAPIs-AddAPI

curl -X POST -b cookies http://localhost:9763/publisher/site/blocks/item-add/ajax/add.jag -d "action=addAPI&name=PhoneVerification&context=/phoneverify&version=1.0.0&visibility=public&thumbUrl=&description=Verify a phone number&tags=phone,mobile,multimedia&endpointType=nonsecured&tiersCollection=Gold,Bronze&http_checked=http&https_checked=https&resourceCount=0&resourceMethod-0=GET&resourceMethodAuthType-0=Application&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/*&default_version_checked=default_version&bizOwner=xx&[email protected]&techOwner=xx&[email protected]" -d 'endpoint_config={"production_endpoints":{"url":" http://ws.cdyne.com/phoneverify/phoneverify.asmx","config":null},"endpoint_type":"http "}'
0
On

You can write a java/python client or create a script which will include the couple of hits to the APIs mentioned in the publisher api document.

  1. Generate the token using scopes: apim:api_create apim:api_view apim:api_publish
  2. Call the Update swagger definition
  3. Change API-Status to Publish using the Change API Status