File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 22
33const path = require ( "path" ) ;
44
5+ const {
6+ Config,
7+ lintFromString,
8+ stringifyYaml,
9+ createConfig,
10+ } = require ( "@redocly/openapi-core" ) ;
511const isEqual = require ( "lodash.isequal" ) ;
6- const validator = require ( "oas-validator" ) ;
712const { v4 : uuid } = require ( "uuid" ) ;
813
914const SchemaHandler = require ( "./schemaHandler" ) ;
@@ -971,9 +976,35 @@ class DefinitionGenerator {
971976 }
972977
973978 async validate ( ) {
974- return await validator . validateInner ( this . openAPI , { } ) . catch ( ( err ) => {
979+ const config = await createConfig ( {
980+ apis : { } ,
981+ // styleguide: {
982+ rules : {
983+ spec : "error" ,
984+ "path-parameters-defined" : "error" ,
985+ "operation-2xx-response" : "error" ,
986+ "operation-4xx-response" : "error" ,
987+ "operation-operationId-unique" : "error" ,
988+ "path-declaration-must-exist" : "error" ,
989+ } ,
990+ // },
991+ } ) ;
992+
993+ const apiDesc = stringifyYaml ( this . openAPI ) ;
994+
995+ const results = await lintFromString ( {
996+ source : apiDesc ,
997+ config : config ,
998+ } ) . catch ( ( err ) => {
999+ console . error ( err ) ;
9751000 throw err ;
9761001 } ) ;
1002+
1003+ if ( results . length ) {
1004+ throw results ;
1005+ }
1006+
1007+ return true ;
9771008 }
9781009}
9791010
You can’t perform that action at this time.
0 commit comments