@readme/oas-to-har 14.1.0 → 15.0.0

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 15.0.0 (2022-02-03)
2
+
3
+ > **BREAKING RELEASE**
4
+ >
5
+ > `oas-to-har` now assumes that the OpenAPI definition you're supplying it has been fully dereferenced.
6
+
7
+ * feat: upgrading oas and replacing some deprecated accessors (#58) ([ed97a5d](https://github.com/readmeio/oas-to-har/commit/ed97a5d)), closes [#58](https://github.com/readmeio/oas-to-har/issues/58)
8
+ * chore(deps-dev): bump @readme/eslint-config from 8.1.2 to 8.2.0 (#54) ([f783873](https://github.com/readmeio/oas-to-har/commit/f783873)), closes [#54](https://github.com/readmeio/oas-to-har/issues/54)
9
+ * chore(deps-dev): bump @readme/oas-examples from 4.3.3 to 4.4.0 (#53) ([fec1f82](https://github.com/readmeio/oas-to-har/commit/fec1f82)), closes [#53](https://github.com/readmeio/oas-to-har/issues/53)
10
+ * chore(deps-dev): bump eslint from 8.7.0 to 8.8.0 (#56) ([0559975](https://github.com/readmeio/oas-to-har/commit/0559975)), closes [#56](https://github.com/readmeio/oas-to-har/issues/56)
11
+ * chore(deps-dev): bump jest-expect-har from 3.0.1 to 3.0.2 (#57) ([cd2c19e](https://github.com/readmeio/oas-to-har/commit/cd2c19e)), closes [#57](https://github.com/readmeio/oas-to-har/issues/57)
12
+
13
+
14
+
1
15
  ## 14.1.0 (2022-01-25)
2
16
 
3
17
  * chore(deps): bumping all out of date deps (#51) ([926763b](https://github.com/readmeio/oas-to-har/commit/926763b)), closes [#51](https://github.com/readmeio/oas-to-har/issues/51)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@readme/oas-to-har",
3
3
  "description": "Utility to transform an OAS operation into a HAR representation",
4
- "version": "14.1.0",
4
+ "version": "15.0.0",
5
5
  "main": "src/index.js",
6
6
  "author": "Jon Ursenbach <jon@ursenba.ch>",
7
7
  "license": "ISC",
@@ -21,8 +21,8 @@
21
21
  "test": "jest --coverage"
22
22
  },
23
23
  "dependencies": {
24
- "@readme/oas-extensions": "^14.1.0",
25
- "oas": "^17.5.0",
24
+ "@readme/oas-extensions": "^14.1.1",
25
+ "oas": "^17.7.1",
26
26
  "parse-data-url": "^4.0.1"
27
27
  },
28
28
  "devDependencies": {
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ const configureSecurity = require('./lib/configure-security');
6
6
  const removeUndefinedObjects = require('./lib/remove-undefined-objects');
7
7
  const formatStyle = require('./lib/style-formatting');
8
8
 
9
- const { findSchemaDefinition, getSchema, jsonSchemaTypes } = utils;
9
+ const { jsonSchemaTypes } = utils;
10
10
 
11
11
  function formatter(values, param, type, onlyIfExists) {
12
12
  if (param.style) {
@@ -188,27 +188,7 @@ module.exports = (
188
188
  }
189
189
  }
190
190
 
191
- // Does this operation have any parameters?
192
- const parameters = [];
193
- function addParameter(param) {
194
- if (param.$ref) {
195
- parameters.push(findSchemaDefinition(param.$ref, apiDefinition));
196
- } else {
197
- parameters.push(param);
198
- }
199
- }
200
-
201
- operation.getParameters().forEach(addParameter);
202
-
203
- // Does this operation have any common parameters?
204
- if (
205
- apiDefinition &&
206
- apiDefinition.paths &&
207
- apiDefinition.paths[operation.path] &&
208
- apiDefinition.paths[operation.path].parameters
209
- ) {
210
- apiDefinition.paths[operation.path].parameters.forEach(addParameter);
211
- }
191
+ const parameters = operation.getParameters();
212
192
 
213
193
  har.url = har.url.replace(/{([-_a-zA-Z0-9[\]]+)}/g, (full, key) => {
214
194
  if (!operation || !parameters) return key; // No path params at all
@@ -299,14 +279,12 @@ module.exports = (
299
279
  });
300
280
  }
301
281
 
302
- let requestBody = getSchema(operation.schema, apiDefinition);
303
- if (requestBody) {
304
- requestBody = requestBody.schema;
305
- } else {
306
- requestBody = { schema: {} };
282
+ let requestBody = false;
283
+ if (operation.hasRequestBody()) {
284
+ [, requestBody] = operation.getRequestBody();
307
285
  }
308
286
 
309
- if (requestBody.schema && Object.keys(requestBody.schema).length) {
287
+ if (requestBody && requestBody.schema && Object.keys(requestBody.schema).length) {
310
288
  if (operation.isFormUrlEncoded()) {
311
289
  if (Object.keys(formData.formData).length) {
312
290
  const cleanFormData = removeUndefinedObjects(JSON.parse(JSON.stringify(formData.formData)));
@@ -436,7 +414,7 @@ module.exports = (
436
414
 
437
415
  // Add a `Content-Type` header if there are any body values setup above or if there is a schema defined, but only do
438
416
  // so if we don't already have a `Content-Type` present as it's impossible for a request to have multiple.
439
- if ((har.postData.text || Object.keys(requestBody.schema).length) && !hasContentType) {
417
+ if ((har.postData.text || (requestBody && Object.keys(requestBody.schema).length)) && !hasContentType) {
440
418
  har.headers.push({
441
419
  name: 'Content-Type',
442
420
  value: contentType,