11import * as c from 'chalk' ;
22import * as fs from 'fs' ;
33import * as YAML from 'js-yaml' ;
4+ import { inspect } from 'util' ;
45import { DefinitionGenerator } from './DefinitionGenerator' ;
56import { IDefinitionType , ILog } from './types' ;
67import { merge } from './utils' ;
@@ -129,10 +130,15 @@ export class ServerlessOpenApiDocumentation {
129130 if ( validation . valid ) {
130131 this . log ( `${ c . bold . green ( '[VALIDATION]' ) } OpenAPI valid: ${ c . bold . green ( 'true' ) } \n\n` ) ;
131132 } else {
132- this . log (
133- `${ c . bold . red ( '[VALIDATION]' ) } Failed to validate OpenAPI document: \n\n` +
134- `${ c . bold . green ( 'Path:' ) } ${ JSON . stringify ( validation , null , 2 ) } \n` ,
135- ) ;
133+ this . log ( `${ c . bold . red ( '[VALIDATION]' ) } Failed to validate OpenAPI document: \n\n` ) ;
134+ this . log ( `${ c . bold . green ( 'Path:' ) } ${ JSON . stringify ( validation . context , null , 2 ) } \n` ) ;
135+
136+ for ( const info of validation . error ) {
137+ this . log ( c . grey ( '\n\n--------\n\n' ) ) ;
138+ this . log ( ' ' , info . schemaPath , c . bold . yellow ( info . message ) ) ;
139+ this . log ( c . grey ( '\n\n--------\n\n' ) ) ;
140+ this . log ( `${ inspect ( info , { colors : true , depth : 2 } ) } \n\n` ) ;
141+ }
136142 }
137143
138144 const { definition } = generator ;
@@ -152,6 +158,6 @@ export class ServerlessOpenApiDocumentation {
152158
153159 fs . writeFileSync ( config . file , output ) ;
154160
155- this . log ( `${ c . bold . green ( '[SUCCESS ]' ) } Output file to "${ c . bold . red ( config . file ) } "\n` ) ;
161+ this . log ( `${ c . bold . green ( '[OUTPUT ]' ) } To "${ c . bold . red ( config . file ) } "\n` ) ;
156162 }
157163}
0 commit comments