How to Modify the Strongloop's Loopback Explorer CSS

How to Modify the StrongLoop's LoopBack Explorer CSS

You can provide your own version of Swagger UI files via options.uiDirs.

  1. Edit your server/server.js and add this config option to the explorer:

    app.use(explorer(app, { uiDirs: path.resolve(__dirname, 'explorer') }));
  2. Copy the directory node_modules/loopback-explorer/public/css to server/explorer/css

  3. Customize the copied CSS files as you need.

You should lock loopback-explorer's major & minor version in your package.json. Newer versions of loopback-explorer may change the CSS in which case your customization may stop working.

How to customize the api version that appear in loopback 4 generated API explorer?

At this moment, you can modify the spec manually. First get the application's OpenAPI spec by calling app.restServer.getApiSpec()

Then modify the spec accordingly (change the version inside info to be the same as the version in package.json), and setting the new spec by calling app.api(your_new_spec)

LoopBack team is building an OpenAPI spec enhancer service to make ^ automatically happen by applying spec enhancers. See the usage and demo documentation in Extending-OpenAPI-specification

After finishing story Adding an enhancer service in the rest server, you will be able to modify the spec by applying your enhancer.

What is {nk} in loopback API explorer?

I think it's related to Nested queries.

May be {nk} stands for nested foreign key.

How to Read Query Filters from Within a LoopBack Model

Declare filter query paramerter as argument for your formatted remote method and then access it just like callback argument.

See how to describe arguments in docs.

Loopback: How can we modify the return data of a built in model function

You need to remove strong-error-handler from middlewares and add your custom error handler like this

In config.json you need to do :

...
"remoting" {
...
"handleErrors": false
...
}
...

Also create config.local.js in root/sever folder and add below :

'use strict';

var errorConverter = require('./middlewares/error-converter');

module.exports = {
remoting: {
errorHandler: {
handler: errorConverter()
}
}
};

error-converter.js in middleare folder (or any other place) is the custom error hadnling middleare



Related Topics



Leave a reply



Submit