fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(parser-3.1.x): prevent [key: string]: never in allOf with additionalProperties: false

Applies same fix as 2.0.x/3.0.x parsers - detects empty objects with additionalProperties: false
inside allOf compositions and skips never index signature generation.
Completes the fix implementation across all three OpenAPI specification parser versions.

MaxwellAt 2e259121 58929934

+22 -4
+22 -4
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 290 290 }; 291 291 } 292 292 } else if (typeof schema.additionalProperties === 'boolean') { 293 - irSchema.additionalProperties = { 294 - type: schema.additionalProperties ? 'unknown' : 'never', 295 - }; 293 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 294 + // This would override inherited properties from other schemas in the composition 295 + const isEmptyObjectInAllOf = 296 + state.inAllOf && 297 + schema.additionalProperties === false && 298 + (!schema.properties || Object.keys(schema.properties).length === 0); 299 + 300 + if (!isEmptyObjectInAllOf) { 301 + irSchema.additionalProperties = { 302 + type: schema.additionalProperties ? 'unknown' : 'never', 303 + }; 304 + } 296 305 } else { 297 306 const irAdditionalPropertiesSchema = schemaToIrSchema({ 298 307 context, ··· 361 370 const compositionSchemas = schema.allOf; 362 371 363 372 for (const compositionSchema of compositionSchemas) { 373 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 374 + const isRef = '$ref' in compositionSchema; 375 + const schemaState = isRef 376 + ? state 377 + : { 378 + ...state, 379 + inAllOf: true, 380 + }; 381 + 364 382 const irCompositionSchema = schemaToIrSchema({ 365 383 context, 366 384 schema: compositionSchema, 367 - state, 385 + state: schemaState, 368 386 }); 369 387 370 388 if (schema.required) {