我已经安装swagger-parser@3.4.1
并尝试使用parser.validate(" swaggerJson")根据找到的here文件验证我的api但是获取webpack编译问题
这是代码......
SwaggerParser = require('swagger-parser');
validateResult: string;
swaggerSpec ;
constructor(private http: Http, private service: DifferencesService){
let parser = new this.SwaggerParser();
service.getSwaggerSpec().subscribe(
result => { this.swaggerSpec = result;},
error => { console.log(error); }
);
parser.validate(this.swaggerSpec).then(function(api) {
this.validateResult = "Yay! The API is valid.";
})
.catch(function(err) {
this.validateResult = 'Onoes! The API is invalid. ' + err.message;
});
这是错误......
ERROR in ./~/swagger-parser/lib/validate-schema.js
Module not found: Error: Can't resolve 'swagger-schema-official/schema' in 'D:\gitmyworkspace\mywork\pcfdeploy\node_modules\swagger-parser\lib'
@ ./~/swagger-parser/lib/validate-schema.js 6:20-61
@ ./~/swagger-parser/lib/index.js
@ ./src/app/components/swagger-validate.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts
ERROR in ./~/swagger-parser/lib/promise.js
Module not found: Error: Can't resolve 'es6-promise' in 'D:\gitmyworkspace\mywork\pcfdeploy\node_modules\swagger-parser\lib'
@ ./~/swagger-parser/lib/promise.js 4:59-81
@ ./~/swagger-parser/lib/index.js
@ ./src/app/components/swagger-validate.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts
ERROR in ./~/json-schema-ref-parser/lib/promise.js
Module not found: Error: Can't resolve 'es6-promise' in 'D:\gitmyworkspace\mywork\pcfdeploy\node_modules\json-schema-ref-parser\lib'
@ ./~/json-schema-ref-parser/lib/promise.js 4:59-81
@ ./~/json-schema-ref-parser/lib/index.js
@ ./~/swagger-parser/lib/index.js
@ ./src/app/components/swagger-validate.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts
webpack: Failed to compile.