Search code examples
swiftibm-cloudibm-mobile-servicesopenwhiskkitura

IBM Bluemix - Kitura Swift - is missing a required environment variable: 'OPENAPI_SPEC'


I am stuck for the moment. I cannot obtain the source code for the mobile project and I do not know where is the problem. All my researches was without positive result.

My intention with IBM Bluemix is to develop myself a small project only in Swift (server side + iOS) because I am iOS mobile developer.

When I try to get the code for mobile project (iOS) I get these error:

Error Notification:
The Cloud Foundry App 'XXX' is missing a required environment variable: 'OPENAPI_SPEC'.

I want to use OpenWhisk SDK for iOS. I do not know where to set the variable OPENAPI_SPEC and what value to put in it.

I have setup a Cloud Foundry App started from "Runtime for Swift - Kitura" and a mobile project named started from "Code Starter - OpenWhisk".

Can you help me with some advice or some sample? Thank you!


Solution

  • If you added a Swift server side Compute to your mobile project, you will need to add an environment variable called OPENAPI_SPEC to your backend to point to a valid Open API swagger document outlining the API.

    This way when you download the project, it will auto-generate an SDK corresponding with your backend's Open API.

    For instance, here is how you set the environment variable:

    env variable

    And here is a valid API doc that it's using (albeit not in the most elegant Open API compliant format yet but it works).

    https://updatesdk.mybluemix.net/explorer/swagger.json

    The idea is that the "project" concept takes an abstracted view of a Compute runtime (Cloud Foundry, Docker, etc.) and only cares that it exposes an API compliant with the Open API specification. Using that defined Open API spec, you can dynamically generate an SDK for a "project" when it's downloaded (for iOS, Android, etc.).


    If your backend Compute exposes no Open API specification at this time, and you just want to download the code of OpenWhisk for iOS, you can just deassociate that backend Compute from your mobile project for now, and it should download the code. If you ever build on top of that backend and want to reconnect it in the future, you can add it and redownload at a later time (doing a git diff or using the Bluemix CLI SDK plugin to download an SDK from your Open API specification later in your project's lifecycle).