@@ -13,15 +13,14 @@ const { detectDuplicates } = require("../engine/transformers");
1313 * Transforms provided API JSON file using oneOf transformation
1414 *
1515 * @param {* } api OpenAPI JSON File
16- * @param {* } oneOfTransformations array of transformations to apply
1716 * @returns OpenAPI JSON File
1817 */
1918function applyOneOfTransformations ( api ) {
2019 const oneOfTransformations = getAllObjects ( api , ( obj ) => {
2120 return canApplyOneOfTransformation ( obj , api ) ;
2221 } ) . filter ( ( e ) => ! ignoreModels . includes ( e . path ) ) ;
2322
24- transformationPaths = oneOfTransformations . map ( ( e ) => e . path ) ;
23+ const transformationPaths = oneOfTransformations . map ( ( e ) => e . path ) ;
2524 console . info (
2625 "# OneOf transformations: " +
2726 JSON . stringify ( transformationPaths , undefined , 2 ) ,
@@ -83,7 +82,7 @@ function transformOneOfEnum(parentObject, api) {
8382 delete parentObject . oneOf ;
8483}
8584
86- // Moves all the propertis of the children into the parent
85+ // Moves all the properties of the children into the parent
8786function transformOneOfProperties ( parentObject , api ) {
8887 const childObjects = parentObject . oneOf . map ( ( childRef ) =>
8988 getObjectFromReference ( childRef , api ) ,
@@ -153,7 +152,7 @@ function handleDuplicates(parentObject, childObject) {
153152 }
154153}
155154
156- // Uses ignore list for known missmatches and removes them
155+ // Uses ignore list for known mismatches and removes them
157156function filterReferenceOrTypeMissmatch ( mismatches ) {
158157 return mismatches . filter ( ( mismatch ) => {
159158 for ( const ignoredProperty of ignoredProperties ) {
@@ -183,8 +182,8 @@ function mergeDuplicates(
183182 ) } \n`,
184183 ) ;
185184 for ( duplicate of duplicates ) {
186- childProperty = childObject . properties [ duplicate . key ] ;
187- parentProperty = parentObject . properties [ duplicate . key ] ;
185+ const childProperty = childObject . properties [ duplicate . key ] ;
186+ const parentProperty = parentObject . properties [ duplicate . key ] ;
188187
189188 if (
190189 parentProperty . description &&
@@ -195,10 +194,7 @@ function mergeDuplicates(
195194}
196195
197196function canApplyOneOfTransformation ( obj , api ) {
198- if ( obj . oneOf ) {
199- return true ;
200- }
201- return false ;
197+ return ! ! obj . oneOf ;
202198}
203199
204200module . exports = {
0 commit comments