File tree 1 file changed +3
-17
lines changed
1 file changed +3
-17
lines changed Original file line number Diff line number Diff line change 1
1
import fs from "fs" ;
2
2
import yaml from "js-yaml" ;
3
- import merger from "json-schema-merge-allof" ;
3
+ import mergeAllOf from "json-schema-merge-allof" ;
4
4
import { dereferenceDocument } from "@open-rpc/schema-utils-js" ;
5
5
6
6
function sortByMethodName ( methods ) {
@@ -102,26 +102,12 @@ let spec = await dereferenceDocument(doc);
102
102
103
103
spec . components = { } ;
104
104
105
- function recursiveMerge ( schema ) {
106
- schema = merger ( schema ) ;
107
-
108
- if ( "items" in schema && "oneOf" in schema . items ) {
109
- schema . items . oneOf = recursiveMerge ( schema . items . oneOf ) ;
110
- }
111
- if ( "oneOf" in schema ) {
112
- for ( var k = 0 ; k < schema . oneOf . length ; k ++ ) {
113
- schema . oneOf [ k ] = recursiveMerge ( schema . oneOf [ k ] ) ;
114
- }
115
- }
116
- return schema ;
117
- }
118
-
119
105
// Merge instances of `allOf` in methods.
120
106
for ( var i = 0 ; i < spec . methods . length ; i ++ ) {
121
107
for ( var j = 0 ; j < spec . methods [ i ] . params . length ; j ++ ) {
122
- spec . methods [ i ] . params [ j ] . schema = recursiveMerge ( spec . methods [ i ] . params [ j ] . schema ) ;
108
+ spec . methods [ i ] . params [ j ] . schema = mergeAllOf ( spec . methods [ i ] . params [ j ] . schema ) ;
123
109
}
124
- spec . methods [ i ] . result . schema = recursiveMerge ( spec . methods [ i ] . result . schema ) ;
110
+ spec . methods [ i ] . result . schema = mergeAllOf ( spec . methods [ i ] . result . schema ) ;
125
111
}
126
112
127
113
let data = JSON . stringify ( spec , null , '\t' ) ;
You can’t perform that action at this time.
0 commit comments