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

Modified parseObject to detect empty objects with additionalProperties: false
inside allOf compositions and skip generating never index signature.
Updated parseAllOf to propagate inAllOf flag to child schemas while preserving
\ handling for reusable components.

MaxwellAt 3c7828a8 ff574433

+22 -4
+22 -4
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 249 249 }; 250 250 } 251 251 } else if (typeof schema.additionalProperties === 'boolean') { 252 - irSchema.additionalProperties = { 253 - type: schema.additionalProperties ? 'unknown' : 'never', 254 - }; 252 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 253 + // This would override inherited properties from other schemas in the composition 254 + const isEmptyObjectInAllOf = 255 + state.inAllOf && 256 + schema.additionalProperties === false && 257 + (!schema.properties || Object.keys(schema.properties).length === 0); 258 + 259 + if (!isEmptyObjectInAllOf) { 260 + irSchema.additionalProperties = { 261 + type: schema.additionalProperties ? 'unknown' : 'never', 262 + }; 263 + } 255 264 } else { 256 265 const irAdditionalPropertiesSchema = schemaToIrSchema({ 257 266 context, ··· 313 322 const compositionSchemas = schema.allOf; 314 323 315 324 for (const compositionSchema of compositionSchemas) { 325 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 326 + const isRef = '$ref' in compositionSchema; 327 + const schemaState = isRef 328 + ? state 329 + : { 330 + ...state, 331 + inAllOf: true, 332 + }; 333 + 316 334 const irCompositionSchema = schemaToIrSchema({ 317 335 context, 318 336 schema: compositionSchema, 319 - state, 337 + state: schemaState, 320 338 }); 321 339 322 340 irSchema.accessScopes = mergeSchemaAccessScopes(