@scalar/openapi-parser 0.10.1 → 0.10.2

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,5 +1,11 @@
1
1
  # @scalar/openapi-parser
2
2
 
3
+ ## 0.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 3791738: fix(openapi-parser): correct schema upgrade for "format: binary"
8
+
3
9
  ## 0.10.1
4
10
 
5
11
  ### Patch Changes
@@ -23,8 +23,7 @@ const getSiblings =
23
23
  const concatAll =
24
24
  /* ::<T> */
25
25
 
26
-
27
- (xs /*: $ReadOnlyArray<T> */) =>
26
+ (xs /*: $ReadOnlyArray<T> */) =>
28
27
  (ys /* : $ReadOnlyArray<T> */) /* : $ReadOnlyArray<T> */ =>
29
28
  ys.reduce((zs, z) => zs.concat(z), xs);
30
29
 
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAkHrC;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAsBpD"}
1
+ {"version":3,"file":"upgradeFromThreeToThreeOne.d.ts","sourceRoot":"","sources":["../../src/utils/upgradeFromThreeToThreeOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAIxD;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,qBAAqB,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;mBAmIrC;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAsBpD"}
@@ -63,25 +63,38 @@ function upgradeFromThreeToThreeOne(originalSpecification) {
63
63
  return schema;
64
64
  });
65
65
  // Multipart file uploads with a binary file
66
- specification = traverse(specification, (schema) => {
66
+ specification = traverse(specification, (schema, path) => {
67
67
  if (schema.type === 'object' && schema.properties !== undefined) {
68
- // Types
69
- const entries = Object.entries(schema.properties);
70
- for (const [_, value] of entries) {
71
- if (typeof value === 'object' &&
72
- value.type === 'string' &&
73
- value.format === 'binary') {
74
- value.contentEncoding = 'application/octet-stream';
75
- delete value.format;
68
+ // Check if this is a multipart request body schema
69
+ const parentPath = path.slice(0, -1);
70
+ const isMultipart = parentPath.some((segment, index) => {
71
+ return (segment === 'content' && path[index + 1] === 'multipart/form-data');
72
+ });
73
+ if (isMultipart) {
74
+ // Types
75
+ const entries = Object.entries(schema.properties);
76
+ for (const [_, value] of entries) {
77
+ if (typeof value === 'object' &&
78
+ value.type === 'string' &&
79
+ value.format === 'binary') {
80
+ value.contentMediaType = 'application/octet-stream';
81
+ delete value.format;
82
+ }
76
83
  }
77
84
  }
78
85
  }
79
86
  return schema;
80
87
  });
81
88
  // Uploading a binary file in a POST request
82
- specification = traverse(specification, (schema) => {
89
+ specification = traverse(specification, (schema, path) => {
90
+ if (path.includes('content') && path.includes('application/octet-stream')) {
91
+ return {};
92
+ }
83
93
  if (schema.type === 'string' && schema.format === 'binary') {
84
- return undefined;
94
+ return {
95
+ type: 'string',
96
+ contentMediaType: 'application/octet-stream',
97
+ };
85
98
  }
86
99
  return schema;
87
100
  });
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "parser",
18
18
  "typescript"
19
19
  ],
20
- "version": "0.10.1",
20
+ "version": "0.10.2",
21
21
  "engines": {
22
22
  "node": ">=18"
23
23
  },
@@ -59,13 +59,13 @@
59
59
  "@apidevtools/swagger-parser": "^10.1.0",
60
60
  "@babel/code-frame": "^7.24.7",
61
61
  "@google-cloud/storage": "^7.12.1",
62
- "@types/node": "^20.14.10",
62
+ "@types/node": "^20.17.10",
63
63
  "glob": "^10.3.10",
64
64
  "json-to-ast": "^2.1.0",
65
65
  "just-diff": "^6.0.2",
66
66
  "tinybench": "^2.8.0",
67
- "@scalar/build-tooling": "0.1.12",
68
67
  "@scalar/openapi-types": "0.1.5",
68
+ "@scalar/build-tooling": "0.1.12",
69
69
  "@scalar/types": "0.0.25"
70
70
  },
71
71
  "scripts": {