1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | 'use strict';
|
17 |
|
18 | var path = require('path');
|
19 | var _ = require('lodash');
|
20 | var debug = require('debug')('swagger');
|
21 |
|
22 | var config = {
|
23 | rootDir: path.resolve(__dirname, '..'),
|
24 | userHome: process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'],
|
25 | debug: !!process.env.DEBUG
|
26 | };
|
27 | config.nodeModules = path.resolve(config.rootDir, 'node_modules');
|
28 |
|
29 | module.exports = config;
|
30 |
|
31 |
|
32 | config.style = {
|
33 | fileName: path.resolve(__dirname, 'style.css')
|
34 | }
|
35 |
|
36 | config.swagger = {
|
37 | fileName: 'api/swagger/swagger.yaml',
|
38 | JSONfileName: 'api/swagger/swagger.json',
|
39 | editorDir: path.resolve(config.nodeModules, 'swagger-editor'),
|
40 | editorConfig: {
|
41 | analytics: { google: { id: null } },
|
42 | disableCodeGen: true,
|
43 | disableNewUserIntro: false,
|
44 | examplesFolder: '/spec-files/',
|
45 | editorOptions: {theme: "ace/theme/atom_dark"},
|
46 | exampleFiles: [],
|
47 | autocompleteExtension: {},
|
48 | useBackendForStorage: true,
|
49 | backendEndpoint: '/editor/spec',
|
50 | backendHealthCheckTimeout: 5000,
|
51 | useYamlBackend: true,
|
52 | disableFileMenu: false,
|
53 | enableTryIt: true,
|
54 | headerBranding: true,
|
55 | brandingCssClass: null,
|
56 | schemaUrl: '/schema/swagger.json',
|
57 | importProxyUrl: 'https://cors-it.herokuapp.com/?url='
|
58 | }
|
59 | };
|
60 |
|
61 |
|
62 |
|
63 | config.project = {
|
64 | port: process.env.PORT || 10010,
|
65 | skeletonDir: path.resolve(__dirname, '..', 'project-skeleton')
|
66 | };
|
67 |
|
68 |
|
69 |
|
70 | _.each(process.env, function(value, key) {
|
71 | var split = key.split('_');
|
72 | if (split[0] === 'swagger') {
|
73 | var configItem = config;
|
74 | for (var i = 1; i < split.length; i++) {
|
75 | var subKey = split[i];
|
76 | if (i < split.length - 1) {
|
77 | if (!configItem[subKey]) { configItem[subKey] = {}; }
|
78 | configItem = configItem[subKey];
|
79 | } else {
|
80 | configItem[subKey] = value;
|
81 | }
|
82 | }
|
83 | debug('loaded env var: %s = %s', split.slice(1).join('.'), value);
|
84 | }
|
85 | });
|
86 |
|
87 |
|