0

I am working on publishing an existing swagger through API Connect. For that, i need to import an existing yaml file (Draft), available in my local folder, and add it to an existing product. However, i find the commands to create an api from scratch. Is there a way i can import a yaml file, having the Assemble Tab" details (x-ibm-configuration:....) and add it to the product and stage the product to the catalog.

apic create --type api -h

Above command only allows to create an api. But i need to import an existing yaml file.

Please suggest.

Aman
  • 159
  • 2
  • 15

1 Answers1

2

To push a definition to drafts, use this command ( you can skip the -r if you don't want to replace an existing draft):

"apic drafts:push "+ apiName +".yaml -r "+ apiName + ':' + apiVersion2Replace +" --organization '${deploymentOrganization}' --server '${deploymentServer}'"
Álvaro Pérez Soria
  • 1,443
  • 1
  • 13
  • 26
  • The above command adds the local api to draft but is there a way i can add this api (which is in draft), to an existing product. This command "apic publish TestProduct.yaml --stage --catalog '${catalogName}' --organization '${deploymentOrganization}' --server '${deploymentServer}'" can stage the product, but for that i need a product.yaml file in my local folder with the $ref for the newly drafted swagger. – Aman Dec 12 '18 at 17:54
  • I have the same requirement in my CI/CD Jenkins pipeline for API Connect. What I do is, get all the products that this API belongs to, iterate through all the products in all catalogs, and republish the API in every Product that this API belongs to – Álvaro Pérez Soria Dec 12 '18 at 19:21
  • So, as of now, my testapi.yaml file is saved in drafts. And it has no reference of it, in any of the products (Example: testapi: id: 5c1145170cf23847e55e34a8). If i re-publish the existing old versioned produt, how will it pick up the new testapi which i just now added in draft. – Aman Dec 13 '18 at 03:51
  • In my case, the API replaces (if there is one with the same major version) the existing one. When you replace it with the new one, and you republish the products, the new version will be published. – Álvaro Pérez Soria Dec 13 '18 at 18:15
  • So after going through the help docs, i find that there is no real need to add any new swagger (yaml file) in draft. We can directly publish the swagger by executing the publish command. I have written the code to add the swagger files details in the APIs tag of product.yaml file. – Aman Dec 19 '18 at 15:37