@kubb/oas 4.12.2 → 4.12.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/oas",
3
- "version": "4.12.2",
3
+ "version": "4.12.4",
4
4
  "description": "OpenAPI Specification (OAS) utilities and helpers for Kubb, providing parsing, normalization, and manipulation of OpenAPI/Swagger schemas.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -56,7 +56,7 @@
56
56
  }
57
57
  ],
58
58
  "dependencies": {
59
- "@redocly/openapi-core": "^2.12.7",
59
+ "@redocly/openapi-core": "^2.13.0",
60
60
  "hotscript": "^1.0.13",
61
61
  "json-schema-to-ts": "^3.1.1",
62
62
  "jsonpointer": "^5.0.1",
package/src/Oas.ts CHANGED
@@ -380,6 +380,36 @@ export class Oas<const TOAS = unknown> extends BaseOas {
380
380
  const property = pathParameters.content?.[contentType]?.schema ?? (pathParameters.schema as SchemaObject)
381
381
  const required = [...(schema.required || ([] as any)), pathParameters.required ? pathParameters.name : undefined].filter(Boolean)
382
382
 
383
+ // Handle explode=true with style=form for object with additionalProperties
384
+ // According to OpenAPI spec, when explode is true, object properties are flattened
385
+ const getDefaultStyle = (location: string): string => {
386
+ if (location === 'query') return 'form'
387
+ if (location === 'path') return 'simple'
388
+ return 'simple'
389
+ }
390
+ const style = pathParameters.style || getDefaultStyle(inKey)
391
+ const explode = pathParameters.explode !== undefined ? pathParameters.explode : style === 'form'
392
+
393
+ if (
394
+ inKey === 'query' &&
395
+ style === 'form' &&
396
+ explode === true &&
397
+ property?.type === 'object' &&
398
+ property?.additionalProperties &&
399
+ !property?.properties
400
+ ) {
401
+ // When explode is true for an object with only additionalProperties,
402
+ // flatten it to the root level by merging additionalProperties with existing schema.
403
+ // This preserves other query parameters while allowing dynamic key-value pairs.
404
+ return {
405
+ ...schema,
406
+ description: pathParameters.description || schema.description,
407
+ deprecated: schema.deprecated,
408
+ example: property.example || schema.example,
409
+ additionalProperties: property.additionalProperties,
410
+ }
411
+ }
412
+
383
413
  return {
384
414
  ...schema,
385
415
  description: schema.description,