( config: RestServerConfig, )
| 1219 | }; |
| 1220 | |
| 1221 | function resolveRestServerConfig( |
| 1222 | config: RestServerConfig, |
| 1223 | ): RestServerResolvedConfig { |
| 1224 | const result: RestServerResolvedConfig = Object.assign( |
| 1225 | cloneDeep(DEFAULT_CONFIG), |
| 1226 | config, |
| 1227 | ); |
| 1228 | |
| 1229 | // Can't check falsiness, 0 is a valid port. |
| 1230 | if (result.port == null) { |
| 1231 | result.port = 3000; |
| 1232 | } |
| 1233 | |
| 1234 | if (result.host == null) { |
| 1235 | // Set it to '' so that the http server will listen on all interfaces |
| 1236 | result.host = undefined; |
| 1237 | } |
| 1238 | |
| 1239 | if (!result.openApiSpec.endpointMapping) { |
| 1240 | // mapping may be mutated by addOpenApiSpecEndpoint, be sure that doesn't |
| 1241 | // pollute the default mapping configuration |
| 1242 | result.openApiSpec.endpointMapping = cloneDeep(OPENAPI_SPEC_MAPPING); |
| 1243 | } |
| 1244 | |
| 1245 | result.apiExplorer = normalizeApiExplorerConfig(config.apiExplorer); |
| 1246 | |
| 1247 | if (result.openApiSpec.disabled) { |
| 1248 | // Disable apiExplorer if the OpenAPI spec endpoint is disabled |
| 1249 | result.apiExplorer.disabled = true; |
| 1250 | } |
| 1251 | |
| 1252 | return result; |
| 1253 | } |
| 1254 | |
| 1255 | function normalizeApiExplorerConfig( |
| 1256 | input: ApiExplorerOptions | undefined, |
no test coverage detected