Search code examples
loopbackjsloopback4

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


Loopback 4 is showing a version number in the Api explorer and I'd like this version to follow the version of my component that is specified in the package.json .

How can this be achieved ?

Regards,


Solution

  • 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.