1

Trying to use an API Connect generated app as the backend for my mobile project adding an OPENAPI_SPEC env variable as defined here:

https://console.ng.bluemix.net/docs/mobile/sdk_compute.html#definition

I can add the app as a compute instance in the Mobile Project UI but it can't generate the SDK, I guess it is because when published via APIC Editor to Bluemix the Loopback app isn't accessed directly but through the APIC gateway.

Any suggestion here?

rene
  • 41,474
  • 78
  • 114
  • 152

1 Answers1

0

I would presume that although you have an OPENAPI_SPEC environment variable, your Open API swagger doc isn't valid.

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

For instance, here is how you set the environment variable with an example relative path:

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


A good way to test the validity of your OPEN API swagger doc is using the new Bluemix SDK Gen CLI Plugin.

$ bx sdk validate

NAME:
   validate - Determines if an OpenAPI specification is valid for SDK generation


USAGE:
   bluemix sdk validate OPENAPI_DOC_LOCATION | APP_NAME

   OPENAPI_DOC_LOCATION - is a raw OpenAPI specification (URL to spec or local file; json or yaml)
   APP_NAME    - is the name of an app running in your current space hosting
                 OpenAPI spec.

In addition, IBM provides a deployable BFF starter sample with an accompanying blog post which may be helpful.

joe
  • 2,468
  • 2
  • 12
  • 19
  • If I create a backend app using loopback only I can add the /explorer/swagger.json to the env variable and everything works as described in the references above. The problem is when I use apic to create and publish the CF app to Bluemix, this CF app can't be accessed directly because it's designed to be accessed via apic gateway, so there's no valid reference path to a swagger file to add to the app's env variable in Bluemix. I think that in this case I have to add the SDK via command line using the swagger file generated in my workstation by APIC instead of referencing the Bluemix App. – Paulo Lacerda Mar 10 '17 at 18:24
  • Do you have a full link to the swagger doc that you can access? If there is, you could try using that as the environment variable rather than a relative path. – joe Mar 13 '17 at 05:00