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.

remove discriminator changes in openapi 2.0.x

+5 -63
+5 -63
packages/shared/src/openApi/2.0.x/parser/schema.ts
··· 6 6 SchemaType, 7 7 SchemaWithRequired, 8 8 } from '../../../openApi/shared/types/schema'; 9 - import { 10 - convertDiscriminatorValue, 11 - type DiscriminatorPropertyType, 12 - discriminatorValues, 13 - } from '../../../openApi/shared/utils/discriminator'; 9 + import { discriminatorValues } from '../../../openApi/shared/utils/discriminator'; 14 10 import { isTopLevelComponent, refToName } from '../../../utils/ref'; 15 11 import type { SchemaObject } from '../types/spec'; 16 12 ··· 29 25 } 30 26 31 27 return; 32 - }; 33 - 34 - /** 35 - * Finds the type of a discriminator property by looking it up in the provided schemas. 36 - * Searches through properties and allOf chains to find the property definition. 37 - */ 38 - const findDiscriminatorPropertyType = ({ 39 - context, 40 - propertyName, 41 - schemas, 42 - }: { 43 - context: Context; 44 - propertyName: string; 45 - schemas: ReadonlyArray<SchemaObject>; 46 - }): DiscriminatorPropertyType => { 47 - for (const schema of schemas) { 48 - const resolved = schema.$ref ? context.resolveRef<SchemaObject>(schema.$ref) : schema; 49 - 50 - // Check direct properties 51 - const property = resolved.properties?.[propertyName]; 52 - if (property) { 53 - const resolvedProperty = property.$ref 54 - ? context.resolveRef<SchemaObject>(property.$ref) 55 - : property; 56 - if ( 57 - resolvedProperty.type === 'boolean' || 58 - resolvedProperty.type === 'integer' || 59 - resolvedProperty.type === 'number' 60 - ) { 61 - return resolvedProperty.type; 62 - } 63 - } 64 - 65 - // Check allOf chains 66 - if (resolved.allOf) { 67 - const foundType = findDiscriminatorPropertyType({ 68 - context, 69 - propertyName, 70 - schemas: resolved.allOf, 71 - }); 72 - if (foundType !== 'string') { 73 - return foundType; 74 - } 75 - } 76 - } 77 - 78 - return 'string'; 79 28 }; 80 29 81 30 const parseSchemaJsDoc = ({ ··· 387 336 // `$ref` should be passed from the root `parseSchema()` call 388 337 if (ref.discriminator && state.$ref) { 389 338 const values = discriminatorValues(state.$ref); 390 - 391 - // Detect the actual type of the discriminator property 392 - const propertyType = findDiscriminatorPropertyType({ 393 - context, 394 - propertyName: ref.discriminator, 395 - schemas: [ref], 396 - }); 397 - 398 - const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map((value) => 399 - convertDiscriminatorValue(value, propertyType), 400 - ); 339 + const valueSchemas: ReadonlyArray<IR.SchemaObject> = values.map((value) => ({ 340 + const: value, 341 + type: 'string', 342 + })); 401 343 const irDiscriminatorSchema: IR.SchemaObject = { 402 344 properties: { 403 345 [ref.discriminator]: