Repository: fastify/fastify-swagger (JavaScript)

Issue:
Omitting `uiConfig` option crashes the html page
<!--
Before you submit an issue we recommend you visit [Fastify Help](https://github.com/fastify/help) and ask any questions you have or mention any problems you've had getting started with Fastify.

**Please read this entire template before posting any issue. If you ignore these instructions
and post an issue here that does not follow the instructions, your issue might be closed,
locked, and assigned the `missing discussion` label.**
-->

## 🐛 Bug Report

Omitting `uiConfig` field while using static mode causes the `/uiConfig` route to return no content, this crashes the html page when it tries to parse the response JSON.

On [line 62 of `static.js`](https://github.com/fastify/fastify-swagger/blob/master/lib/mode/static.js#L62) it does not try to set the default value of `{}` when the field is missing, as it does for [`dynamic.js` on line 19](https://github.com/fastify/fastify-swagger/blob/master/lib/mode/dynamic.js#L19)

## To Reproduce

I'm actually using NestJS's swagger module, but the description above should be enough since it points to the original files.

```js
httpServer.register(load_package_util_1.loadPackage('fastify-swagger', 'SwaggerModule', () => require('fastify-swagger')), {
    swagger: document,
    exposeRoute: true,
    routePrefix: path,
    mode: 'static',
    specification: {
        document
    }
});
```

## Expected behavior

The default value for `uiConfig` should be `{}`, as stated in the documentation.

## Your Environment

- *node version*: v12.19.1
- *fastify version*: 3.11.0
- *os*: Windows, Linux
- *any other relevant information*



Discussion:
Would you like to send a Pull Request to address this issue? Remember to add unit tests.



Patch:
diff --git a/lib/mode/static.js b/lib/mode/static.js
index d5bf171f..a0cbe3fe 100644
--- a/lib/mode/static.js
+++ b/lib/mode/static.js
@@ -61,6 +61,7 @@ module.exports = function (fastify, opts, done) {
   if (opts.exposeRoute === true) {
     const options = {
       prefix: opts.routePrefix || '/documentation',
+      uiConfig: opts.uiConfig || {},
       baseDir: opts.specification.baseDir
     }
 


Test patch:
diff --git a/test/mode/static.js b/test/mode/static.js
index c23f285a..3db7ef45 100644
--- a/test/mode/static.js
+++ b/test/mode/static.js
@@ -752,3 +752,54 @@ test('inserts default opts in fastifySwaggerDynamic (dynamic.js)', t => {
     t.pass('Inserted default option for fastifySwagger.')
   })
 })
+
+test('/documentation/uiConfig should have default', t => {
+  const config = {
+    exposeRoute: true,
+    mode: 'static',
+    specification: {
+      path: './examples/example-static-specification.yaml',
+      baseDir: resolve(__dirname, '..', '..', 'static')
+    }
+  }
+
+  t.plan(3)
+  const fastify = new Fastify()
+  fastify.register(fastifySwagger, config)
+
+  fastify.inject({
+    method: 'GET',
+    url: '/documentation/uiConfig'
+  }, (err, res) => {
+    t.error(err)
+    t.strictEqual(res.statusCode, 200)
+    t.strictEqual(res.payload, '{}')
+  })
+})
+
+test('/documentation/uiConfig can be customize', t => {
+  const config = {
+    exposeRoute: true,
+    mode: 'static',
+    specification: {
+      path: './examples/example-static-specification.yaml',
+      baseDir: resolve(__dirname, '..', '..', 'static')
+    },
+    uiConfig: {
+      docExpansion: 'full'
+    }
+  }
+
+  t.plan(3)
+  const fastify = new Fastify()
+  fastify.register(fastifySwagger, config)
+
+  fastify.inject({
+    method: 'GET',
+    url: '/documentation/uiConfig'
+  }, (err, res) => {
+    t.error(err)
+    t.strictEqual(res.statusCode, 200)
+    t.strictEqual(res.payload, '{"docExpansion":"full"}')
+  })
+})