swagger-client 3.23.1 → 3.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,4 +3,5 @@ export { default as findOperation } from './find-operation.js';
3
3
  export { default as getOperationRaw } from './get-operation-raw.js';
4
4
  export { default as opId } from './op-id.js';
5
5
  export { default as idFromPathMethod } from './id-from-path-method/index.js';
6
- export { default as idFromPathMethodLegacy } from './id-from-path-method/legacy.js';
6
+ export { default as idFromPathMethodLegacy } from './id-from-path-method/legacy.js';
7
+ export { default as isHttpUrl } from './is-http-url.js';
@@ -0,0 +1,5 @@
1
+ import { url } from '@swagger-api/apidom-reference/configuration/empty';
2
+ const {
3
+ isHttpUrl
4
+ } = url;
5
+ export default isHttpUrl;
package/es/index.js CHANGED
@@ -8,7 +8,8 @@ import openApi30ResolveStrategy from './resolver/strategies/openapi-3-0/index.js
8
8
  import openApi31ApiDOMResolveStrategy from './resolver/strategies/openapi-3-1-apidom/index.js';
9
9
  import { makeApisTagOperation } from './interfaces.js';
10
10
  import { execute, buildRequest, baseUrl } from './execute/index.js';
11
- import { opId } from './helpers/index.js';
11
+ import { opId, isHttpUrl } from './helpers/index.js';
12
+ import { isOpenAPI2, isOpenAPI3 } from './helpers/openapi-predicates.js';
12
13
  import HttpResolverSwaggerClient from './resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js';
13
14
  import JsonParser from './resolver/apidom/reference/parse/parsers/json/index.js';
14
15
  import YamlParser from './resolver/apidom/reference/parse/parsers/yaml-1-2/index.js';
@@ -123,8 +124,7 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
123
124
  spec
124
125
  } = this;
125
126
  const specUrl = this.url;
126
- // TODO: OAS3: support servers here
127
- if (specUrl && specUrl.startsWith('http')) {
127
+ if (isOpenAPI2(spec) && isHttpUrl(specUrl)) {
128
128
  const parsed = new URL(specUrl);
129
129
  if (!spec.host) {
130
130
  spec.host = parsed.host;
@@ -135,6 +135,12 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
135
135
  if (!spec.basePath) {
136
136
  spec.basePath = '/';
137
137
  }
138
+ } else if (isOpenAPI3(spec) && isHttpUrl(specUrl)) {
139
+ if (!spec.servers) {
140
+ spec.servers = [{
141
+ url: specUrl
142
+ }];
143
+ }
138
144
  }
139
145
  };
140
146
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
4
4
  exports.__esModule = true;
5
- exports.opId = exports.idFromPathMethodLegacy = exports.idFromPathMethod = exports.getOperationRaw = exports.findOperation = exports.eachOperation = void 0;
5
+ exports.opId = exports.isHttpUrl = exports.idFromPathMethodLegacy = exports.idFromPathMethod = exports.getOperationRaw = exports.findOperation = exports.eachOperation = void 0;
6
6
  var _eachOperation = _interopRequireDefault(require("./each-operation.js"));
7
7
  exports.eachOperation = _eachOperation.default;
8
8
  var _findOperation = _interopRequireDefault(require("./find-operation.js"));
@@ -14,4 +14,6 @@ exports.opId = _opId.default;
14
14
  var _index = _interopRequireDefault(require("./id-from-path-method/index.js"));
15
15
  exports.idFromPathMethod = _index.default;
16
16
  var _legacy = _interopRequireDefault(require("./id-from-path-method/legacy.js"));
17
- exports.idFromPathMethodLegacy = _legacy.default;
17
+ exports.idFromPathMethodLegacy = _legacy.default;
18
+ var _isHttpUrl = _interopRequireDefault(require("./is-http-url.js"));
19
+ exports.isHttpUrl = _isHttpUrl.default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ var _empty = require("@swagger-api/apidom-reference/configuration/empty");
6
+ const {
7
+ isHttpUrl
8
+ } = _empty.url;
9
+ var _default = exports.default = isHttpUrl;
package/lib/index.js CHANGED
@@ -14,6 +14,7 @@ var _index7 = _interopRequireDefault(require("./resolver/strategies/openapi-3-1-
14
14
  var _interfaces = require("./interfaces.js");
15
15
  var _index8 = require("./execute/index.js");
16
16
  var _index9 = require("./helpers/index.js");
17
+ var _openapiPredicates = require("./helpers/openapi-predicates.js");
17
18
  var _index10 = _interopRequireDefault(require("./resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js"));
18
19
  var _index11 = _interopRequireDefault(require("./resolver/apidom/reference/parse/parsers/json/index.js"));
19
20
  var _index12 = _interopRequireDefault(require("./resolver/apidom/reference/parse/parsers/yaml-1-2/index.js"));
@@ -134,8 +135,7 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
134
135
  spec
135
136
  } = this;
136
137
  const specUrl = this.url;
137
- // TODO: OAS3: support servers here
138
- if (specUrl && specUrl.startsWith('http')) {
138
+ if ((0, _openapiPredicates.isOpenAPI2)(spec) && (0, _index9.isHttpUrl)(specUrl)) {
139
139
  const parsed = new URL(specUrl);
140
140
  if (!spec.host) {
141
141
  spec.host = parsed.host;
@@ -146,6 +146,12 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
146
146
  if (!spec.basePath) {
147
147
  spec.basePath = '/';
148
148
  }
149
+ } else if ((0, _openapiPredicates.isOpenAPI3)(spec) && (0, _index9.isHttpUrl)(specUrl)) {
150
+ if (!spec.servers) {
151
+ spec.servers = [{
152
+ url: specUrl
153
+ }];
154
+ }
149
155
  }
150
156
  };
151
157
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-client",
3
- "version": "3.23.1",
3
+ "version": "3.24.1",
4
4
  "description": "SwaggerJS - a collection of interfaces for OAI specs",
5
5
  "browser": {
6
6
  "./src/helpers/btoa.node.js": "./src/helpers/btoa.browser.js",
@@ -50,7 +50,7 @@
50
50
  "build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
51
51
  "lint": "eslint src/ test/",
52
52
  "lint:fix": "npm run lint -- --fix",
53
- "link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-json-pointer",
53
+ "link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-error @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-2 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-json-pointer",
54
54
  "test": "run-s test:unit:coverage test:artifact",
55
55
  "test:unit": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.config.js",
56
56
  "test:unit:coverage": "cross-env BABEL_ENV=commonjs jest --runInBand --config ./config/jest/jest.unit.coverage.config.js",
@@ -77,15 +77,15 @@
77
77
  "@babel/plugin-transform-runtime": "^7.21.0",
78
78
  "@babel/preset-env": "^7.20.2",
79
79
  "@babel/register": "^7.21.0",
80
- "@commitlint/cli": "^17.0.0",
81
- "@commitlint/config-conventional": "^17.0.0",
80
+ "@commitlint/cli": "^18.0.0",
81
+ "@commitlint/config-conventional": "^18.0.0",
82
82
  "babel-loader": "=9.1.3",
83
83
  "cross-env": "=7.0.3",
84
84
  "eslint": "^8.42.0",
85
85
  "eslint-config-airbnb-base": "^15.0.0",
86
86
  "eslint-config-prettier": "=9.0.0",
87
- "eslint-plugin-import": "=2.28.1",
88
- "eslint-plugin-prettier": "=5.0.0",
87
+ "eslint-plugin-import": "=2.29.0",
88
+ "eslint-plugin-prettier": "=5.0.1",
89
89
  "expect": "^29.0.3",
90
90
  "glob": "=10.3.10",
91
91
  "husky": "^8.0.1",
@@ -95,24 +95,24 @@
95
95
  "jest-environment-jsdom": "^29.0.3",
96
96
  "json-loader": "=0.5.7",
97
97
  "license-checker": "=25.0.1",
98
- "lint-staged": "=14.0.1",
98
+ "lint-staged": "=15.0.2",
99
99
  "lodash": "^4.17.21",
100
100
  "npm-run-all": "=4.1.5",
101
101
  "prettier": "^3.0.0",
102
102
  "rimraf": "=5.0.5",
103
103
  "source-map-explorer": "^2.5.3",
104
104
  "terser-webpack-plugin": "^5.0.3",
105
- "webpack": "=5.88.2",
105
+ "webpack": "=5.89.0",
106
106
  "webpack-bundle-size-analyzer": "=3.1.0",
107
107
  "webpack-cli": "=5.1.4",
108
108
  "webpack-stats-plugin": "=1.1.3"
109
109
  },
110
110
  "dependencies": {
111
111
  "@babel/runtime-corejs3": "^7.22.15",
112
- "@swagger-api/apidom-core": ">=0.77.0 <1.0.0",
113
- "@swagger-api/apidom-json-pointer": ">=0.77.0 <1.0.0",
114
- "@swagger-api/apidom-ns-openapi-3-1": ">=0.77.0 <1.0.0",
115
- "@swagger-api/apidom-reference": ">=0.77.0 <1.0.0",
112
+ "@swagger-api/apidom-core": ">=0.82.0 <1.0.0",
113
+ "@swagger-api/apidom-json-pointer": ">=0.82.0 <1.0.0",
114
+ "@swagger-api/apidom-ns-openapi-3-1": ">=0.82.0 <1.0.0",
115
+ "@swagger-api/apidom-reference": ">=0.82.0 <1.0.0",
116
116
  "cookie": "~0.5.0",
117
117
  "deepmerge": "~4.3.0",
118
118
  "fast-json-patch": "^3.0.0-1",
@@ -127,11 +127,14 @@
127
127
  "overrides": {
128
128
  "@swagger-api/apidom-reference": {
129
129
  "@swagger-api/apidom-ns-asyncapi-2": "npm:-@0.0.1",
130
+ "@swagger-api/apidom-ns-openapi-2": "npm:-@0.0.1",
130
131
  "@swagger-api/apidom-parser-adapter-api-design-systems-json": "npm:-@0.0.1",
131
132
  "@swagger-api/apidom-parser-adapter-api-design-systems-yaml": "npm:-@0.0.1",
132
133
  "@swagger-api/apidom-parser-adapter-asyncapi-json-2": "npm:-@0.0.1",
133
134
  "@swagger-api/apidom-parser-adapter-asyncapi-yaml-2": "npm:-@0.0.1",
134
135
  "@swagger-api/apidom-parser-adapter-json": "npm:-@0.0.1",
136
+ "@swagger-api/apidom-parser-adapter-openapi-json-2": "npm:-@0.0.1",
137
+ "@swagger-api/apidom-parser-adapter-openapi-yaml-2": "npm:-@0.0.1",
135
138
  "@swagger-api/apidom-parser-adapter-openapi-json-3-0": "npm:-@0.0.1",
136
139
  "@swagger-api/apidom-parser-adapter-openapi-json-3-1": "npm:-@0.0.1",
137
140
  "@swagger-api/apidom-parser-adapter-openapi-yaml-3-0": "npm:-@0.0.1",