@@ -129,55 +129,61 @@ interface SchemaProps {
129
129
130
130
const AnyOneOf : React . FC < SchemaProps > = ( { schema, schemaType } ) => {
131
131
const key = schema . oneOf ? "oneOf" : "anyOf" ;
132
- const type = schema . oneOf
132
+ const groupLabel = schema . oneOf
133
133
? translate ( { id : OPENAPI_SCHEMA_ITEM . ONE_OF , message : "oneOf" } )
134
134
: translate ( { id : OPENAPI_SCHEMA_ITEM . ANY_OF , message : "anyOf" } ) ;
135
+
135
136
return (
136
137
< >
137
138
< span className = "badge badge--info" style = { { marginBottom : "1rem" } } >
138
- { type }
139
+ { groupLabel }
139
140
</ span >
140
141
< SchemaTabs >
141
142
{ schema [ key ] ?. map ( ( anyOneSchema : any , index : number ) => {
142
- const label = anyOneSchema . title || anyOneSchema . type ;
143
+ // Prefer explicit title, then inferred name, then raw type, finally fallback MOD{n}
144
+ const computedSchemaName = getSchemaName ( anyOneSchema ) ;
145
+ const label =
146
+ anyOneSchema . title ||
147
+ computedSchemaName ||
148
+ anyOneSchema . type ||
149
+ `MOD${ index + 1 } ` ;
150
+ const isPrimitiveArm =
151
+ isPrimitive ( anyOneSchema ) || anyOneSchema . const ;
152
+ const emptyObjectPrimitive =
153
+ anyOneSchema . type === "object" &&
154
+ ! anyOneSchema . properties &&
155
+ ! anyOneSchema . allOf &&
156
+ ! anyOneSchema . oneOf &&
157
+ ! anyOneSchema . anyOf ;
143
158
return (
144
159
// @ts -ignore
145
160
< TabItem
146
161
key = { index }
147
162
label = { label }
148
163
value = { `${ index } -item-properties` }
149
164
>
150
- { /* Handle primitive types directly */ }
151
- { ( isPrimitive ( anyOneSchema ) || anyOneSchema . const ) && (
165
+ { isPrimitiveArm && (
152
166
< SchemaItem
153
167
collapsible = { false }
154
168
name = { undefined }
155
- schemaName = { anyOneSchema . type }
169
+ schemaName = { computedSchemaName }
170
+ qualifierMessage = { getQualifierMessage ( anyOneSchema ) }
171
+ schema = { anyOneSchema }
172
+ discriminator = { false }
173
+ children = { null }
174
+ />
175
+ ) }
176
+ { emptyObjectPrimitive && (
177
+ < SchemaItem
178
+ collapsible = { false }
179
+ name = { undefined }
180
+ schemaName = { computedSchemaName }
156
181
qualifierMessage = { getQualifierMessage ( anyOneSchema ) }
157
182
schema = { anyOneSchema }
158
183
discriminator = { false }
159
184
children = { null }
160
185
/>
161
186
) }
162
-
163
- { /* Handle empty object as a primitive type */ }
164
- { anyOneSchema . type === "object" &&
165
- ! anyOneSchema . properties &&
166
- ! anyOneSchema . allOf &&
167
- ! anyOneSchema . oneOf &&
168
- ! anyOneSchema . anyOf && (
169
- < SchemaItem
170
- collapsible = { false }
171
- name = { undefined }
172
- schemaName = { anyOneSchema . type }
173
- qualifierMessage = { getQualifierMessage ( anyOneSchema ) }
174
- schema = { anyOneSchema }
175
- discriminator = { false }
176
- children = { null }
177
- />
178
- ) }
179
-
180
- { /* Handle actual object types with properties or nested schemas */ }
181
187
{ anyOneSchema . type === "object" && anyOneSchema . properties && (
182
188
< Properties schema = { anyOneSchema } schemaType = { schemaType } />
183
189
) }
0 commit comments