source: node_modules/swagger-client/lib/resolver/utils/options.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d24f17c]1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4exports.__esModule = true;
5exports.retrievalURI = exports.httpClient = void 0;
6var _index = _interopRequireDefault(require("../../http/index.js"));
7const retrievalURI = options => {
8 var _ref, _globalThis$document;
9 /**
10 * Swagger-UI uses baseDoc instead of url, this helper function exists
11 * to allow both.
12 *
13 * In browser environment, we allow to pass a relative URI Reference,
14 * and we resolve it against the document's baseURI before passing it deeper
15 * to swagger-client code.
16 */
17 const {
18 baseDoc,
19 url
20 } = options;
21 const retrievalURL = (_ref = baseDoc != null ? baseDoc : url) != null ? _ref : '';
22 return typeof ((_globalThis$document = globalThis.document) == null ? void 0 : _globalThis$document.baseURI) === 'string' ? String(new URL(retrievalURL, globalThis.document.baseURI)) : retrievalURL;
23};
24exports.retrievalURI = retrievalURI;
25const httpClient = options => {
26 const {
27 fetch,
28 http
29 } = options;
30
31 // @TODO fetch should be removed, and http used instead
32 // provide a default fetch implementation
33 return fetch || http || _index.default;
34};
35exports.httpClient = httpClient;
Note: See TracBrowser for help on using the repository browser.