File tree Expand file tree Collapse file tree 5 files changed +63
-24
lines changed
Expand file tree Collapse file tree 5 files changed +63
-24
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @pactflow/openapi-pact-comparator " : minor
3+ ---
4+
5+ Remove swagger-parser validation as it is very slow
Original file line number Diff line number Diff line change 4141 "license" : " Apache-2.0" ,
4242 "type" : " module" ,
4343 "devDependencies" : {
44- "@apidevtools/swagger-parser" : " 10.1.1" ,
4544 "@changesets/cli" : " 2.28.1" ,
4645 "@eslint/js" : " 9.23.0" ,
4746 "@pactflow/swagger-mock-validator" : " 14.5.0" ,
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ export class Comparator {
3131 this . #config = new Map ( DEFAULT_CONFIG ) ;
3232 this . #oas = oas ;
3333
34+ parseOas ( oas ) ;
35+
3436 const ajvOptions = {
3537 allErrors : true ,
3638 discriminator : true ,
@@ -51,7 +53,6 @@ export class Comparator {
5153
5254 async * compare ( pact : Pact ) : AsyncGenerator < Result > {
5355 if ( ! this . #router) {
54- await parseOas ( this . #oas) ;
5556 for ( const [ key , value ] of Object . entries ( this . #oas. info ) ) {
5657 if ( key . startsWith ( "x-opc-config-" ) ) {
5758 this . #config. set ( key . substring ( 13 ) as ConfigKeys , value ) ;
Original file line number Diff line number Diff line change 11import type { OpenAPIV2 , OpenAPIV3 } from "openapi-types" ;
2- import SwaggerParser from "@apidevtools/swagger-parser" ;
3- import { cloneDeep } from "lodash-es" ;
42
53const isSwagger2 = ( oas : OpenAPIV2 . Document ) : boolean =>
64 Object . prototype . hasOwnProperty . call ( oas , "swagger" ) &&
@@ -12,17 +10,15 @@ const isOpenApi3 = (oas: OpenAPIV3.Document): boolean =>
1210 typeof oas . openapi === "string" &&
1311 oas . openapi . indexOf ( "3." ) === 0 ;
1412
15- export const parse = async (
16- oas : OpenAPIV2 . Document | OpenAPIV3 . Document ,
17- ) : Promise < void > => {
13+ export const parse = ( oas : OpenAPIV2 . Document | OpenAPIV3 . Document ) : void => {
1814 if (
1915 ! isSwagger2 ( oas as OpenAPIV2 . Document ) &&
2016 ! isOpenApi3 ( oas as OpenAPIV3 . Document )
2117 ) {
2218 throw new ParserError ( ) ;
2319 }
2420
25- await SwaggerParser . validate ( cloneDeep ( oas ) ) ;
21+ // FIXME: ideally, we validate the document here
2622} ;
2723
2824export class ParserError extends Error {
You can’t perform that action at this time.
0 commit comments