jpoveda
jpoveda

Reputation: 2177

StrongLoop API Explorer Not Working With `apic strongloop` Scaffolding / Generator

I am learning LoopBack (aka Strongloop). When I go to https://strongloop.com/ it tells me to install npm install -g apiconnect. So, I'm learning LoopBack with the scaffolding from apic loopback

Once I get a starter project going with apic loopback, and add a model with apic create --type model, it looks like my definitions where my Swagger is defined is automatically updated (./definitions/server.yaml). As a result, I am able to explore those APIs when I run apic edit.

However, when I edit a model to extend my API, as demonstrated in the LoopBack documentation (https://docs.strongloop.com/display/public/LB/Extend+your+API), I don't see the updated API documentation... but from the documentation that looks like the "Explorer" should pick up the new API endpoint.

What am I missing here? Is there a swagger command that I'm supposed to run when I create manual API extensions? Or perhaps it's some kind of magic comments in the code?

Bottom line: how do I get my loopback API customizations / extensions to show up in the Explorer when I'm using apic put out by IBM? Do I have to use apic create --type api? Is there a way to get the explorer to pick up my changes as I customize my API? Exactly how magical is this thing?

Upvotes: 2

Views: 1006

Answers (1)

jpoveda
jpoveda

Reputation: 2177

Here's how I solved my problem:

(1) I installed the loopback-component-explorer package:

npm install loopback-component-explorer --save-dev

(2) I added a ./server/component-config.json file that contains the following:

{
    "loopback-component-explorer": {
        "mountPath": "/explorer"
    }
}

(3) Instead of viewing my documentation through apic edit, I can now view it at http://0.0.0.0:3000/explorer. Unlike the apic edit explorer, this one picks up the changes I make dynamically.

Apparently, when you setup your project with slc loopback you get this baked into the scaffolding, but because IBM really wants you to use their API Connect designer, they leave the StrongLoop API Explorer out when you use apic loopback to setup your project. Unfortunately, the API Connect Explorer does not appear to pickup API changes that are done programatically.

Upvotes: 6

Related Questions