Swagger.vue 856 Bytes
Newer Older
janis.streib's avatar
janis.streib committed
1
2
3
4
5
6
<template>
    <div id="swagger-ui">
    </div>
</template>

<script>
janis.streib's avatar
janis.streib committed
7
8
import SwaggerUI from 'swagger-ui'
import 'swagger-ui/dist/swagger-ui.css'
janis.streib's avatar
janis.streib committed
9

janis.streib's avatar
janis.streib committed
10
11
12
13
14
export default {
  name: 'ui.vue',
  mounted () {
    var self = this
    SwaggerUI({
15
16
      tagsSorter: 'alpha',
      apisSorter: 'alpha',
janis.streib's avatar
janis.streib committed
17
      url: '/api.yml',
janis.streib's avatar
janis.streib committed
18
19
20
21
22
23
24
25
26
27
28
      docExpansion: 'none',
      dom_id: '#swagger-ui',
      deepLinking: false,
      filter: true,
      presets: [
        SwaggerUI.presets.apis
      ],
      plugins: [
        SwaggerUI.plugins.DownloadUrl
      ],
      requestInterceptor: function (req) {
29
        if (self.$store.state.user) {
janis.streib's avatar
janis.streib committed
30
31
          req.headers.Authorization = 'Bearer ' + self.$store.state.token.token
          window.console.log('Authorized from Session')
janis.streib's avatar
janis.streib committed
32
        }
janis.streib's avatar
janis.streib committed
33
34
35
36
37
38
39
        return req
      }
    })
  },
  created () {
  }
}
janis.streib's avatar
janis.streib committed
40
41
42
43
44
</script>

<style scoped>

</style>