File tree Expand file tree Collapse file tree
tools/proto-convert/src/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,6 +200,27 @@ export function remove_unused(spec: OpenAPIV3.Document): void {
200200 }
201201 return false ;
202202 } ) ;
203+
204+ // Clean up empty properties objects and oneOf/anyOf items left after removing broken refs
205+ deleteMatchingKeys ( spec , ( obj : any ) => {
206+ // Remove oneOf/anyOf items with empty or missing properties (after broken refs removed)
207+ if ( obj . properties !== undefined && obj . required !== undefined ) {
208+ // Check if all properties are empty or removed
209+ const propKeys = Object . keys ( obj . properties ) ;
210+ if ( propKeys . length === 0 ) {
211+ return true ; // Remove this oneOf item entirely
212+ }
213+ // Check if properties only contain empty objects
214+ const hasValidProps = propKeys . some ( k => {
215+ const prop = obj . properties [ k ] ;
216+ return prop && Object . keys ( prop ) . length > 0 ;
217+ } ) ;
218+ if ( ! hasValidProps ) {
219+ return true ;
220+ }
221+ }
222+ return false ;
223+ } ) ;
203224}
204225
205226/**
You can’t perform that action at this time.
0 commit comments