@@ -6,11 +6,7 @@ import type {
66 SchemaType ,
77 SchemaWithRequired ,
88} 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' ;
1410import { isTopLevelComponent , refToName } from '../../../utils/ref' ;
1511import type { SchemaObject } from '../types/spec' ;
1612
@@ -31,53 +27,6 @@ export const getSchemaType = ({
3127 return ;
3228} ;
3329
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- } ;
80-
8130const parseSchemaJsDoc = ( {
8231 irSchema,
8332 schema,
@@ -387,17 +336,10 @@ const parseAllOf = ({
387336 // `$ref` should be passed from the root `parseSchema()` call
388337 if ( ref . discriminator && state . $ref ) {
389338 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+ } ) ) ;
401343 const irDiscriminatorSchema : IR . SchemaObject = {
402344 properties : {
403345 [ ref . discriminator ] :
0 commit comments