@@ -2,18 +2,16 @@ import type {OpenAPIV3} from "openapi-types";
22import { traverse } from './utils/OpenApiTraverser' ;
33import isEqual from 'lodash.isequal' ;
44import { compressMultipleUnderscores , isPrimitiveType , resolveObj , isReferenceObject , isEmptyObjectSchema , is_simple_ref } from './utils/helper' ;
5- import Logger from "./utils/logger" ;
5+ import logger from "./utils/logger" ;
66
77
88const DEFAULT_MAP_KEY = 'field' // default key for simplified additionalProperties
99const DEFAULT_MAP_VALUE = 'value' // default value for simplified additionalProperties
1010
1111export class SchemaModifier {
12- logger : Logger
1312 root : OpenAPIV3 . Document ;
14- constructor ( root : OpenAPIV3 . Document , logger : Logger = new Logger ( ) ) {
13+ constructor ( root : OpenAPIV3 . Document ) {
1514 this . root = root ;
16- this . logger = logger ;
1715 }
1816 public modify ( ) : OpenAPIV3 . Document {
1917 traverse ( this . root , {
@@ -256,7 +254,7 @@ export class SchemaModifier {
256254 }
257255 } else if ( complexObject . type === 'object' && complexObject . properties ) {
258256 if ( complexObject . properties [ DEFAULT_MAP_KEY ] ) {
259- this . logger . error ( "Error: additionalProperties key already exists in the schema " + complexObject ) ;
257+ logger . error ( "Error: additionalProperties key already exists in the schema " + complexObject ) ;
260258 }
261259 complexObject . properties [ DEFAULT_MAP_KEY ] = this . createAdditionalPropertySchema ( ) . properties ?. [ DEFAULT_MAP_KEY ] as OpenAPIV3 . SchemaObject || { } ;
262260 } else if ( isPrimitiveType ( complexObject ) ) {
@@ -405,7 +403,7 @@ export class SchemaModifier {
405403 }
406404
407405 if ( schema . properties [ propertyName ] ) {
408- this . logger . warn ( `Property '${ propertyName } ' already exists in schema, skipping additionalProperties conversion` ) ;
406+ logger . warn ( `Property '${ propertyName } ' already exists in schema, skipping additionalProperties conversion` ) ;
409407 return ;
410408 }
411409
@@ -437,7 +435,7 @@ export class SchemaModifier {
437435 delete schema . propertyNames ;
438436 }
439437
440- this . logger . info ( `Converted additionalProperties to named property '${ propertyName } ' with type: object` ) ;
438+ logger . info ( `Converted additionalProperties to named property '${ propertyName } ' with type: object` ) ;
441439 }
442440
443441 /**
@@ -473,7 +471,7 @@ export class SchemaModifier {
473471 schema . additionalProperties = items . additionalProperties ;
474472 delete ( schema as any ) . items ;
475473
476- this . logger . info ( `Removed array wrapper from array of maps schema` ) ;
474+ logger . info ( `Removed array wrapper from array of maps schema` ) ;
477475 }
478476 }
479477 }
@@ -514,7 +512,7 @@ export class SchemaModifier {
514512 if ( Array . isArray ( schema . oneOf ) && schema . oneOf . length > 0 ) {
515513 if ( this . isOneOfWithSingleProperties ( schema . oneOf ) ) {
516514 this . flattenOneOfToProperties ( schema ) ;
517- this . logger . info ( `Converted oneOf pattern to minProperties/maxProperties` ) ;
515+ logger . info ( `Converted oneOf pattern to minProperties/maxProperties` ) ;
518516 }
519517 }
520518 }
@@ -587,10 +585,10 @@ export class SchemaModifier {
587585 }
588586 }
589587 ( schema as any ) [ 'x-oneof-schema' ] = true ;
590- this . logger . info ( `Added x-oneof-property to properties and marked schema with x-oneof-schema` ) ;
588+ logger . info ( `Added x-oneof-property to properties and marked schema with x-oneof-schema` ) ;
591589 } else if ( hasNestedPattern ) {
592590 ( schema as any ) [ 'x-oneof-schema' ] = true ;
593- this . logger . info ( `Marked parent schema with x-oneof-schema (contains nested oneOf pattern)` ) ;
591+ logger . info ( `Marked parent schema with x-oneof-schema (contains nested oneOf pattern)` ) ;
594592 }
595593 }
596594
0 commit comments