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.0.x): prevent [key: string]: never in allOf with additionalProperties: false

Applies same fix as 2.0.x parser - detects empty objects with additionalProperties: false
inside allOf compositions and skips never index signature generation.
Ensures consistent behavior across all OpenAPI parser versions.

MaxwellAt 58929934 3c7828a8

+22 -4
+22 -4
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 259 259 }; 260 260 } 261 261 } else if (typeof schema.additionalProperties === 'boolean') { 262 - irSchema.additionalProperties = { 263 - type: schema.additionalProperties ? 'unknown' : 'never', 264 - }; 262 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 263 + // This would override inherited properties from other schemas in the composition 264 + const isEmptyObjectInAllOf = 265 + state.inAllOf && 266 + schema.additionalProperties === false && 267 + (!schema.properties || Object.keys(schema.properties).length === 0); 268 + 269 + if (!isEmptyObjectInAllOf) { 270 + irSchema.additionalProperties = { 271 + type: schema.additionalProperties ? 'unknown' : 'never', 272 + }; 273 + } 265 274 } else { 266 275 const irAdditionalPropertiesSchema = schemaToIrSchema({ 267 276 context, ··· 323 332 const compositionSchemas = schema.allOf; 324 333 325 334 for (const compositionSchema of compositionSchemas) { 335 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 336 + const isRef = '$ref' in compositionSchema; 337 + const schemaState = isRef 338 + ? state 339 + : { 340 + ...state, 341 + inAllOf: true, 342 + }; 343 + 326 344 const irCompositionSchema = schemaToIrSchema({ 327 345 context, 328 346 schema: compositionSchema, 329 - state, 347 + state: schemaState, 330 348 }); 331 349 332 350 irSchema.accessScopes = mergeSchemaAccessScopes(