diff --git a/CHANGELOG.md b/CHANGELOG.md index a82f9bc..4c3c74e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [6.0.1](https://github.com/codekie/openapi-examples-validator/compare/v6.0.0...v6.0.1) (2024-11-20) + + +### Bug Fixes + +* update README.md that minimum NodeJS version is 18 now ([eb69b27](https://github.com/codekie/openapi-examples-validator/commit/eb69b278134266341636992edc6c6cab42df6125)) + ## [6.0.0](https://github.com/codekie/openapi-examples-validator/compare/v5.0.0...v6.0.0) (2024-11-20) diff --git a/dist/Dockerfile b/dist/Dockerfile index 32f7af8..095f01c 100644 --- a/dist/Dockerfile +++ b/dist/Dockerfile @@ -1,6 +1,6 @@ FROM node:18.16.0-alpine3.17 -RUN npm install -g openapi-examples-validator@6.0.0 +RUN npm install -g openapi-examples-validator@6.0.1 ENV NODE_OPTIONS="--unhandled-rejections=strict" ENTRYPOINT ["openapi-examples-validator"] diff --git a/dist/cli.js b/dist/cli.js index d236f46..b695905 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1,3 +1,3 @@ #!/usr/bin/env node -(()=>{var e={476:(e,t,r)=>{const a=r(711),{ENOENT:o}=r(184).code,s={jsENOENT:o.code,jsonPathNotFound:"JsonPathNotFound",errorAndErrorsMutuallyExclusive:"ErrorErrorsMutuallyExclusive",parseError:"ParseError",validation:"Validation"};class n{static create(e){const{code:t,message:r,path:o,cause:i}=e,l=t||e.type||s.validation,p={message:r};return s.validation===l||s.errorAndErrorsMutuallyExclusive===l?a(p,e):(o&&a(p,{params:{path:o}}),i&&a(p,i)),new n(l,p)}constructor(e,t={}){Object.assign(this,{type:e,...t})}}e.exports={ApplicationError:n,ErrorType:s}},115:(e,t,r)=>{const a=r(723).version,o=r(858),{validateFile:s,validateExample:n,validateExamplesByMap:i}=r(497),l="true"===process.env.OPENAPI_EXAMPLES_VALIDATOR_TESTS;o.version(a).arguments("").description("Validate embedded examples in OpenAPI-specs (JSON and YAML supported).\n To validate external examples, use the `-s` and `-e` option.\n To pass a mapping-file, to validate multiple external examples, use the `-m` option.").option("-s, --schema-jsonpath ","Path to OpenAPI-schema, to validate the example file against").option("-e, --example-filepath ","file path to example file, to be validated").option("-m, --mapping-filepath ","file path to map, containing schema-paths as key and the file-path(s) to examples as value. If wildcards are used, the parameter has to be put in quotes.").option("-c, --cwd-to-mapping-file","changes to the directory of the mapping-file, before resolving the example's paths. Use this option, if your mapping-files use relative paths for the examples").option("-n, --no-additional-properties","don't allow properties that are not described in the schema").option("-r, --all-properties-required","make all the properties in the schema required").option("-o, --ignore-formats ",'Datatype formats to ignore (to prevent "unknown format" message in the error-console.)').action((async function(e,t){const{schemaJsonpath:r,exampleFilepath:a,mappingFilepath:o,cwdToMappingFile:p,allPropertiesRequired:c}=t,u=!t.additionalProperties,d=function(e){return null!=e&&Array.isArray(e)?1!==e.length||-1===e[0].indexOf("\n")?e:e[0].split("\n").filter((e=>!e.match(/^\s*$/))):e}(t.ignoreFormats);let m;o?(console.log("Validating with mapping file"),m=await i(e,o,{cwdToMappingFile:p,noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})):r&&a?(console.log("Validating single external example"),m=await n(e,r,a,{noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})):(console.log("Validating examples"),m=await s(e,{noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})),function(e){const t=l;if(function(e){const{schemasWithExamples:t,examplesWithoutSchema:r,examplesTotal:a,matchingFilePathsMapping:o}=e,s=[`Schemas with examples found: ${t}`,`Examples without schema found: ${r}`,`Total examples found: ${a}`];null!=o&&s.push(`Matching mapping files found: ${o}`),process.stdout.write(`${s.join("\n")}\n`)}(e.statistics),e.valid)return process.stdout.write("\nNo errors found.\n\n"),void(!t&&process.exit(0));process.stdout.write("\nErrors found.\n\n"),process.stderr.write(JSON.stringify(e.errors,null," ")),!t&&process.exit(1)}(m)})),o.on("--help",(()=>{console.log("\n\n Example for external example-file:\n"),console.log(" $ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json openapi-spec.json\n\n")})),e.exports=o.parseAsync(process.argv)},285:e=>{e.exports={parent:"parent",parentProperty:"parentProperty",path:"path",pointer:"pointer",value:"value"}},600:(e,t,r)=>{const a=r(273),o=r(474),s=/^3\./;e.exports={getImplementation:function(e){return"string"==typeof e.swagger?a:e.openapi&&e.openapi.match(s)?o:null}}},299:(e,t,r)=>{const{applyCallbackToAllObjectModels:a}=r(935);e.exports={setAllPropertiesRequired:function(e,t=[]){a(e,t,(()=>e=>{e.hasOwnProperty("properties")&&(e.required=Object.keys(e.properties))}))}}},935:(e,t,r)=>{const{JSONPath:a}=r(940),o=r(285);function s(e,t,r=o.path,s){return a({json:e,path:t,flatten:!0,resultType:r,callback:s})}e.exports={applyCallbackToAllObjectModels:function(e,t,r){const a=new Set;s(e,"$..schema..").forEach((e=>{(function(e){if(!e.match(/\['properties']$/))return;const t=e.match(/(?{s(e,r).forEach((e=>{for(const r of t)r.startsWith(e)&&t.delete(r)}))}))}(e,a,t);for(const t of a){const a=r(t);s(e,t,o.value,((e,t,r)=>{var o;("object"===(o=e).type||o.properties)&&a(e,t,r)}))}}}},305:(e,t,r)=>{const{applyCallbackToAllObjectModels:a}=r(935);e.exports={setNoAdditionalProperties:function(e,t=[]){const r=new RegExp("(?t=>{r.test(e)?console.warn(`"additionalProperties" flag not set for ${e} because it has a parent with a JSON-schema combiner keyword.`):o.some((e=>t.hasOwnProperty(e)))?console.warn(`"additionalProperties" flag not set for ${e} because it contains JSON-schema combiner keyword.`):t.hasOwnProperty("additionalProperties")||(t.additionalProperties=!1)}))}};const o=["oneOf","allOf","anyOf","not"]},273:(e,t,r)=>{const a=r(984),{setAllPropertiesRequired:o}=r(299),{setNoAdditionalProperties:s}=r(305);function n(){return["$..examples[?(@property.match(/[/+]json/))]"]}e.exports={buildValidationMap:function(e){return e.reduce(((e,t)=>{const r=function(e){const t=e.split("/"),r=t.lastIndexOf("examples");return t.splice(r,t.length-r,"schema"),t.join("/")}(t);return e[r]=(e[r]||new Set).add(t),e}),{})},getJsonPathsToExamples:n,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const n=a(e);return t&&s(n,["$..examples[?(@property.match(/[/+]json/))]"]),r&&o(n,["$..examples[?(@property.match(/[/+]json/))]"]),n}}},474:(e,t,r)=>{const a=r(984),{ApplicationError:o,ErrorType:s}=r(476),{setAllPropertiesRequired:n}=r(299),{setNoAdditionalProperties:i}=r(305),l="$..responses..content[?(@property.match(/[/+]json/))]",p="$..requestBody.content[?(@property.match(/[/+]json/))]",c=".example",u=".examples.*.value",d=`${l}${c}`,m=`${l}${u}`,h=`${p}${c}`,f=`${p}${u}`,g="single";function x(){return[d,m,"$..parameters..example","$..parameters..examples.*.value",h,f]}e.exports={buildValidationMap:function(e){const t=new Map;return e.reduce(((e,r)=>{const{pathSchemaAsArray:a,exampleType:n}=function(e){const t=e.split("/"),r=t.lastIndexOf("example"),a=r>-1?g:"multi",o=a===g?r:t.lastIndexOf("examples");return t.splice(o,t.length-o,"schema"),{exampleType:a,pathSchemaAsArray:t}}(r),i=a.join("/"),l=t.get(i);return l&&l!==n&&function(e){const t=e.slice(0,e.length-1);throw o.create({type:s.errorAndErrorsMutuallyExclusive,message:'Properties "error" and "errors" are mutually exclusive',params:{pathContext:t.join("/")}})}(a),t.set(i,n),e[i]=(e[i]||new Set).add(r),e}),{})},getJsonPathsToExamples:x,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const o=a(e);return t&&i(o,x()),r&&n(o,x()),o}}},497:(e,t,r)=>{const a=r(711),o=r(149),s=r(668),n=r(258),i=r(896),l=r(928),p=r(410),c=r(496),{JSONPath:u}=r(940),d=r(694),{createError:m}=r(184).custom,h=r(285),{getValidatorFactory:f,compileValidate:g}=r(631),x=r(600),{ApplicationError:y,ErrorType:v}=r(476),{createValidationResponse:P,dereferenceJsonSchema:b}=r(427),w=Symbol("internal"),j="schemasWithExamples",E=["yaml","yml"],A=m(v.jsonPathNotFound);async function F(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a}={}){const o=x.getImplementation(e);e=await d.dereference(e),e=o.prepare(e,{noAdditionalProperties:t,allPropertiesRequired:a});let s=o.getJsonPathsToExamples().reduce(((t,r)=>t.concat(S(r,e))),[]);return function({impl:e},t,r,{ignoreFormats:a}){const o=T(),s={valid:!0,statistics:o,errors:[]},n=R(r,{ignoreFormats:a});let i;try{i=e.buildValidationMap(t)}catch(e){if(!(e instanceof y))throw e;return s.valid=!1,s.errors.push(e),s}return Object.keys(i).forEach((e=>{!function({openapiSpec:e,createValidator:t,schemaPointer:r,validationMap:a,statistics:o,validationResult:s}){const n=s.errors;a[r].forEach((a=>{const i=M(a,e),l=V(r,e,!0),p=N({createValidator:t,schema:l,example:i,statistics:o}).map((e=>(e.examplePath=a,e)));p.length&&(s.valid=!1,n.splice(n.length-1,0,...p))}))}({openapiSpec:r,createValidator:n,schemaPointer:e,validationMap:i,statistics:o,validationResult:s})})),s}({impl:o},s,e,{ignoreFormats:r})}async function O(e){const t=function(e){const t=e.split(".").pop();return E.includes(t)}(e);let r;if(t)try{r=c.parse(i.readFileSync(e,"utf-8"))}catch(e){const{name:t,message:r}=e;throw new y(v.parseError,{message:`${t}: ${r}`})}else r=JSON.parse(i.readFileSync(e,"utf-8"));return await b(e,r)}function q(e){const t=T(),r=e(t);return P({errors:r,statistics:t})}function $(e,t,r,{cwdToMappingFile:a=!1,dirPathMapExternalExamples:n,ignoreFormats:c}){return s(Object.entries(t),(([t,u])=>{let d=null;try{d=V(k(t,e),e)}catch(e){return y.create(e)}return s(o([u]),(t=>{let o=[];try{const e=a?l.join(n,t):t,r=p.sync(e);if(0===r.length)return[y.create({type:v.jsENOENT,message:`No such file or directory: '${e}'`,path:e})];for(const e of r)o.push({path:l.normalize(e),content:JSON.parse(i.readFileSync(e,"utf-8"))})}catch(e){return[y.create(e)]}return s(o,(t=>N({createValidator:R(e,{ignoreFormats:c}),schema:d,example:t.content,statistics:r,filePathExample:t.path})))}))}))}function S(e,t){return u({json:t,path:e,resultType:h.pointer})}function k(e,t){const r=S(e,t);return 0===r.length&&J(e),r.length>1?[y.create({type:v.jsonPathNotFound,message:`Path to schema cannot identify unique schema: '${e}'`,path:e})]:r[0]}function T(){const e={[w]:{[j]:new Set},examplesTotal:0,examplesWithoutSchema:0};return Object.defineProperty(e,j,{enumerable:!0,get:()=>e[w][j].size}),e}function M(e,t){try{return n.get(t,e)}catch(e){return}}function N({createValidator:e,schema:t,example:r,statistics:a,filePathExample:o}){const s=[];if(a.examplesTotal++,!t)return a.examplesWithoutSchema++,s;a[w][j].add(t);const n=g(e(),t);return n(r)?s:s.concat(...n.errors.map(y.create)).map((e=>o?(e.exampleFilePath=o,e):e))}function R(e,{ignoreFormats:t}){return f(e,{schemaId:"auto",discriminator:!0,strict:!1,allErrors:!0,formats:t&&t.reduce(((e,t)=>(e[t]=()=>!0,e)),{})})}function V(e,t,r=!1){const a=M(e,t);return r||a||J(e),a}function J(e){throw new A(`Path to schema can't be found: '${e}'`,{params:{path:e}})}e.exports={default:F,validateFile:async function(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a}={}){let o=null;try{o=await O(e)}catch(e){return P({errors:[y.create(e)]})}return F(o,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a})},validateExample:async function(e,t,r,{noAdditionalProperties:a,ignoreFormats:o,allPropertiesRequired:s}={}){let n=null,l=null,p=null;try{n=JSON.parse(i.readFileSync(r,"utf-8")),p=await O(e),p=x.getImplementation(p).prepare(p,{noAdditionalProperties:a,allPropertiesRequired:s}),l=V(k(t,p),p)}catch(e){return P({errors:[y.create(e)]})}return q((e=>N({createValidator:R(p,{ignoreFormats:o}),schema:l,example:n,statistics:e,filePathExample:r})))},validateExamplesByMap:async function(e,t,{cwdToMappingFile:r,noAdditionalProperties:o,ignoreFormats:s,allPropertiesRequired:n}={}){let c=0;const u=p.sync(t,{nonull:!0});let d=[];for(const t of u){let a=null,p=null;try{a=JSON.parse(i.readFileSync(t,"utf-8")),p=await O(e),p=x.getImplementation(p).prepare(p,{noAdditionalProperties:o,allPropertiesRequired:n})}catch(e){d.push(P({errors:[y.create(e)]}));continue}c++,d.push(q((e=>$(p,a,e,{cwdToMappingFile:r,dirPathMapExternalExamples:l.dirname(t),ignoreFormats:s}).map((e=>Object.assign(e,{mapFilePath:l.normalize(t)}))))))}return a(d.reduce(((e,t)=>{return e?(a=t,P({errors:(r=e).errors.concat(a.errors),statistics:Object.entries(r.statistics).reduce(((e,[t,o])=>j===t?([r,a].forEach((t=>{const r=t.statistics[w][j].values();for(let t of r)e[w][j].add(t)})),e):(e[t]=o+a.statistics[t],e)),T())})):t;var r,a}),null),{statistics:{matchingFilePathsMapping:c}})}}},427:(e,t,r)=>{const a=r(928),o=r(694);e.exports={createValidationResponse:function({errors:e,statistics:t={}}){return{valid:!e.length,statistics:t,errors:e}},dereferenceJsonSchema:async function(e,t){const r=process.cwd();process.chdir(a.dirname(e));const s=await o.dereference(t);return process.chdir(r),s}}},631:(e,t,r)=>{const{JSONPath:a}=r(940),o=r(258),s=r(804),n=r(402),i="$id",l="$..$ref",p="https://www.npmjs.com/package/openapi-examples-validator/defs.json";e.exports={getValidatorFactory:function(e,t){const r=function(e){const t={[i]:p};return a({path:l,json:e,callback(r){if(!r.startsWith("#"))return;const a=r.substring(1),s=o.get(e,a);o.set(t,a,s)}}),t}(e);return()=>{const e=new s(t);return n(e),e.addSchema(r),e}},compileValidate:function(e,t){const r=function(e){const t=Object.assign({},e);return t.$id="https://www.npmjs.com/package/openapi-examples-validator/schema.json",t}(t);let o;a({path:l,json:r,callback(e,t,r){e.startsWith("#")&&(r.parent[r.parentProperty]=`${p}${e}`)}});try{o=e.compile(r)}catch(e){o=()=>{},o.errors=[e]}return o}}},723:e=>{e.exports={name:"openapi-examples-validator",version:"6.0.0",description:"Validates embedded examples in OpenAPI-JSONs",main:"dist/index.js",engines:{node:">=18"},bin:{"openapi-examples-validator":"dist/cli.js"},"standard-version":{scripts:{postchangelog:"npm run release:create-dockerfile && npm run release:stage-artifacts"}},scripts:{"start-dev":"babel-node src/cli",build:"npm run build:clean && npm run build:webpack","build:clean":"rimraf dist","build:webpack":"webpack --bail --progress --profile --mode production --config ./webpack/config.babel.js",coverage:'rimraf ./coverage && nyc --reporter=lcov --reporter=text -x "dist/**/*" -x "test/**/*.js" npm test',coveralls:"cat ./coverage/lcov.info | coveralls",test:"npm run build && npm run test:mocha","test-mutations":"stryker run","test:mocha":'mocha --require "./test/util/setup-tests" --recursive "./test/specs/**/*.js"',release:"npm run build && standard-version -a","release:create-dockerfile":"npm run build && node etc/src/build-dockerfile.js","release:stage-artifacts":"git add dist/*"},repository:{type:"git",url:"git+https://github.com/codekie/openapi-examples-validator.git"},keywords:["swagger","openapi","json","validate","examples"],author:"Josua Amann",license:"MIT",bugs:{url:"https://github.com/codekie/openapi-examples-validator/issues"},homepage:"https://github.com/codekie/openapi-examples-validator#readme",devDependencies:{"@babel/cli":"^7.25.9","@babel/core":"^7.26.0","@babel/eslint-parser":"^7.25.9","@babel/node":"^7.26.0","@babel/preset-env":"^7.26.0","@babel/register":"^7.25.9","@stryker-mutator/core":"^8.6.0","@stryker-mutator/mocha-runner":"^8.6.0","babel-loader":"^9.2.1",chai:"^4.3.6","chai-string":"^1.5.0","core-js-pure":"^3.39.0",coveralls:"^3.1.1",eslint:"^8.41.0","eslint-webpack-plugin":"^4.2.0","json-loader":"^0.5.7",mocha:"^10.8.2","mocha-lcov-reporter":"^1.3.0",nyc:"^15.1.0",rimraf:"^5.0.1","standard-version":"^9.5.0","stryker-cli":"^1.0.2",webpack:"^5.96.1","webpack-cli":"^5.1.4"},dependencies:{ajv:"^8.17.1","ajv-draft-04":"^1.0.0","ajv-formats":"^2.1.1",commander:"^6.2.1",errno:"^1.0.0",glob:"^8.1.0","json-pointer":"^0.6.2","json-schema-ref-parser":"^9.0.9","jsonpath-plus":"^10.2.0","lodash.clonedeep":"^4.5.0","lodash.flatmap":"^4.5.0","lodash.flatten":"^4.4.0","lodash.merge":"^4.6.2",yaml:"^2.6.1"}}},804:e=>{"use strict";e.exports=require("ajv-draft-04")},402:e=>{"use strict";e.exports=require("ajv-formats")},858:e=>{"use strict";e.exports=require("commander")},184:e=>{"use strict";e.exports=require("errno")},410:e=>{"use strict";e.exports=require("glob")},258:e=>{"use strict";e.exports=require("json-pointer")},694:e=>{"use strict";e.exports=require("json-schema-ref-parser")},940:e=>{"use strict";e.exports=require("jsonpath-plus")},984:e=>{"use strict";e.exports=require("lodash.clonedeep")},668:e=>{"use strict";e.exports=require("lodash.flatmap")},149:e=>{"use strict";e.exports=require("lodash.flatten")},711:e=>{"use strict";e.exports=require("lodash.merge")},496:e=>{"use strict";e.exports=require("yaml")},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}},t={},r=function r(a){var o=t[a];if(void 0!==o)return o.exports;var s=t[a]={exports:{}};return e[a](s,s.exports,r),s.exports}(115);module.exports=r})(); +(()=>{var e={476:(e,t,r)=>{const a=r(711),{ENOENT:o}=r(184).code,s={jsENOENT:o.code,jsonPathNotFound:"JsonPathNotFound",errorAndErrorsMutuallyExclusive:"ErrorErrorsMutuallyExclusive",parseError:"ParseError",validation:"Validation"};class n{static create(e){const{code:t,message:r,path:o,cause:i}=e,l=t||e.type||s.validation,p={message:r};return s.validation===l||s.errorAndErrorsMutuallyExclusive===l?a(p,e):(o&&a(p,{params:{path:o}}),i&&a(p,i)),new n(l,p)}constructor(e,t={}){Object.assign(this,{type:e,...t})}}e.exports={ApplicationError:n,ErrorType:s}},115:(e,t,r)=>{const a=r(723).version,o=r(858),{validateFile:s,validateExample:n,validateExamplesByMap:i}=r(497),l="true"===process.env.OPENAPI_EXAMPLES_VALIDATOR_TESTS;o.version(a).arguments("").description("Validate embedded examples in OpenAPI-specs (JSON and YAML supported).\n To validate external examples, use the `-s` and `-e` option.\n To pass a mapping-file, to validate multiple external examples, use the `-m` option.").option("-s, --schema-jsonpath ","Path to OpenAPI-schema, to validate the example file against").option("-e, --example-filepath ","file path to example file, to be validated").option("-m, --mapping-filepath ","file path to map, containing schema-paths as key and the file-path(s) to examples as value. If wildcards are used, the parameter has to be put in quotes.").option("-c, --cwd-to-mapping-file","changes to the directory of the mapping-file, before resolving the example's paths. Use this option, if your mapping-files use relative paths for the examples").option("-n, --no-additional-properties","don't allow properties that are not described in the schema").option("-r, --all-properties-required","make all the properties in the schema required").option("-o, --ignore-formats ",'Datatype formats to ignore (to prevent "unknown format" message in the error-console.)').action((async function(e,t){const{schemaJsonpath:r,exampleFilepath:a,mappingFilepath:o,cwdToMappingFile:p,allPropertiesRequired:c}=t,u=!t.additionalProperties,d=function(e){return null!=e&&Array.isArray(e)?1!==e.length||-1===e[0].indexOf("\n")?e:e[0].split("\n").filter((e=>!e.match(/^\s*$/))):e}(t.ignoreFormats);let m;o?(console.log("Validating with mapping file"),m=await i(e,o,{cwdToMappingFile:p,noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})):r&&a?(console.log("Validating single external example"),m=await n(e,r,a,{noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})):(console.log("Validating examples"),m=await s(e,{noAdditionalProperties:u,ignoreFormats:d,allPropertiesRequired:c})),function(e){const t=l;if(function(e){const{schemasWithExamples:t,examplesWithoutSchema:r,examplesTotal:a,matchingFilePathsMapping:o}=e,s=[`Schemas with examples found: ${t}`,`Examples without schema found: ${r}`,`Total examples found: ${a}`];null!=o&&s.push(`Matching mapping files found: ${o}`),process.stdout.write(`${s.join("\n")}\n`)}(e.statistics),e.valid)return process.stdout.write("\nNo errors found.\n\n"),void(!t&&process.exit(0));process.stdout.write("\nErrors found.\n\n"),process.stderr.write(JSON.stringify(e.errors,null," ")),!t&&process.exit(1)}(m)})),o.on("--help",(()=>{console.log("\n\n Example for external example-file:\n"),console.log(" $ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json openapi-spec.json\n\n")})),e.exports=o.parseAsync(process.argv)},285:e=>{e.exports={parent:"parent",parentProperty:"parentProperty",path:"path",pointer:"pointer",value:"value"}},600:(e,t,r)=>{const a=r(273),o=r(474),s=/^3\./;e.exports={getImplementation:function(e){return"string"==typeof e.swagger?a:e.openapi&&e.openapi.match(s)?o:null}}},299:(e,t,r)=>{const{applyCallbackToAllObjectModels:a}=r(935);e.exports={setAllPropertiesRequired:function(e,t=[]){a(e,t,(()=>e=>{e.hasOwnProperty("properties")&&(e.required=Object.keys(e.properties))}))}}},935:(e,t,r)=>{const{JSONPath:a}=r(940),o=r(285);function s(e,t,r=o.path,s){return a({json:e,path:t,flatten:!0,resultType:r,callback:s})}e.exports={applyCallbackToAllObjectModels:function(e,t,r){const a=new Set;s(e,"$..schema..").forEach((e=>{(function(e){if(!e.match(/\['properties']$/))return;const t=e.match(/(?{s(e,r).forEach((e=>{for(const r of t)r.startsWith(e)&&t.delete(r)}))}))}(e,a,t);for(const t of a){const a=r(t);s(e,t,o.value,((e,t,r)=>{var o;("object"===(o=e).type||o.properties)&&a(e,t,r)}))}}}},305:(e,t,r)=>{const{applyCallbackToAllObjectModels:a}=r(935);e.exports={setNoAdditionalProperties:function(e,t=[]){const r=new RegExp("(?t=>{r.test(e)?console.warn(`"additionalProperties" flag not set for ${e} because it has a parent with a JSON-schema combiner keyword.`):o.some((e=>t.hasOwnProperty(e)))?console.warn(`"additionalProperties" flag not set for ${e} because it contains JSON-schema combiner keyword.`):t.hasOwnProperty("additionalProperties")||(t.additionalProperties=!1)}))}};const o=["oneOf","allOf","anyOf","not"]},273:(e,t,r)=>{const a=r(984),{setAllPropertiesRequired:o}=r(299),{setNoAdditionalProperties:s}=r(305);function n(){return["$..examples[?(@property.match(/[/+]json/))]"]}e.exports={buildValidationMap:function(e){return e.reduce(((e,t)=>{const r=function(e){const t=e.split("/"),r=t.lastIndexOf("examples");return t.splice(r,t.length-r,"schema"),t.join("/")}(t);return e[r]=(e[r]||new Set).add(t),e}),{})},getJsonPathsToExamples:n,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const n=a(e);return t&&s(n,["$..examples[?(@property.match(/[/+]json/))]"]),r&&o(n,["$..examples[?(@property.match(/[/+]json/))]"]),n}}},474:(e,t,r)=>{const a=r(984),{ApplicationError:o,ErrorType:s}=r(476),{setAllPropertiesRequired:n}=r(299),{setNoAdditionalProperties:i}=r(305),l="$..responses..content[?(@property.match(/[/+]json/))]",p="$..requestBody.content[?(@property.match(/[/+]json/))]",c=".example",u=".examples.*.value",d=`${l}${c}`,m=`${l}${u}`,h=`${p}${c}`,f=`${p}${u}`,g="single";function x(){return[d,m,"$..parameters..example","$..parameters..examples.*.value",h,f]}e.exports={buildValidationMap:function(e){const t=new Map;return e.reduce(((e,r)=>{const{pathSchemaAsArray:a,exampleType:n}=function(e){const t=e.split("/"),r=t.lastIndexOf("example"),a=r>-1?g:"multi",o=a===g?r:t.lastIndexOf("examples");return t.splice(o,t.length-o,"schema"),{exampleType:a,pathSchemaAsArray:t}}(r),i=a.join("/"),l=t.get(i);return l&&l!==n&&function(e){const t=e.slice(0,e.length-1);throw o.create({type:s.errorAndErrorsMutuallyExclusive,message:'Properties "error" and "errors" are mutually exclusive',params:{pathContext:t.join("/")}})}(a),t.set(i,n),e[i]=(e[i]||new Set).add(r),e}),{})},getJsonPathsToExamples:x,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const o=a(e);return t&&i(o,x()),r&&n(o,x()),o}}},497:(e,t,r)=>{const a=r(711),o=r(149),s=r(668),n=r(258),i=r(896),l=r(928),p=r(410),c=r(496),{JSONPath:u}=r(940),d=r(694),{createError:m}=r(184).custom,h=r(285),{getValidatorFactory:f,compileValidate:g}=r(631),x=r(600),{ApplicationError:y,ErrorType:v}=r(476),{createValidationResponse:P,dereferenceJsonSchema:b}=r(427),w=Symbol("internal"),j="schemasWithExamples",E=["yaml","yml"],A=m(v.jsonPathNotFound);async function F(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a}={}){const o=x.getImplementation(e);e=await d.dereference(e),e=o.prepare(e,{noAdditionalProperties:t,allPropertiesRequired:a});let s=o.getJsonPathsToExamples().reduce(((t,r)=>t.concat(S(r,e))),[]);return function({impl:e},t,r,{ignoreFormats:a}){const o=T(),s={valid:!0,statistics:o,errors:[]},n=R(r,{ignoreFormats:a});let i;try{i=e.buildValidationMap(t)}catch(e){if(!(e instanceof y))throw e;return s.valid=!1,s.errors.push(e),s}return Object.keys(i).forEach((e=>{!function({openapiSpec:e,createValidator:t,schemaPointer:r,validationMap:a,statistics:o,validationResult:s}){const n=s.errors;a[r].forEach((a=>{const i=M(a,e),l=V(r,e,!0),p=N({createValidator:t,schema:l,example:i,statistics:o}).map((e=>(e.examplePath=a,e)));p.length&&(s.valid=!1,n.splice(n.length-1,0,...p))}))}({openapiSpec:r,createValidator:n,schemaPointer:e,validationMap:i,statistics:o,validationResult:s})})),s}({impl:o},s,e,{ignoreFormats:r})}async function O(e){const t=function(e){const t=e.split(".").pop();return E.includes(t)}(e);let r;if(t)try{r=c.parse(i.readFileSync(e,"utf-8"))}catch(e){const{name:t,message:r}=e;throw new y(v.parseError,{message:`${t}: ${r}`})}else r=JSON.parse(i.readFileSync(e,"utf-8"));return await b(e,r)}function q(e){const t=T(),r=e(t);return P({errors:r,statistics:t})}function $(e,t,r,{cwdToMappingFile:a=!1,dirPathMapExternalExamples:n,ignoreFormats:c}){return s(Object.entries(t),(([t,u])=>{let d=null;try{d=V(k(t,e),e)}catch(e){return y.create(e)}return s(o([u]),(t=>{let o=[];try{const e=a?l.join(n,t):t,r=p.sync(e);if(0===r.length)return[y.create({type:v.jsENOENT,message:`No such file or directory: '${e}'`,path:e})];for(const e of r)o.push({path:l.normalize(e),content:JSON.parse(i.readFileSync(e,"utf-8"))})}catch(e){return[y.create(e)]}return s(o,(t=>N({createValidator:R(e,{ignoreFormats:c}),schema:d,example:t.content,statistics:r,filePathExample:t.path})))}))}))}function S(e,t){return u({json:t,path:e,resultType:h.pointer})}function k(e,t){const r=S(e,t);return 0===r.length&&J(e),r.length>1?[y.create({type:v.jsonPathNotFound,message:`Path to schema cannot identify unique schema: '${e}'`,path:e})]:r[0]}function T(){const e={[w]:{[j]:new Set},examplesTotal:0,examplesWithoutSchema:0};return Object.defineProperty(e,j,{enumerable:!0,get:()=>e[w][j].size}),e}function M(e,t){try{return n.get(t,e)}catch(e){return}}function N({createValidator:e,schema:t,example:r,statistics:a,filePathExample:o}){const s=[];if(a.examplesTotal++,!t)return a.examplesWithoutSchema++,s;a[w][j].add(t);const n=g(e(),t);return n(r)?s:s.concat(...n.errors.map(y.create)).map((e=>o?(e.exampleFilePath=o,e):e))}function R(e,{ignoreFormats:t}){return f(e,{schemaId:"auto",discriminator:!0,strict:!1,allErrors:!0,formats:t&&t.reduce(((e,t)=>(e[t]=()=>!0,e)),{})})}function V(e,t,r=!1){const a=M(e,t);return r||a||J(e),a}function J(e){throw new A(`Path to schema can't be found: '${e}'`,{params:{path:e}})}e.exports={default:F,validateFile:async function(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a}={}){let o=null;try{o=await O(e)}catch(e){return P({errors:[y.create(e)]})}return F(o,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:a})},validateExample:async function(e,t,r,{noAdditionalProperties:a,ignoreFormats:o,allPropertiesRequired:s}={}){let n=null,l=null,p=null;try{n=JSON.parse(i.readFileSync(r,"utf-8")),p=await O(e),p=x.getImplementation(p).prepare(p,{noAdditionalProperties:a,allPropertiesRequired:s}),l=V(k(t,p),p)}catch(e){return P({errors:[y.create(e)]})}return q((e=>N({createValidator:R(p,{ignoreFormats:o}),schema:l,example:n,statistics:e,filePathExample:r})))},validateExamplesByMap:async function(e,t,{cwdToMappingFile:r,noAdditionalProperties:o,ignoreFormats:s,allPropertiesRequired:n}={}){let c=0;const u=p.sync(t,{nonull:!0});let d=[];for(const t of u){let a=null,p=null;try{a=JSON.parse(i.readFileSync(t,"utf-8")),p=await O(e),p=x.getImplementation(p).prepare(p,{noAdditionalProperties:o,allPropertiesRequired:n})}catch(e){d.push(P({errors:[y.create(e)]}));continue}c++,d.push(q((e=>$(p,a,e,{cwdToMappingFile:r,dirPathMapExternalExamples:l.dirname(t),ignoreFormats:s}).map((e=>Object.assign(e,{mapFilePath:l.normalize(t)}))))))}return a(d.reduce(((e,t)=>{return e?(a=t,P({errors:(r=e).errors.concat(a.errors),statistics:Object.entries(r.statistics).reduce(((e,[t,o])=>j===t?([r,a].forEach((t=>{const r=t.statistics[w][j].values();for(let t of r)e[w][j].add(t)})),e):(e[t]=o+a.statistics[t],e)),T())})):t;var r,a}),null),{statistics:{matchingFilePathsMapping:c}})}}},427:(e,t,r)=>{const a=r(928),o=r(694);e.exports={createValidationResponse:function({errors:e,statistics:t={}}){return{valid:!e.length,statistics:t,errors:e}},dereferenceJsonSchema:async function(e,t){const r=process.cwd();process.chdir(a.dirname(e));const s=await o.dereference(t);return process.chdir(r),s}}},631:(e,t,r)=>{const{JSONPath:a}=r(940),o=r(258),s=r(804),n=r(402),i="$id",l="$..$ref",p="https://www.npmjs.com/package/openapi-examples-validator/defs.json";e.exports={getValidatorFactory:function(e,t){const r=function(e){const t={[i]:p};return a({path:l,json:e,callback(r){if(!r.startsWith("#"))return;const a=r.substring(1),s=o.get(e,a);o.set(t,a,s)}}),t}(e);return()=>{const e=new s(t);return n(e),e.addSchema(r),e}},compileValidate:function(e,t){const r=function(e){const t=Object.assign({},e);return t.$id="https://www.npmjs.com/package/openapi-examples-validator/schema.json",t}(t);let o;a({path:l,json:r,callback(e,t,r){e.startsWith("#")&&(r.parent[r.parentProperty]=`${p}${e}`)}});try{o=e.compile(r)}catch(e){o=()=>{},o.errors=[e]}return o}}},723:e=>{e.exports={name:"openapi-examples-validator",version:"6.0.1",description:"Validates embedded examples in OpenAPI-JSONs",main:"dist/index.js",engines:{node:">=18"},bin:{"openapi-examples-validator":"dist/cli.js"},"standard-version":{scripts:{postchangelog:"npm run release:create-dockerfile && npm run release:stage-artifacts"}},scripts:{"start-dev":"babel-node src/cli",build:"npm run build:clean && npm run build:webpack","build:clean":"rimraf dist","build:webpack":"webpack --bail --progress --profile --mode production --config ./webpack/config.babel.js",coverage:'rimraf ./coverage && nyc --reporter=lcov --reporter=text -x "dist/**/*" -x "test/**/*.js" npm test',coveralls:"cat ./coverage/lcov.info | coveralls",test:"npm run build && npm run test:mocha","test-mutations":"stryker run","test:mocha":'mocha --require "./test/util/setup-tests" --recursive "./test/specs/**/*.js"',release:"npm run build && standard-version -a","release:create-dockerfile":"npm run build && node etc/src/build-dockerfile.js","release:stage-artifacts":"git add dist/*"},repository:{type:"git",url:"git+https://github.com/codekie/openapi-examples-validator.git"},keywords:["swagger","openapi","json","validate","examples"],author:"Josua Amann",license:"MIT",bugs:{url:"https://github.com/codekie/openapi-examples-validator/issues"},homepage:"https://github.com/codekie/openapi-examples-validator#readme",devDependencies:{"@babel/cli":"^7.25.9","@babel/core":"^7.26.0","@babel/eslint-parser":"^7.25.9","@babel/node":"^7.26.0","@babel/preset-env":"^7.26.0","@babel/register":"^7.25.9","@stryker-mutator/core":"^8.6.0","@stryker-mutator/mocha-runner":"^8.6.0","babel-loader":"^9.2.1",chai:"^4.3.6","chai-string":"^1.5.0","core-js-pure":"^3.39.0",coveralls:"^3.1.1",eslint:"^8.41.0","eslint-webpack-plugin":"^4.2.0","json-loader":"^0.5.7",mocha:"^10.8.2","mocha-lcov-reporter":"^1.3.0",nyc:"^15.1.0",rimraf:"^5.0.1","standard-version":"^9.5.0","stryker-cli":"^1.0.2",webpack:"^5.96.1","webpack-cli":"^5.1.4"},dependencies:{ajv:"^8.17.1","ajv-draft-04":"^1.0.0","ajv-formats":"^2.1.1",commander:"^6.2.1",errno:"^1.0.0",glob:"^8.1.0","json-pointer":"^0.6.2","json-schema-ref-parser":"^9.0.9","jsonpath-plus":"^10.2.0","lodash.clonedeep":"^4.5.0","lodash.flatmap":"^4.5.0","lodash.flatten":"^4.4.0","lodash.merge":"^4.6.2",yaml:"^2.6.1"}}},804:e=>{"use strict";e.exports=require("ajv-draft-04")},402:e=>{"use strict";e.exports=require("ajv-formats")},858:e=>{"use strict";e.exports=require("commander")},184:e=>{"use strict";e.exports=require("errno")},410:e=>{"use strict";e.exports=require("glob")},258:e=>{"use strict";e.exports=require("json-pointer")},694:e=>{"use strict";e.exports=require("json-schema-ref-parser")},940:e=>{"use strict";e.exports=require("jsonpath-plus")},984:e=>{"use strict";e.exports=require("lodash.clonedeep")},668:e=>{"use strict";e.exports=require("lodash.flatmap")},149:e=>{"use strict";e.exports=require("lodash.flatten")},711:e=>{"use strict";e.exports=require("lodash.merge")},496:e=>{"use strict";e.exports=require("yaml")},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}},t={},r=function r(a){var o=t[a];if(void 0!==o)return o.exports;var s=t[a]={exports:{}};return e[a](s,s.exports,r),s.exports}(115);module.exports=r})(); //# sourceMappingURL=cli.js.map \ No newline at end of file diff --git a/dist/cli.js.map b/dist/cli.js.map index 15976ee..244bf98 100644 --- a/dist/cli.js.map +++ b/dist/cli.js.map @@ -1 +1 @@ -{"version":3,"file":"cli.js","mappings":";2BAAA,MACIA,EAAQC,EAAQ,MAChB,OAAEC,GAAWD,EAAAA,KAAAA,KA6BXE,EAAY,CACdC,SAAUF,EAAOG,KACjBC,iBAAkB,mBAClBC,gCAAiC,+BACjCC,WAAY,aACZC,WAAY,cAQhB,MAAMC,EAQF,aAAOC,CAAOC,GACV,MAAM,KAAEP,EAAI,QAAEQ,EAAO,KAAEC,EAAI,MAAEC,GAAUH,EACnCI,EAAOX,GAAQO,EAAII,MAAQb,EAAUM,WACrCQ,EAAU,CAAEJ,WAShB,OARIV,EAAUM,aAAeO,GAAQb,EAAUI,kCAAoCS,EAE/EhB,EAAMiB,EAASL,IAGfE,GAAQd,EAAMiB,EAAS,CAAEC,OAAQ,CAAEJ,UACnCC,GAASf,EAAMiB,EAASF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,QAAUvB,QAAQ,c,uBCAzBsB,EAAOC,QAAUvB,QAAQ,Y,uBCAzBsB,EAAOC,QAAUvB,QAAQ,Q,uBCAzBsB,EAAOC,QAAUvB,QAAQ,O,uBCAzBsB,EAAOC,QAAUvB,QAAQ,e,uBCAzBsB,EAAOC,QAAUvB,QAAQ,yB,uBCAzBsB,EAAOC,QAAUvB,QAAQ,gB,uBCAzBsB,EAAOC,QAAUvB,QAAQ,mB,uBCAzBsB,EAAOC,QAAUvB,QAAQ,iB,uBCAzBsB,EAAOC,QAAUvB,QAAQ,iB,uBCAzBsB,EAAOC,QAAUvB,QAAQ,e,uBCAzBsB,EAAOC,QAAUvB,QAAQ,O,uBCAzBsB,EAAOC,QAAUvB,QAAQ,K,uBCAzBsB,EAAOC,QAAUvB,QAAQ,O,GCCrBiS,EAA2B,CAAC,ECE5BC,EDCJ,SAASC,EAAoBC,GAE5B,IAAIC,EAAeJ,EAAyBG,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa9Q,QAGrB,IAAID,EAAS2Q,EAAyBG,GAAY,CAGjD7Q,QAAS,CAAC,GAOX,OAHAgR,EAAoBH,GAAU9Q,EAAQA,EAAOC,QAAS4Q,GAG/C7Q,EAAOC,OACf,CCnB0B4Q,CAAoB,K","sources":["webpack://openapi-examples-validator/./src/application-error.js","webpack://openapi-examples-validator/./src/cli.js","webpack://openapi-examples-validator/./src/const/result-type.js","webpack://openapi-examples-validator/./src/impl/index.js","webpack://openapi-examples-validator/./src/impl/service/all-properties-required.js","webpack://openapi-examples-validator/./src/impl/service/common.js","webpack://openapi-examples-validator/./src/impl/service/no-additional-properties.js","webpack://openapi-examples-validator/./src/impl/v2/index.js","webpack://openapi-examples-validator/./src/impl/v3/index.js","webpack://openapi-examples-validator/./src/index.js","webpack://openapi-examples-validator/./src/utils/index.js","webpack://openapi-examples-validator/./src/validator.js","webpack://openapi-examples-validator/./package.json","webpack://openapi-examples-validator/external commonjs \"ajv-draft-04\"","webpack://openapi-examples-validator/external commonjs \"ajv-formats\"","webpack://openapi-examples-validator/external commonjs \"commander\"","webpack://openapi-examples-validator/external commonjs \"errno\"","webpack://openapi-examples-validator/external commonjs \"glob\"","webpack://openapi-examples-validator/external commonjs \"json-pointer\"","webpack://openapi-examples-validator/external commonjs \"json-schema-ref-parser\"","webpack://openapi-examples-validator/external commonjs \"jsonpath-plus\"","webpack://openapi-examples-validator/external commonjs \"lodash.clonedeep\"","webpack://openapi-examples-validator/external commonjs \"lodash.flatmap\"","webpack://openapi-examples-validator/external commonjs \"lodash.flatten\"","webpack://openapi-examples-validator/external commonjs \"lodash.merge\"","webpack://openapi-examples-validator/external commonjs \"yaml\"","webpack://openapi-examples-validator/external node-commonjs \"fs\"","webpack://openapi-examples-validator/external node-commonjs \"path\"","webpack://openapi-examples-validator/webpack/bootstrap","webpack://openapi-examples-validator/webpack/startup"],"sourcesContent":["const\n merge = require('lodash.merge'),\n { ENOENT } = require('errno').code;\n\n// TYPEDEFINITIONS\n\n/**\n * @typedef {{}} CustomError\n * @augments Error\n */\n\n/**\n * ApplicationErrorOptions\n * @typedef {{\n * [instancePath]: string,\n * [examplePath]: string,\n * [exampleFilePath]: string,\n * [keyword]: string,\n * [message]: string,\n * [mapFilePath]: string,\n * [params]: {\n * [path]: string,\n * [missingProperty]: string,\n * [type]: string\n * },\n * [schemaPath]: string\n * }} ApplicationErrorOptions\n */\n\n// CONSTANTS\n\nconst ErrorType = {\n jsENOENT: ENOENT.code,\n jsonPathNotFound: 'JsonPathNotFound',\n errorAndErrorsMutuallyExclusive: 'ErrorErrorsMutuallyExclusive',\n parseError: 'ParseError',\n validation: 'Validation'\n};\n\n// CLASSES\n\n/**\n * Unified application-error\n */\nclass ApplicationError {\n /**\n * Factory-function, which is able to consume validation-errors and JS-errors. If a validation error is passed, all\n * properties will be adopted.\n * @param {Error|CustomError} err Javascript-, validation- or custom-error, to create the application-error\n * from\n * @returns {ApplicationError} Unified application-error instance\n */\n static create(err) {\n const { code, message, path, cause } = err, // Certain properties of Javascript-errors\n type = code || err.type || ErrorType.validation, // If `code` is available then it's a Javascript-error\n options = { message };\n if (ErrorType.validation === type || ErrorType.errorAndErrorsMutuallyExclusive === type) {\n // For certain, created error-types, copy all properties\n merge(options, err);\n } else {\n // Copy certain properties of Javascript-error (but only if available)\n path && merge(options, { params: { path } });\n cause && merge(options, cause);\n }\n return new ApplicationError(type, options);\n }\n\n /**\n * Constructor\n * @param {string} type Type of error (see statics)\n * @param {ApplicationErrorOptions} [options] Optional properties\n */\n constructor(type, options = {}) {\n Object.assign(this, {\n type,\n ...options\n });\n }\n}\n\n// PUBLIC API\n\nmodule.exports = {\n ApplicationError,\n ErrorType\n};\n","// Shebang will be added by webpack\n//#!/usr/bin/env node --harmony\n\n/**\n * Command Line Interface for the validator\n */\n\nconst\n VERSION = require('../package.json').version,\n program = require('commander'),\n { validateFile, validateExample, validateExamplesByMap } = require('./index');\n\n// FOR AUTOMATED TESTS\n\nconst ENV_TEST = process.env.OPENAPI_EXAMPLES_VALIDATOR_TESTS === 'true';\n\n// DEFINE CLI\n\nprogram\n .version(VERSION)\n .arguments('')\n .description('Validate embedded examples in OpenAPI-specs (JSON and YAML supported).\\n'\n + ' To validate external examples, use the `-s` and `-e` option.\\n'\n + ' To pass a mapping-file, to validate multiple external examples, use the `-m` option.')\n .option('-s, --schema-jsonpath ', 'Path to OpenAPI-schema, to validate the example file against')\n .option('-e, --example-filepath ', 'file path to example file, to be validated')\n .option('-m, --mapping-filepath ', 'file path to map, containing schema-paths as key and the'\n + ' file-path(s) to examples as value. If wildcards are used, the parameter has to be put in quotes.')\n .option('-c, --cwd-to-mapping-file', \"changes to the directory of the mapping-file, before resolving the example's\"\n + ' paths. Use this option, if your mapping-files use relative paths for the examples')\n .option('-n, --no-additional-properties', 'don\\'t allow properties that are not described in the schema')\n .option('-r, --all-properties-required', 'make all the properties in the schema required')\n .option('-o, --ignore-formats ', 'Datatype formats to ignore '\n + '(to prevent \"unknown format\" message in the error-console.)')\n .action(processAction);\nprogram.on('--help', () => {\n console.log('\\n\\n Example for external example-file:\\n');\n console.log(' $ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json'\n + ' openapi-spec.json\\n\\n');\n});\n// Execute and export promise (for automated tests)\nmodule.exports = program.parseAsync(process.argv);\n\n// IMPLEMENTATION DETAILS\n\nasync function processAction(filepath, options) {\n const { schemaJsonpath, exampleFilepath, mappingFilepath, cwdToMappingFile, allPropertiesRequired } = options,\n noAdditionalProperties = !options.additionalProperties,\n ignoreFormats = _prepareIgnoreFormats(options.ignoreFormats);\n let result;\n if (mappingFilepath) {\n console.log('Validating with mapping file');\n result = await validateExamplesByMap(filepath, mappingFilepath, {\n cwdToMappingFile,\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n } else if (schemaJsonpath && exampleFilepath) {\n console.log('Validating single external example');\n result = await validateExample(filepath, schemaJsonpath, exampleFilepath, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n } else {\n console.log('Validating examples');\n result = await validateFile(filepath, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n }\n _handleResult(result);\n}\n\nfunction _handleResult(result) {\n const noExit = ENV_TEST;\n _printStatistics(result.statistics);\n if (result.valid) {\n process.stdout.write('\\nNo errors found.\\n\\n');\n !noExit && process.exit(0);\n return;\n }\n process.stdout.write('\\nErrors found.\\n\\n');\n process.stderr.write(JSON.stringify(result.errors, null, ' '));\n !noExit && process.exit(1);\n}\n\nfunction _printStatistics(statistics) {\n const {\n schemasWithExamples,\n examplesWithoutSchema,\n examplesTotal,\n matchingFilePathsMapping\n } = statistics,\n strStatistics = [\n `Schemas with examples found: ${ schemasWithExamples }`,\n `Examples without schema found: ${ examplesWithoutSchema }`,\n `Total examples found: ${ examplesTotal }`\n ];\n if (matchingFilePathsMapping != null) {\n strStatistics.push(`Matching mapping files found: ${ matchingFilePathsMapping }`);\n }\n process.stdout.write(`${ strStatistics.join('\\n') }\\n`);\n}\n\nfunction _prepareIgnoreFormats(ignoreFormats) {\n if (ignoreFormats == null || !Array.isArray(ignoreFormats)) { return ignoreFormats; }\n if (ignoreFormats.length !== 1) { return ignoreFormats; }\n // If only one argument has been passed, with all formats separated by newlines\n if (ignoreFormats[0].indexOf('\\n') === -1) { return ignoreFormats; }\n return ignoreFormats[0].split('\\n').filter(entry => !entry.match(/^\\s*$/));\n}\n","module.exports = {\n parent: 'parent',\n parentProperty: 'parentProperty',\n path: 'path',\n pointer: 'pointer',\n value: 'value'\n};\n","/**\n * Entry point for logic that only applies to specific versions of the OpenAPI-spec\n */\n\nconst implV2 = require('./v2/index'),\n implV3 = require('./v3/index');\n\nconst REGEX__OPEN_API = /^3\\./;\n\nmodule.exports = {\n getImplementation\n};\n\n/**\n * Get the version-specific implementation for the OpenAPI-spec. Currently v2 and v3 are supported\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {Object|null}\n */\nfunction getImplementation(openapiSpec) {\n if (typeof openapiSpec.swagger === 'string') {\n return implV2;\n }\n if (openapiSpec.openapi && openapiSpec.openapi.match(REGEX__OPEN_API)) {\n return implV3;\n }\n return null;\n}\n","const { applyCallbackToAllObjectModels } = require('./common');\n\nmodule.exports = {\n setAllPropertiesRequired\n};\n\n/**\n * Sets all properties of each object to required\n * @param {Object} openApiSpec The to-be-modified schema\n * @param {Array.} [examplePaths=[]] The paths to the examples, which's content must not be modified\n */\nfunction setAllPropertiesRequired(openApiSpec, examplePaths = []) {\n applyCallbackToAllObjectModels(openApiSpec, examplePaths,\n () => {\n return (value) => {\n if (value.hasOwnProperty('properties')) {\n value.required = Object.keys(value.properties);\n }\n };\n });\n}\n","const { JSONPath: jsonPath } = require('jsonpath-plus'),\n ResultType = require('../../const/result-type');\n\nmodule.exports = {\n applyCallbackToAllObjectModels\n};\n\n/**\n * @typedef {{\n * path: String,\n * value: Object,\n * parent: Object,\n * parentProperty: String,\n * hasArrExpr: Boolean\n * }} JsonPathMatchData\n */\n\n/**\n * Callback that is applied to a JSONPath-match.\n * @callback JsonPathMatchCallback\n * @param {Object} value Value of the matched property\n * @param {String} resultType Result-type of the query\n * @param {JsonPathMatchData} data Object that contains additional data to the match\n */\n\n/**\n * Function to build a callback that is applied to a JSONPath-match.\n * @callback JsonPathMatchCallbackBuilder\n * @param {string} jsPath Path to the property that matched\n * @return {JsonPathMatchCallback} Callback that is applied to a JSONPath-match\n */\n\n/**\n * Apply the input rule to all models of type object in the input openApiSpec\n * @param {Object} openApiSpec The to-be-modified schema\n * @param {Array.} [examplePaths] The paths to the examples, which's content must not be modified\n * @param {JsonPathMatchCallbackBuilder} [matchCallbackBuilder] Function to build a callback\n * that will be called on each match\n */\nfunction applyCallbackToAllObjectModels(openApiSpec, examplePaths, matchCallbackBuilder) {\n // Find all matches\n const paths = new Set();\n _find(openApiSpec, '$..schema..')\n .forEach(match => {\n if (_isPropertiesDefinition(match)) { return; }\n paths.add(match);\n });\n // Exclude examples\n _excludeExamples(openApiSpec, paths, examplePaths);\n // Set flag\n for (const jsPath of paths) {\n const callback = matchCallbackBuilder(jsPath);\n _find(openApiSpec, jsPath, ResultType.value, (result, resultType, data) => {\n if (!_isObjectDefinition(result)) { return; }\n callback(result, resultType, data);\n });\n }\n}\n\n/**\n * Find matching elements in JSON.\n * @param {Object} json JSON to be searched\n * @param {String} path JSON-path to search\n * @param {String} [resultType=\"path\"] Result-type of the query\n * @param {JsonPathMatchCallback} [callback] Function to be called on a match\n * @returns {any} Result of the query, depending on the `resultType`\n * @private\n */\nfunction _find(json, path, resultType = ResultType.path, callback) {\n return jsonPath({\n json,\n path,\n flatten: true,\n resultType,\n callback\n });\n}\n\n/**\n * Remove JSON-paths from `paths` that are included in `examplePaths`\n * @param {Object} openApiSpec Open-API spec to search in\n * @param {Set.} paths Paths where the examples have to be removed from\n * @param {Array.} examplePaths JSON-paths of the examples\n * @private\n */\nfunction _excludeExamples(openApiSpec, paths, examplePaths) {\n examplePaths\n .forEach(examplePath => {\n _find(openApiSpec, examplePath)\n .forEach(exampleMatch => {\n for (const jsPath of paths) {\n jsPath.startsWith(exampleMatch) && paths.delete(jsPath);\n }\n });\n });\n}\n\nfunction _isPropertiesDefinition(path) {\n // Path has to end with `properties`\n if (!path.match(/\\['properties']$/)) { return; }\n // Every second consecutive `properties` actually is not a property-definition, but a property itself\n const consecutiveMatch = path.match(/(?} [examplePaths=[]] The paths to the examples, which's content must not be modified\n */\nfunction setNoAdditionalProperties(openApiSpec, examplePaths = []) {\n // Match all combiner keywords that are not preceded by a 'properties' keyword.\n // This allow to have objects that have as property name one of the combiner keywords.\n const hasJsonCombinerParentRegex\n = new RegExp('(? {\n return (schema) => {\n // Exclude schema that have a JSON combiner as parent\n if (hasJsonCombinerParentRegex.test(path)) {\n console.warn('\"additionalProperties\" flag not set '\n + `for ${path} because it has a parent with a JSON-schema combiner keyword.`);\n return;\n }\n // Exclude schema that contains a JSON combiner\n if (JSON_SCHEMA_COMBINERS.some((combiner) => schema.hasOwnProperty(combiner))) {\n console.warn('\"additionalProperties\" flag not set '\n + `for ${path} because it contains JSON-schema combiner keyword.`);\n return;\n }\n // Exclude schema that already contains additionalProperties\n if (schema.hasOwnProperty('additionalProperties')) {\n return;\n }\n schema.additionalProperties = false;\n };\n });\n}\n","/**\n * Contains validation-logic that is specific to V2 of the OpenAPI-spec\n */\n\nconst cloneDeep = require('lodash.clonedeep'),\n { setAllPropertiesRequired } = require('../service/all-properties-required'),\n { setNoAdditionalProperties } = require('../service/no-additional-properties');\n\n// CONSTANTS\n\nconst PATH__EXAMPLES = '$..examples[?(@property.match(/[\\/+]json/))]',\n PROP__SCHEMA = 'schema',\n PROP__EXAMPLES = 'examples';\n\nmodule.exports = {\n buildValidationMap,\n getJsonPathsToExamples,\n prepare\n};\n\n// IMPLEMENTATION DETAILS\n\n/**\n * Get the JSONPaths to the examples\n * @returns {Array.} JSONPaths to the examples\n */\nfunction getJsonPathsToExamples() { return [PATH__EXAMPLES]; }\n\n\n\n/**\n * Builds a map with the json-pointers to the response-schema as key and the json-pointers to the examples, as value.\n * The pointer of the schema is derived from the pointer to the example and doesn't necessarily mean\n * that the schema actually exists.\n * @param {Array.} pathsExamples Paths to the examples\n * @returns {Object.} Map with schema-pointers as key and example-pointers as value\n * @private\n */\nfunction buildValidationMap(pathsExamples) {\n return pathsExamples.reduce((validationMap, pathExample) => {\n const pathSchema = _getSchemaPointerOfExample(pathExample);\n validationMap[pathSchema] = (validationMap[pathSchema] || new Set())\n .add(pathExample);\n return validationMap;\n }, {});\n}\n\n/**\n * Pre-processes the OpenAPI-spec, for further use.\n * The passed spec won't be modified. If a modification happens, a modified copy will be returned.\n * @param {Object} openapiSpec The OpenAPI-spec as JSON-schema\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @return {Object} The prepared OpenAPI-spec\n */\nfunction prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired } = {}) {\n const openapiSpecCopy = cloneDeep(openapiSpec);\n noAdditionalProperties && setNoAdditionalProperties(openapiSpecCopy, getJsonPathsToExamples());\n allPropertiesRequired && setAllPropertiesRequired(openapiSpecCopy, getJsonPathsToExamples());\n return openapiSpecCopy;\n}\n\n/**\n * Gets a JSON-pointer to the corresponding response-schema, based on a JSON-pointer to an example.\n * @param {String} examplePointer JSON-pointer to example\n * @returns {String} JSON-pointer to the corresponding response-schema\n * @private\n */\nfunction _getSchemaPointerOfExample(examplePointer) {\n const pathSegs = examplePointer.split('/'),\n idxExamples = pathSegs.lastIndexOf(PROP__EXAMPLES);\n pathSegs.splice(idxExamples, pathSegs.length - idxExamples, PROP__SCHEMA);\n return pathSegs.join('/');\n}\n","/**\n * Contains validation-logic that is specific to V3 of the OpenAPI-spec\n */\n\nconst cloneDeep = require('lodash.clonedeep'),\n { ApplicationError, ErrorType } = require('../../application-error'),\n { setAllPropertiesRequired } = require('../service/all-properties-required'),\n { setNoAdditionalProperties } = require('../service/no-additional-properties');\n\n// CONSTANTS\n\nconst RESPONSES = '$..responses..content[?(@property.match(/[\\/+]json/))]';\nconst REQUEST = '$..requestBody.content[?(@property.match(/[\\/+]json/))]';\nconst SINGLE_EXAMPLE = '.example';\nconst MANY_EXAMPLES = '.examples.*.value';\n\nconst PATH__EXAMPLE = `${RESPONSES}${SINGLE_EXAMPLE}`,\n PATH__EXAMPLES = `${RESPONSES}${MANY_EXAMPLES}`,\n PATH__EXAMPLE__PARAMETER = '$..parameters..example',\n PATH__EXAMPLES__PARAMETER = '$..parameters..examples.*.value',\n PATH__EXAMPLE__REQUEST_BODY = `${REQUEST}${SINGLE_EXAMPLE}`,\n PATH__EXAMPLES__REQUEST_BODY = `${REQUEST}${MANY_EXAMPLES}`,\n PROP__SCHEMA = 'schema',\n PROP__EXAMPLE = 'example',\n PROP__EXAMPLES = 'examples';\n\nconst ExampleType = {\n single: 'single',\n multi: 'multi'\n};\n\n// PUBLIC API\n\nmodule.exports = {\n buildValidationMap,\n getJsonPathsToExamples,\n prepare\n};\n\n// IMPLEMENTATION DETAILS\n\n/**\n * Get the JSONPaths to the examples\n * @returns {Array.} JSONPaths to the examples\n */\nfunction getJsonPathsToExamples() {\n return [\n PATH__EXAMPLE,\n PATH__EXAMPLES,\n PATH__EXAMPLE__PARAMETER,\n PATH__EXAMPLES__PARAMETER,\n PATH__EXAMPLE__REQUEST_BODY,\n PATH__EXAMPLES__REQUEST_BODY\n ];\n}\n\n/**\n * Builds a map with the json-pointers to the response-schema as key and the json-pointers to the examples, as value.\n * The pointer of the schema is derived from the pointer to the example and doesn't necessarily mean\n * that the schema actually exists.\n * @param {Array.} pathsExamples Paths to the examples\n * @returns {Object.} Map with schema-pointers as key and example-pointers as value\n * @private\n */\nfunction buildValidationMap(pathsExamples) {\n const exampleTypesOfSchemas = new Map();\n return pathsExamples.reduce((validationMap, pathExample) => {\n const { pathSchemaAsArray, exampleType } = _getSchemaPointerOfExample(pathExample),\n pathSchema = pathSchemaAsArray.join('/'),\n exampleTypeOfSchema = exampleTypesOfSchemas.get(pathSchema);\n if (exampleTypeOfSchema) {\n exampleTypeOfSchema !== exampleType && _throwMutuallyExclusiveError(pathSchemaAsArray);\n }\n exampleTypesOfSchemas.set(pathSchema, exampleType);\n validationMap[pathSchema] = (validationMap[pathSchema] || new Set())\n .add(pathExample);\n return validationMap;\n }, {});\n}\n\n/**\n * Pre-processes the OpenAPI-spec, for further use.\n * The passed spec won't be modified. If a modification happens, a modified copy will be returned.\n * @param {Object} openapiSpec The OpenAPI-spec as JSON-schema\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @return {Object} The prepared OpenAPI-spec\n */\nfunction prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired } = {}) {\n const openapiSpecCopy = cloneDeep(openapiSpec);\n noAdditionalProperties && setNoAdditionalProperties(openapiSpecCopy, getJsonPathsToExamples());\n allPropertiesRequired && setAllPropertiesRequired(openapiSpecCopy, getJsonPathsToExamples());\n return openapiSpecCopy;\n}\n\n/**\n * Gets a JSON-pointer to the corresponding response-schema, based on a JSON-pointer to an example.\n *\n * It is assumed that the JSON-pointer to the example is valid and existing.\n * @param {String} examplePointer JSON-pointer to example\n * @returns {{\n * exampleType: ExampleType,\n * pathSchema: String\n * }} JSON-path to the corresponding response-schema\n * @private\n */\nfunction _getSchemaPointerOfExample(examplePointer) {\n const pathSegs = examplePointer.split('/'),\n idxExample = pathSegs.lastIndexOf(PROP__EXAMPLE),\n /** @type ExampleType */\n exampleType = idxExample > -1\n ? ExampleType.single\n : ExampleType.multi,\n idxExamples = exampleType === ExampleType.single\n ? idxExample\n : pathSegs.lastIndexOf(PROP__EXAMPLES);\n pathSegs.splice(idxExamples, pathSegs.length - idxExamples, PROP__SCHEMA);\n return {\n exampleType,\n pathSchemaAsArray: pathSegs\n };\n}\n\n\n/**\n * Checks if only `example` or `examples` is set for the schema, as they are mutually exclusive by OpenAPI-spec.\n * @param {Array.} pathSchemaAsArray JSON-path to the Schema, as JSON-path-array\n * @throws ApplicationError if both are set\n * @private\n */\nfunction _throwMutuallyExclusiveError(pathSchemaAsArray) {\n const pathContextAsArray = pathSchemaAsArray.slice(0, pathSchemaAsArray.length - 1); // Strip `schema` away\n throw ApplicationError.create({\n type: ErrorType.errorAndErrorsMutuallyExclusive,\n message: 'Properties \"error\" and \"errors\" are mutually exclusive',\n params: {\n pathContext: pathContextAsArray.join('/')\n }\n });\n}\n","/**\n * Entry-point for the validator-API\n */\n\nconst\n merge = require('lodash.merge'),\n flatten = require('lodash.flatten'),\n flatMap = require('lodash.flatmap'),\n jsonPointer = require('json-pointer'),\n fs = require('fs'),\n path = require('path'),\n glob = require('glob'),\n yaml = require('yaml'),\n { JSONPath: jsonPath } = require('jsonpath-plus'),\n refParser = require('json-schema-ref-parser'),\n { createError } = require('errno').custom,\n ResultType = require('./const/result-type'),\n { getValidatorFactory, compileValidate } = require('./validator'),\n Determiner = require('./impl'),\n { ApplicationError, ErrorType } = require('./application-error'),\n { createValidationResponse, dereferenceJsonSchema } = require('./utils');\n\n// CONSTANTS\n\nconst SYM__INTERNAL = Symbol('internal'),\n PROP__SCHEMAS_WITH_EXAMPLES = 'schemasWithExamples',\n FILE_EXTENSIONS__YAML = [\n 'yaml',\n 'yml'\n ];\n\n// STATICS\n\n/**\n * ErrorJsonPathNotFound\n * @typedef {{\n * cause: {\n * [params]: {\n * [path]: string\n * }\n * }\n * }} ErrorJsonPathNotFound\n * @augments CustomError\n */\n\n/**\n * @constructor\n * @augments CustomError\n * @returns {ErrorJsonPathNotFound}\n */\nconst ErrorJsonPathNotFound = createError(ErrorType.jsonPathNotFound);\n\n// PUBLIC API\n\nmodule.exports = {\n 'default': validateExamples,\n validateFile,\n validateExample,\n validateExamplesByMap\n};\n\n// IMPLEMENTATION DETAILS\n\n// Type definitions\n\n/**\n * ValidationStatistics\n * @typedef {{\n * schemasWithExamples: number,\n * examplesTotal: number,\n * examplesWithoutSchema: number,\n * [matchingFilePathsMapping]: number\n * }} ValidationStatistics\n */\n\n/**\n * ValidationResponse\n * @typedef {{\n * valid: boolean,\n * statistics: ValidationStatistics,\n * errors: Array.\n * }} ValidationResponse\n */\n\n/**\n * @callback ValidationHandler\n * @param {ValidationStatistics} statistics\n * @returns {Array.}\n */\n\n// Public\n\n/**\n * Validates OpenAPI-spec with embedded examples.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExamples(openapiSpec, { noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}) {\n const impl = Determiner.getImplementation(openapiSpec);\n openapiSpec = await refParser.dereference(openapiSpec);\n openapiSpec = impl.prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n let pathsExamples = impl.getJsonPathsToExamples()\n .reduce((res, pathToExamples) => {\n return res.concat(_pathToPointer(pathToExamples, openapiSpec));\n }, []);\n return _validateExamplesPaths({ impl }, pathsExamples, openapiSpec, { ignoreFormats });\n}\n\n/**\n * Validates OpenAPI-spec with embedded examples.\n * @param {string} filePath File-path to the OpenAPI-spec\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateFile(filePath, { noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}) {\n let openapiSpec = null;\n try {\n openapiSpec = await _parseSpec(filePath);\n } catch (err) {\n return createValidationResponse({ errors: [ApplicationError.create(err)] });\n }\n return validateExamples(openapiSpec, { noAdditionalProperties, ignoreFormats, allPropertiesRequired });\n}\n\n/**\n * Validates examples by mapping-files.\n * @param {string} filePathSchema File-path to the OpenAPI-spec\n * @param {string} globMapExternalExamples File-path (globs are supported) to the mapping-file containing JSON-\n * paths to schemas as key and a single file-path or Array of file-paths\n * to external examples\n * @param {boolean} [cwdToMappingFile=false] Change working directory for resolving the example-paths (relative to\n * the mapping-file)\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExamplesByMap(filePathSchema, globMapExternalExamples,\n { cwdToMappingFile, noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}\n) {\n let matchingFilePathsMapping = 0;\n const filePathsMaps = glob.sync(\n globMapExternalExamples,\n // Using `nonull`-option to explicitly create an app-error if there's no match for `globMapExternalExamples`\n { nonull: true }\n );\n let responses = [];\n // for..of here, to support sequential execution of async calls. This is required, since dereferencing the\n // `openapiSpec` is not concurrency-safe\n for (const filePathMapExternalExamples of filePathsMaps) {\n let mapExternalExamples = null,\n openapiSpec = null;\n try {\n mapExternalExamples = JSON.parse(fs.readFileSync(filePathMapExternalExamples, 'utf-8'));\n openapiSpec = await _parseSpec(filePathSchema);\n openapiSpec = Determiner.getImplementation(openapiSpec)\n .prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n } catch (err) {\n responses.push(createValidationResponse({ errors: [ApplicationError.create(err)] }));\n continue;\n }\n // Not using `glob`'s response-length, because it is `1` if there's no match for `globMapExternalExamples`.\n // Instead, increment on every match\n matchingFilePathsMapping++;\n responses.push(\n _validate(\n statistics => {\n return _handleExamplesByMapValidation(\n openapiSpec, mapExternalExamples, statistics, {\n cwdToMappingFile,\n dirPathMapExternalExamples: path.dirname(filePathMapExternalExamples),\n ignoreFormats\n }\n ).map(\n (/** @type ApplicationError */ error) => Object.assign(error, {\n mapFilePath: path.normalize(filePathMapExternalExamples)\n })\n );\n }\n )\n );\n }\n return merge(\n responses.reduce((res, response) => {\n if (!res) {\n return response;\n }\n return _mergeValidationResponses(res, response);\n }, null),\n { statistics: { matchingFilePathsMapping } }\n );\n}\n\n/**\n * Validates a single external example.\n * @param {String} filePathSchema File-path to the OpenAPI-spec\n * @param {String} pathSchema JSON-path to the schema\n * @param {String} filePathExample File-path to the external example-file\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not described in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExample(filePathSchema, pathSchema, filePathExample, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n} = {}) {\n let example = null,\n schema = null,\n openapiSpec = null;\n try {\n example = JSON.parse(fs.readFileSync(filePathExample, 'utf-8'));\n openapiSpec = await _parseSpec(filePathSchema);\n openapiSpec = Determiner.getImplementation(openapiSpec)\n .prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n schema = _extractSchema(_getSchmaPointer(pathSchema, openapiSpec), openapiSpec);\n } catch (err) {\n return createValidationResponse({ errors: [ApplicationError.create(err)] });\n }\n return _validate(\n statistics => _validateExample({\n createValidator: _initValidatorFactory(openapiSpec, { ignoreFormats }),\n schema,\n example,\n statistics,\n filePathExample\n })\n );\n}\n\n// Private\n\n/**\n * Parses the OpenAPI-spec (supports JSON and YAML)\n * @param {String} filePath File-path to the OpenAPI-spec\n * @returns {object} Parsed OpenAPI-spec\n * @private\n */\nasync function _parseSpec(filePath) {\n const isYaml = _isFileTypeYaml(filePath);\n let jsonSchema;\n\n if (isYaml) {\n try {\n jsonSchema = yaml.parse(fs.readFileSync(filePath, 'utf-8'));\n } catch (e) {\n const { name, message } = e;\n throw new ApplicationError(ErrorType.parseError, { message: `${name}: ${message}` });\n }\n } else {\n jsonSchema = JSON.parse(fs.readFileSync(filePath, 'utf-8'));\n }\n\n return await dereferenceJsonSchema(filePath, jsonSchema);\n}\n\n/**\n * Determines whether the filePath is pointing to a YAML-file\n * @param {String} filePath File-path to the OpenAPI-spec\n * @returns {boolean} `true`, if the file is a YAML-file\n * @private\n */\nfunction _isFileTypeYaml(filePath) {\n const extension = filePath.split('.').pop();\n return FILE_EXTENSIONS__YAML.includes(extension);\n}\n\n/**\n * Top-level validator. Prepares common values, required for the validation, then calles the validator and prepares\n * the result for the output.\n * @param {ValidationHandler} validationHandler The handler which performs the validation. It will receive the\n * statistics-object as argument and has to return an Array of\n * errors (or an empty Array, when all examples are valid)\n * @returns {ValidationResponse}\n * @private\n */\nfunction _validate(validationHandler) {\n const statistics = _initStatistics(),\n errors = validationHandler(statistics);\n return createValidationResponse({ errors, statistics });\n}\n\n/**\n * Validates examples by a mapping-file.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {Object} mapExternalExamples Mapping-file containing JSON-paths to schemas as\n * key and a single file-path or Array of file-paths\n * to external examples\n * @param {ValidationStatistics} statistics Validation-statistics\n * @param {boolean} [cwdToMappingFile=false] Change working directory for resolving the example-\n * paths (relative to the mapping-file)\n * @param {string} [dirPathMapExternalExamples] The directory-path of the mapping-file\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {Array.}\n * @private\n */\nfunction _handleExamplesByMapValidation(openapiSpec, mapExternalExamples, statistics,\n { cwdToMappingFile = false, dirPathMapExternalExamples, ignoreFormats }\n) {\n return flatMap(Object.entries(mapExternalExamples), ([pathSchema, filePathsExample]) => {\n let schema = null;\n try {\n schema = _extractSchema(_getSchmaPointer(pathSchema, openapiSpec), openapiSpec);\n } catch (/** @type ErrorJsonPathNotFound */ err) {\n // If the schema can't be found, don't even attempt to process the examples\n return ApplicationError.create(err);\n }\n return flatMap(\n flatten([filePathsExample]),\n filePathExample => {\n let examples = [];\n try {\n const resolvedFilePathExample = cwdToMappingFile\n ? path.join(dirPathMapExternalExamples, filePathExample)\n : filePathExample;\n const globResolvedFilePathExample = glob.sync(resolvedFilePathExample);\n if (globResolvedFilePathExample.length === 0) {\n return [ApplicationError.create({\n type: ErrorType.jsENOENT,\n message: `No such file or directory: '${resolvedFilePathExample}'`,\n path: resolvedFilePathExample\n })];\n }\n for (const filePathExample of globResolvedFilePathExample) {\n examples.push({\n path: path.normalize(filePathExample),\n content: JSON.parse(fs.readFileSync(filePathExample, 'utf-8'))\n });\n }\n } catch (err) {\n return [ApplicationError.create(err)];\n }\n return flatMap(examples, example => _validateExample({\n createValidator: _initValidatorFactory(openapiSpec, { ignoreFormats }),\n schema,\n example: example.content,\n statistics,\n filePathExample: example.path\n }));\n }\n );\n });\n}\n\n\n/**\n * Merges two `ValidationResponses` together and returns the merged result. The passed `ValidationResponse`s won't be\n * modified.\n * @param {ValidationResponse} response1\n * @param {ValidationResponse} response2\n * @returns {ValidationResponse}\n * @private\n */\nfunction _mergeValidationResponses(response1, response2) {\n return createValidationResponse({\n errors: response1.errors.concat(response2.errors),\n statistics: Object.entries(response1.statistics)\n .reduce((res, [key, val]) => {\n if (PROP__SCHEMAS_WITH_EXAMPLES === key) {\n [\n response1,\n response2\n ].forEach(response => {\n const schemasWithExample = response.statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES]\n .values();\n for (let schema of schemasWithExample) {\n res[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].add(schema);\n }\n });\n return res;\n }\n res[key] = val + response2.statistics[key];\n return res;\n }, _initStatistics())\n });\n}\n\n/**\n * Extract JSON-pointer(s) for specific path from a OpenAPI-spec\n * @param {String} path JSON-path in the OpenAPI-Spec\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {Array.} JSON-pointers to matching elements\n * @private\n */\nfunction _pathToPointer(path, openapiSpec) {\n return jsonPath({\n json: openapiSpec,\n path: path,\n resultType: ResultType.pointer\n });\n}\n/**\n * Extract JSON-pointer(s) for specific path from a OpenAPI-spec\n * @param {String} path JSON-path in the OpenAPI-Spec\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {String} JSON-pointer to schema or throws error\n * @private\n */\nfunction _getSchmaPointer(pathSchema, openapiSpec) {\n const schemaPointers = _pathToPointer(pathSchema, openapiSpec);\n if (schemaPointers.length === 0) {\n _pathToSchemaNotFoundError(pathSchema);\n }\n if (schemaPointers.length > 1) {\n return [ApplicationError.create({\n type: ErrorType.jsonPathNotFound,\n message: `Path to schema cannot identify unique schema: '${pathSchema}'`,\n path: pathSchema\n })];\n }\n return schemaPointers[0];\n}\n\n/**\n * Validates examples at the given paths in the OpenAPI-spec.\n * @param {Object} impl Spec-dependant validator\n * @param {Array.} pathsExamples JSON-paths to examples\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n * @private\n */\nfunction _validateExamplesPaths({ impl }, pathsExamples, openapiSpec, { ignoreFormats }) {\n const statistics = _initStatistics(),\n validationResult = {\n valid: true,\n statistics,\n errors: []\n },\n createValidator = _initValidatorFactory(openapiSpec, { ignoreFormats });\n let validationMap;\n try {\n // Create mapping between JSON-schemas and examples\n validationMap = impl.buildValidationMap(pathsExamples);\n } catch (error) {\n // Throw unexpected errors\n if (!(error instanceof ApplicationError)) {\n throw error;\n }\n // Add known errors and stop\n validationResult.valid = false;\n validationResult.errors.push(error);\n return validationResult;\n }\n // Start validation\n const schemaPointers = Object.keys(validationMap);\n schemaPointers.forEach(schemaPointer => {\n _validateSchema({\n openapiSpec, createValidator, schemaPointer, validationMap, statistics,\n validationResult\n });\n });\n return validationResult;\n}\n\n/**\n * Validates a single schema.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {ajv} createValidator Factory, to create JSON-schema validator\n * @param {string} schemaPointer JSON-pointer to schema (for request- or response-property)\n * @param {Object.} validationMap Map with schema-pointers as key and example-pointers as value\n * @param {Object} statistics Object to contain statistics metrics\n * @param {Object} validationResult Container, for the validation-results\n * @private\n */\nfunction _validateSchema({\n openapiSpec, createValidator, schemaPointer, validationMap, statistics,\n validationResult\n}) {\n const errors = validationResult.errors;\n validationMap[schemaPointer].forEach(pathExample => {\n const example = _getByPointer(pathExample, openapiSpec),\n // Examples with missing schemas may occur and those are considered valid\n schema = _extractSchema(schemaPointer, openapiSpec, true);\n const curErrors = _validateExample({\n createValidator,\n schema,\n example,\n statistics\n }).map(error => {\n error.examplePath = pathExample;\n return error;\n });\n if (!curErrors.length) {\n return;\n }\n validationResult.valid = false;\n errors.splice(errors.length - 1, 0, ...curErrors);\n });\n}\n\n/**\n * Creates a container-object for the validation statistics.\n * @returns {ValidationStatistics}\n * @private\n */\nfunction _initStatistics() {\n const statistics = {\n [SYM__INTERNAL]: {\n [PROP__SCHEMAS_WITH_EXAMPLES]: new Set()\n },\n examplesTotal: 0,\n examplesWithoutSchema: 0\n };\n Object.defineProperty(statistics, PROP__SCHEMAS_WITH_EXAMPLES, {\n enumerable: true,\n get: () => statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].size\n });\n return statistics;\n}\n\n/**\n * Extract object by the given JSON-pointer\n * @param {String} pointer JSON-pointer\n * @param {Object} json JSON to extract the object(s) from\n * @returns {Object} Extracted object\n */\nfunction _getByPointer(pointer, json) {\n try {\n return jsonPointer.get(json, pointer);\n } catch (_) {\n return undefined;\n }\n}\n\n/**\n * Validates example against the schema. The precondition for this function to work is that the example exists at the\n * given path.\n * `pathExample` and `filePathExample` are exclusively mandatory.\n * itself\n * @param {Function} createValidator Factory, to create JSON-schema validator\n * @param {Object} schema JSON-schema\n * @param {Object} example Example to validate\n * @param {Object} statistics Object to contain statistics metrics\n * @param {String} [filePathExample] File-path to the example file\n * @returns {Array.} Array with errors. Empty array, if examples are valid\n * @private\n */\nfunction _validateExample({ createValidator, schema, example, statistics, filePathExample }) {\n const\n errors = [];\n statistics.examplesTotal++;\n // No schema, no validation (Examples without schema are considered valid)\n if (!schema) {\n statistics.examplesWithoutSchema++;\n return errors;\n }\n statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].add(schema);\n const validate = compileValidate(createValidator(), schema);\n if (validate(example)) {\n return errors;\n }\n return errors.concat(...validate.errors.map(ApplicationError.create))\n .map(error => {\n if (!filePathExample) {\n return error;\n }\n error.exampleFilePath = filePathExample;\n return error;\n });\n}\n\n/**\n * Create a new instance of a JSON schema validator\n * @returns {ajv}\n * @private\n */\nfunction _initValidatorFactory(specSchema, { ignoreFormats }) {\n return getValidatorFactory(specSchema, {\n schemaId: 'auto',\n discriminator: true,\n strict: false,\n allErrors: true,\n formats: ignoreFormats && ignoreFormats.reduce((result, entry) => {\n result[entry] = () => true;\n return result;\n }, {})\n });\n}\n\n/**\n * Extracts the schema in the OpenAPI-spec at the given JSON-pointer.\n * @param {string} schemaPointer JSON-pointer to the schema\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {boolean} [suppressErrorIfNotFound=false] Don't throw `ErrorJsonPathNotFound` if the response does not\n * exist at the given JSON-pointer\n * @returns {Object|Array.|undefined} Matching schema(s)\n * @throws {ErrorJsonPathNotFound} Thrown, when there is no schema at the given path and\n * `suppressErrorIfNotFound` is false\n * @private\n */\nfunction _extractSchema(schemaPointer, openapiSpec, suppressErrorIfNotFound = false) {\n const schema = _getByPointer(schemaPointer, openapiSpec);\n if (!suppressErrorIfNotFound && !schema) {\n _pathToSchemaNotFoundError(schemaPointer);\n }\n return schema;\n}\n\nfunction _pathToSchemaNotFoundError(schemaPointer) {\n throw new ErrorJsonPathNotFound(`Path to schema can't be found: '${schemaPointer}'`, {\n params: {\n path: schemaPointer\n }\n });\n}\n","const path = require('path'),\n refParser = require('json-schema-ref-parser');\n\nmodule.exports = {\n createValidationResponse,\n dereferenceJsonSchema\n};\n\n/**\n * Creates a unified response for the validation-result\n * @param {Array.} errors\n * @param {ValidationStatistics} statistics\n * @returns {ValidationResponse}\n * @private\n */\nfunction createValidationResponse({ errors, statistics = {} }) {\n return {\n valid: !errors.length,\n statistics,\n errors\n };\n}\n\n/**\n * Includes all referenced, external schemas (by the keyword `$ref`) into the schema\n *\n * CAUTION: This function is not concurrency-safe !!\n * This function changes the working dir and sets it back. This may become an concurrency issue when there are\n * other tasks running that rely on the working dir while this function waits for the asynchronous task of\n * dereferencing to complete.\n *\n * @param {String} pathToSchema File-path to the schema\n * @param {Object} jsonSchema Schema with potential externally referenced schemas\n * @returns {Promise} Dereferenced schema\n */\nasync function dereferenceJsonSchema(pathToSchema, jsonSchema) {\n const currentWorkingDir = process.cwd();\n // Change the working dir to the schema-path, to make sure that relative paths can be resolved\n process.chdir(path.dirname(pathToSchema));\n const dereferencedSchema = await refParser.dereference(jsonSchema);\n // Restore original working dir\n process.chdir(currentWorkingDir);\n return dereferencedSchema;\n}\n","/**\n * Wrapper for the JSONSchema-validator\n */\n\nconst { JSONPath: jsonPath } = require('jsonpath-plus'),\n JsonPointer = require('json-pointer'),\n Ajv = require('ajv-draft-04'),\n addFormats = require('ajv-formats');\n\nconst PROP__ID = '$id',\n JSON_PATH__REFS = '$..\\$ref',\n ID__SPEC_SCHEMA = 'https://www.npmjs.com/package/openapi-examples-validator/defs.json',\n ID__RESPONSE_SCHEMA = 'https://www.npmjs.com/package/openapi-examples-validator/schema.json';\n\nmodule.exports = {\n getValidatorFactory,\n compileValidate\n};\n\n/**\n * Get a factory-function to create a prepared validator-instance\n * @param {Object} specSchema OpenAPI-spec of which potential local references will be extracted\n * @param {Object} [options] Options for the validator\n * @returns {function(): (ajv | ajv.Ajv)}\n */\nfunction getValidatorFactory(specSchema, options) {\n const preparedSpecSchema = _createReferenceSchema(specSchema);\n return () => {\n const validator = new Ajv(options);\n addFormats(validator);\n\n validator.addSchema(preparedSpecSchema);\n\n return validator;\n };\n}\n\n/**\n * Compiles the validator-function.\n * @param {ajv | ajv.Ajv} validator Validator-instance\n * @param {Object} responseSchema The response-schema, against the examples will be validated\n * @returns {ajv.ValidateFunction}\n */\nfunction compileValidate(validator, responseSchema) {\n const preparedResponseSchema = _prepareResponseSchema(responseSchema, ID__RESPONSE_SCHEMA);\n _replaceRefsToPreparedSpecSchema(preparedResponseSchema);\n\n let result;\n try {\n result = validator.compile(preparedResponseSchema);\n } catch (e) {\n result = () => {};\n result.errors = [e];\n }\n return result;\n}\n\n/**\n * Prepares the schema, to be used with internal-references\n * @param {Object} specSchema The schema to be prebared\n * @param {String} idSchema The unique ID for the schema\n * @returns {Object}\n * @private\n */\nfunction _prepareResponseSchema(specSchema, idSchema) {\n const preparedSchema = Object.assign({}, specSchema);\n preparedSchema[PROP__ID] = idSchema;\n return preparedSchema;\n}\n\n/**\n * Replaces all internal references to the schema, with the extracted references, based on the origin OpenAPI-spec\n * @param {Object} schema The schema, containing references have to be replaced\n * @private\n */\nfunction _replaceRefsToPreparedSpecSchema(schema) {\n jsonPath({\n path: JSON_PATH__REFS,\n json: schema,\n callback(value, type, payload) {\n if (!value.startsWith('#')) { return; }\n payload.parent[payload.parentProperty] = `${ ID__SPEC_SCHEMA }${ value }`;\n }\n });\n}\n\n/**\n * Extracts all references and returns a new schema, containing only those.\n * @param {Object} specSchema Schema, which references shall be extracted\n * @returns {Object}\n * @private\n */\nfunction _createReferenceSchema(specSchema) {\n const refSchema = {\n [PROP__ID]: ID__SPEC_SCHEMA\n };\n jsonPath({\n path: JSON_PATH__REFS,\n json: specSchema,\n callback(value) {\n if (!value.startsWith('#')) { return; }\n const pointer = value.substring(1),\n definition = JsonPointer.get(specSchema, pointer);\n JsonPointer.set(refSchema, pointer, definition);\n }\n });\n return refSchema;\n}\n","module.exports = {\"name\":\"openapi-examples-validator\",\"version\":\"6.0.0\",\"description\":\"Validates embedded examples in OpenAPI-JSONs\",\"main\":\"dist/index.js\",\"engines\":{\"node\":\">=18\"},\"bin\":{\"openapi-examples-validator\":\"dist/cli.js\"},\"standard-version\":{\"scripts\":{\"postchangelog\":\"npm run release:create-dockerfile && npm run release:stage-artifacts\"}},\"scripts\":{\"start-dev\":\"babel-node src/cli\",\"build\":\"npm run build:clean && npm run build:webpack\",\"build:clean\":\"rimraf dist\",\"build:webpack\":\"webpack --bail --progress --profile --mode production --config ./webpack/config.babel.js\",\"coverage\":\"rimraf ./coverage && nyc --reporter=lcov --reporter=text -x \\\"dist/**/*\\\" -x \\\"test/**/*.js\\\" npm test\",\"coveralls\":\"cat ./coverage/lcov.info | coveralls\",\"test\":\"npm run build && npm run test:mocha\",\"test-mutations\":\"stryker run\",\"test:mocha\":\"mocha --require \\\"./test/util/setup-tests\\\" --recursive \\\"./test/specs/**/*.js\\\"\",\"release\":\"npm run build && standard-version -a\",\"release:create-dockerfile\":\"npm run build && node etc/src/build-dockerfile.js\",\"release:stage-artifacts\":\"git add dist/*\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/codekie/openapi-examples-validator.git\"},\"keywords\":[\"swagger\",\"openapi\",\"json\",\"validate\",\"examples\"],\"author\":\"Josua Amann\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/codekie/openapi-examples-validator/issues\"},\"homepage\":\"https://github.com/codekie/openapi-examples-validator#readme\",\"devDependencies\":{\"@babel/cli\":\"^7.25.9\",\"@babel/core\":\"^7.26.0\",\"@babel/eslint-parser\":\"^7.25.9\",\"@babel/node\":\"^7.26.0\",\"@babel/preset-env\":\"^7.26.0\",\"@babel/register\":\"^7.25.9\",\"@stryker-mutator/core\":\"^8.6.0\",\"@stryker-mutator/mocha-runner\":\"^8.6.0\",\"babel-loader\":\"^9.2.1\",\"chai\":\"^4.3.6\",\"chai-string\":\"^1.5.0\",\"core-js-pure\":\"^3.39.0\",\"coveralls\":\"^3.1.1\",\"eslint\":\"^8.41.0\",\"eslint-webpack-plugin\":\"^4.2.0\",\"json-loader\":\"^0.5.7\",\"mocha\":\"^10.8.2\",\"mocha-lcov-reporter\":\"^1.3.0\",\"nyc\":\"^15.1.0\",\"rimraf\":\"^5.0.1\",\"standard-version\":\"^9.5.0\",\"stryker-cli\":\"^1.0.2\",\"webpack\":\"^5.96.1\",\"webpack-cli\":\"^5.1.4\"},\"dependencies\":{\"ajv\":\"^8.17.1\",\"ajv-draft-04\":\"^1.0.0\",\"ajv-formats\":\"^2.1.1\",\"commander\":\"^6.2.1\",\"errno\":\"^1.0.0\",\"glob\":\"^8.1.0\",\"json-pointer\":\"^0.6.2\",\"json-schema-ref-parser\":\"^9.0.9\",\"jsonpath-plus\":\"^10.2.0\",\"lodash.clonedeep\":\"^4.5.0\",\"lodash.flatmap\":\"^4.5.0\",\"lodash.flatten\":\"^4.4.0\",\"lodash.merge\":\"^4.6.2\",\"yaml\":\"^2.6.1\"}}","module.exports = require(\"ajv-draft-04\");","module.exports = require(\"ajv-formats\");","module.exports = require(\"commander\");","module.exports = require(\"errno\");","module.exports = require(\"glob\");","module.exports = require(\"json-pointer\");","module.exports = require(\"json-schema-ref-parser\");","module.exports = require(\"jsonpath-plus\");","module.exports = require(\"lodash.clonedeep\");","module.exports = require(\"lodash.flatmap\");","module.exports = require(\"lodash.flatten\");","module.exports = require(\"lodash.merge\");","module.exports = require(\"yaml\");","module.exports = require(\"fs\");","module.exports = require(\"path\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(115);\n"],"names":["merge","require","ENOENT","ErrorType","jsENOENT","code","jsonPathNotFound","errorAndErrorsMutuallyExclusive","parseError","validation","ApplicationError","create","err","message","path","cause","type","options","params","constructor","Object","assign","this","module","exports","VERSION","program","validateFile","validateExample","validateExamplesByMap","ENV_TEST","process","env","OPENAPI_EXAMPLES_VALIDATOR_TESTS","version","arguments","description","option","action","async","filepath","schemaJsonpath","exampleFilepath","mappingFilepath","cwdToMappingFile","allPropertiesRequired","noAdditionalProperties","additionalProperties","ignoreFormats","Array","isArray","length","indexOf","split","filter","entry","match","_prepareIgnoreFormats","result","console","log","noExit","statistics","schemasWithExamples","examplesWithoutSchema","examplesTotal","matchingFilePathsMapping","strStatistics","push","stdout","write","join","_printStatistics","valid","exit","stderr","JSON","stringify","errors","_handleResult","on","parseAsync","argv","parent","parentProperty","pointer","value","implV2","implV3","REGEX__OPEN_API","getImplementation","openapiSpec","swagger","openapi","applyCallbackToAllObjectModels","setAllPropertiesRequired","openApiSpec","examplePaths","hasOwnProperty","required","keys","properties","JSONPath","jsonPath","ResultType","_find","json","resultType","callback","flatten","matchCallbackBuilder","paths","Set","forEach","consecutiveMatch","_isPropertiesDefinition","add","examplePath","exampleMatch","jsPath","startsWith","delete","_excludeExamples","data","entity","setNoAdditionalProperties","hasJsonCombinerParentRegex","RegExp","JSON_SCHEMA_COMBINERS","schema","test","warn","some","combiner","cloneDeep","getJsonPathsToExamples","buildValidationMap","pathsExamples","reduce","validationMap","pathExample","pathSchema","examplePointer","pathSegs","idxExamples","lastIndexOf","splice","_getSchemaPointerOfExample","prepare","openapiSpecCopy","RESPONSES","REQUEST","SINGLE_EXAMPLE","MANY_EXAMPLES","PATH__EXAMPLE","PATH__EXAMPLES","PATH__EXAMPLE__REQUEST_BODY","PATH__EXAMPLES__REQUEST_BODY","ExampleType","exampleTypesOfSchemas","Map","pathSchemaAsArray","exampleType","idxExample","exampleTypeOfSchema","get","pathContextAsArray","slice","pathContext","_throwMutuallyExclusiveError","set","flatMap","jsonPointer","fs","glob","yaml","refParser","createError","getValidatorFactory","compileValidate","Determiner","createValidationResponse","dereferenceJsonSchema","SYM__INTERNAL","Symbol","PROP__SCHEMAS_WITH_EXAMPLES","FILE_EXTENSIONS__YAML","ErrorJsonPathNotFound","validateExamples","impl","dereference","res","pathToExamples","concat","_pathToPointer","_initStatistics","validationResult","createValidator","_initValidatorFactory","error","schemaPointer","example","_getByPointer","_extractSchema","curErrors","_validateExample","map","_validateSchema","_validateExamplesPaths","_parseSpec","filePath","isYaml","extension","pop","includes","_isFileTypeYaml","jsonSchema","parse","readFileSync","e","name","_validate","validationHandler","_handleExamplesByMapValidation","mapExternalExamples","dirPathMapExternalExamples","entries","filePathsExample","_getSchmaPointer","filePathExample","examples","resolvedFilePathExample","globResolvedFilePathExample","sync","normalize","content","schemaPointers","_pathToSchemaNotFoundError","defineProperty","enumerable","size","_","validate","exampleFilePath","specSchema","schemaId","discriminator","strict","allErrors","formats","suppressErrorIfNotFound","filePathSchema","globMapExternalExamples","filePathsMaps","nonull","responses","filePathMapExternalExamples","dirname","mapFilePath","response","response2","response1","key","val","schemasWithExample","values","pathToSchema","currentWorkingDir","cwd","chdir","dereferencedSchema","JsonPointer","Ajv","addFormats","PROP__ID","JSON_PATH__REFS","ID__SPEC_SCHEMA","preparedSpecSchema","refSchema","substring","definition","_createReferenceSchema","validator","addSchema","responseSchema","preparedResponseSchema","preparedSchema","_prepareResponseSchema","payload","compile","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"cli.js","mappings":";2BAAA,MACIA,EAAQC,EAAQ,MAChB,OAAEC,GAAWD,EAAAA,KAAAA,KA6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ack://openapi-examples-validator/./src/cli.js","webpack://openapi-examples-validator/./src/const/result-type.js","webpack://openapi-examples-validator/./src/impl/index.js","webpack://openapi-examples-validator/./src/impl/service/all-properties-required.js","webpack://openapi-examples-validator/./src/impl/service/common.js","webpack://openapi-examples-validator/./src/impl/service/no-additional-properties.js","webpack://openapi-examples-validator/./src/impl/v2/index.js","webpack://openapi-examples-validator/./src/impl/v3/index.js","webpack://openapi-examples-validator/./src/index.js","webpack://openapi-examples-validator/./src/utils/index.js","webpack://openapi-examples-validator/./src/validator.js","webpack://openapi-examples-validator/./package.json","webpack://openapi-examples-validator/external commonjs \"ajv-draft-04\"","webpack://openapi-examples-validator/external commonjs \"ajv-formats\"","webpack://openapi-examples-validator/external commonjs \"commander\"","webpack://openapi-examples-validator/external commonjs \"errno\"","webpack://openapi-examples-validator/external commonjs \"glob\"","webpack://openapi-examples-validator/external commonjs \"json-pointer\"","webpack://openapi-examples-validator/external commonjs \"json-schema-ref-parser\"","webpack://openapi-examples-validator/external commonjs \"jsonpath-plus\"","webpack://openapi-examples-validator/external commonjs \"lodash.clonedeep\"","webpack://openapi-examples-validator/external commonjs \"lodash.flatmap\"","webpack://openapi-examples-validator/external commonjs \"lodash.flatten\"","webpack://openapi-examples-validator/external commonjs \"lodash.merge\"","webpack://openapi-examples-validator/external commonjs \"yaml\"","webpack://openapi-examples-validator/external node-commonjs \"fs\"","webpack://openapi-examples-validator/external node-commonjs \"path\"","webpack://openapi-examples-validator/webpack/bootstrap","webpack://openapi-examples-validator/webpack/startup"],"sourcesContent":["const\n merge = require('lodash.merge'),\n { ENOENT } = require('errno').code;\n\n// TYPEDEFINITIONS\n\n/**\n * @typedef {{}} CustomError\n * @augments Error\n */\n\n/**\n * ApplicationErrorOptions\n * @typedef {{\n * [instancePath]: string,\n * [examplePath]: string,\n * [exampleFilePath]: string,\n * [keyword]: string,\n * [message]: string,\n * [mapFilePath]: string,\n * [params]: {\n * [path]: string,\n * [missingProperty]: string,\n * [type]: string\n * },\n * [schemaPath]: string\n * }} ApplicationErrorOptions\n */\n\n// CONSTANTS\n\nconst ErrorType = {\n jsENOENT: ENOENT.code,\n jsonPathNotFound: 'JsonPathNotFound',\n errorAndErrorsMutuallyExclusive: 'ErrorErrorsMutuallyExclusive',\n parseError: 'ParseError',\n validation: 'Validation'\n};\n\n// CLASSES\n\n/**\n * Unified application-error\n */\nclass ApplicationError {\n /**\n * Factory-function, which is able to consume validation-errors and JS-errors. If a validation error is passed, all\n * properties will be adopted.\n * @param {Error|CustomError} err Javascript-, validation- or custom-error, to create the application-error\n * from\n * @returns {ApplicationError} Unified application-error instance\n */\n static create(err) {\n const { code, message, path, cause } = err, // Certain properties of Javascript-errors\n type = code || err.type || ErrorType.validation, // If `code` is available then it's a Javascript-error\n options = { message };\n if (ErrorType.validation === type || ErrorType.errorAndErrorsMutuallyExclusive === type) {\n // For certain, created error-types, copy all properties\n merge(options, err);\n } else {\n // Copy certain properties of Javascript-error (but only if available)\n path && merge(options, { params: { path } });\n cause && merge(options, cause);\n }\n return new ApplicationError(type, options);\n }\n\n /**\n * Constructor\n * @param {string} type Type of error (see statics)\n * @param {ApplicationErrorOptions} [options] Optional properties\n */\n constructor(type, options = {}) {\n Object.assign(this, {\n type,\n ...options\n });\n }\n}\n\n// PUBLIC API\n\nmodule.exports = {\n ApplicationError,\n ErrorType\n};\n","// Shebang will be added by webpack\n//#!/usr/bin/env node --harmony\n\n/**\n * Command Line Interface for the validator\n */\n\nconst\n VERSION = require('../package.json').version,\n program = require('commander'),\n { validateFile, validateExample, validateExamplesByMap } = require('./index');\n\n// FOR AUTOMATED TESTS\n\nconst ENV_TEST = process.env.OPENAPI_EXAMPLES_VALIDATOR_TESTS === 'true';\n\n// DEFINE CLI\n\nprogram\n .version(VERSION)\n .arguments('')\n .description('Validate embedded examples in OpenAPI-specs (JSON and YAML supported).\\n'\n + ' To validate external examples, use the `-s` and `-e` option.\\n'\n + ' To pass a mapping-file, to validate multiple external examples, use the `-m` option.')\n .option('-s, --schema-jsonpath ', 'Path to OpenAPI-schema, to validate the example file against')\n .option('-e, --example-filepath ', 'file path to example file, to be validated')\n .option('-m, --mapping-filepath ', 'file path to map, containing schema-paths as key and the'\n + ' file-path(s) to examples as value. If wildcards are used, the parameter has to be put in quotes.')\n .option('-c, --cwd-to-mapping-file', \"changes to the directory of the mapping-file, before resolving the example's\"\n + ' paths. Use this option, if your mapping-files use relative paths for the examples')\n .option('-n, --no-additional-properties', 'don\\'t allow properties that are not described in the schema')\n .option('-r, --all-properties-required', 'make all the properties in the schema required')\n .option('-o, --ignore-formats ', 'Datatype formats to ignore '\n + '(to prevent \"unknown format\" message in the error-console.)')\n .action(processAction);\nprogram.on('--help', () => {\n console.log('\\n\\n Example for external example-file:\\n');\n console.log(' $ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json'\n + ' openapi-spec.json\\n\\n');\n});\n// Execute and export promise (for automated tests)\nmodule.exports = program.parseAsync(process.argv);\n\n// IMPLEMENTATION DETAILS\n\nasync function processAction(filepath, options) {\n const { schemaJsonpath, exampleFilepath, mappingFilepath, cwdToMappingFile, allPropertiesRequired } = options,\n noAdditionalProperties = !options.additionalProperties,\n ignoreFormats = _prepareIgnoreFormats(options.ignoreFormats);\n let result;\n if (mappingFilepath) {\n console.log('Validating with mapping file');\n result = await validateExamplesByMap(filepath, mappingFilepath, {\n cwdToMappingFile,\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n } else if (schemaJsonpath && exampleFilepath) {\n console.log('Validating single external example');\n result = await validateExample(filepath, schemaJsonpath, exampleFilepath, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n } else {\n console.log('Validating examples');\n result = await validateFile(filepath, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n });\n }\n _handleResult(result);\n}\n\nfunction _handleResult(result) {\n const noExit = ENV_TEST;\n _printStatistics(result.statistics);\n if (result.valid) {\n process.stdout.write('\\nNo errors found.\\n\\n');\n !noExit && process.exit(0);\n return;\n }\n process.stdout.write('\\nErrors found.\\n\\n');\n process.stderr.write(JSON.stringify(result.errors, null, ' '));\n !noExit && process.exit(1);\n}\n\nfunction _printStatistics(statistics) {\n const {\n schemasWithExamples,\n examplesWithoutSchema,\n examplesTotal,\n matchingFilePathsMapping\n } = statistics,\n strStatistics = [\n `Schemas with examples found: ${ schemasWithExamples }`,\n `Examples without schema found: ${ examplesWithoutSchema }`,\n `Total examples found: ${ examplesTotal }`\n ];\n if (matchingFilePathsMapping != null) {\n strStatistics.push(`Matching mapping files found: ${ matchingFilePathsMapping }`);\n }\n process.stdout.write(`${ strStatistics.join('\\n') }\\n`);\n}\n\nfunction _prepareIgnoreFormats(ignoreFormats) {\n if (ignoreFormats == null || !Array.isArray(ignoreFormats)) { return ignoreFormats; }\n if (ignoreFormats.length !== 1) { return ignoreFormats; }\n // If only one argument has been passed, with all formats separated by newlines\n if (ignoreFormats[0].indexOf('\\n') === -1) { return ignoreFormats; }\n return ignoreFormats[0].split('\\n').filter(entry => !entry.match(/^\\s*$/));\n}\n","module.exports = {\n parent: 'parent',\n parentProperty: 'parentProperty',\n path: 'path',\n pointer: 'pointer',\n value: 'value'\n};\n","/**\n * Entry point for logic that only applies to specific versions of the OpenAPI-spec\n */\n\nconst implV2 = require('./v2/index'),\n implV3 = require('./v3/index');\n\nconst REGEX__OPEN_API = /^3\\./;\n\nmodule.exports = {\n getImplementation\n};\n\n/**\n * Get the version-specific implementation for the OpenAPI-spec. Currently v2 and v3 are supported\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {Object|null}\n */\nfunction getImplementation(openapiSpec) {\n if (typeof openapiSpec.swagger === 'string') {\n return implV2;\n }\n if (openapiSpec.openapi && openapiSpec.openapi.match(REGEX__OPEN_API)) {\n return implV3;\n }\n return null;\n}\n","const { applyCallbackToAllObjectModels } = require('./common');\n\nmodule.exports = {\n setAllPropertiesRequired\n};\n\n/**\n * Sets all properties of each object to required\n * @param {Object} openApiSpec The to-be-modified schema\n * @param {Array.} [examplePaths=[]] The paths to the examples, which's content must not be modified\n */\nfunction setAllPropertiesRequired(openApiSpec, examplePaths = []) {\n applyCallbackToAllObjectModels(openApiSpec, examplePaths,\n () => {\n return (value) => {\n if (value.hasOwnProperty('properties')) {\n value.required = Object.keys(value.properties);\n }\n };\n });\n}\n","const { JSONPath: jsonPath } = require('jsonpath-plus'),\n ResultType = require('../../const/result-type');\n\nmodule.exports = {\n applyCallbackToAllObjectModels\n};\n\n/**\n * @typedef {{\n * path: String,\n * value: Object,\n * parent: Object,\n * parentProperty: String,\n * hasArrExpr: Boolean\n * }} JsonPathMatchData\n */\n\n/**\n * Callback that is applied to a JSONPath-match.\n * @callback JsonPathMatchCallback\n * @param {Object} value Value of the matched property\n * @param {String} resultType Result-type of the query\n * @param {JsonPathMatchData} data Object that contains additional data to the match\n */\n\n/**\n * Function to build a callback that is applied to a JSONPath-match.\n * @callback JsonPathMatchCallbackBuilder\n * @param {string} jsPath Path to the property that matched\n * @return {JsonPathMatchCallback} Callback that is applied to a JSONPath-match\n */\n\n/**\n * Apply the input rule to all models of type object in the input openApiSpec\n * @param {Object} openApiSpec The to-be-modified schema\n * @param {Array.} [examplePaths] The paths to the examples, which's content must not be modified\n * @param {JsonPathMatchCallbackBuilder} [matchCallbackBuilder] Function to build a callback\n * that will be called on each match\n */\nfunction applyCallbackToAllObjectModels(openApiSpec, examplePaths, matchCallbackBuilder) {\n // Find all matches\n const paths = new Set();\n _find(openApiSpec, '$..schema..')\n .forEach(match => {\n if (_isPropertiesDefinition(match)) { return; }\n paths.add(match);\n });\n // Exclude examples\n _excludeExamples(openApiSpec, paths, examplePaths);\n // Set flag\n for (const jsPath of paths) {\n const callback = matchCallbackBuilder(jsPath);\n _find(openApiSpec, jsPath, ResultType.value, (result, resultType, data) => {\n if (!_isObjectDefinition(result)) { return; }\n callback(result, resultType, data);\n });\n }\n}\n\n/**\n * Find matching elements in JSON.\n * @param {Object} json JSON to be searched\n * @param {String} path JSON-path to search\n * @param {String} [resultType=\"path\"] Result-type of the query\n * @param {JsonPathMatchCallback} [callback] Function to be called on a match\n * @returns {any} Result of the query, depending on the `resultType`\n * @private\n */\nfunction _find(json, path, resultType = ResultType.path, callback) {\n return jsonPath({\n json,\n path,\n flatten: true,\n resultType,\n callback\n });\n}\n\n/**\n * Remove JSON-paths from `paths` that are included in `examplePaths`\n * @param {Object} openApiSpec Open-API spec to search in\n * @param {Set.} paths Paths where the examples have to be removed from\n * @param {Array.} examplePaths JSON-paths of the examples\n * @private\n */\nfunction _excludeExamples(openApiSpec, paths, examplePaths) {\n examplePaths\n .forEach(examplePath => {\n _find(openApiSpec, examplePath)\n .forEach(exampleMatch => {\n for (const jsPath of paths) {\n jsPath.startsWith(exampleMatch) && paths.delete(jsPath);\n }\n });\n });\n}\n\nfunction _isPropertiesDefinition(path) {\n // Path has to end with `properties`\n if (!path.match(/\\['properties']$/)) { return; }\n // Every second consecutive `properties` actually is not a property-definition, but a property itself\n const consecutiveMatch = path.match(/(?} [examplePaths=[]] The paths to the examples, which's content must not be modified\n */\nfunction setNoAdditionalProperties(openApiSpec, examplePaths = []) {\n // Match all combiner keywords that are not preceded by a 'properties' keyword.\n // This allow to have objects that have as property name one of the combiner keywords.\n const hasJsonCombinerParentRegex\n = new RegExp('(? {\n return (schema) => {\n // Exclude schema that have a JSON combiner as parent\n if (hasJsonCombinerParentRegex.test(path)) {\n console.warn('\"additionalProperties\" flag not set '\n + `for ${path} because it has a parent with a JSON-schema combiner keyword.`);\n return;\n }\n // Exclude schema that contains a JSON combiner\n if (JSON_SCHEMA_COMBINERS.some((combiner) => schema.hasOwnProperty(combiner))) {\n console.warn('\"additionalProperties\" flag not set '\n + `for ${path} because it contains JSON-schema combiner keyword.`);\n return;\n }\n // Exclude schema that already contains additionalProperties\n if (schema.hasOwnProperty('additionalProperties')) {\n return;\n }\n schema.additionalProperties = false;\n };\n });\n}\n","/**\n * Contains validation-logic that is specific to V2 of the OpenAPI-spec\n */\n\nconst cloneDeep = require('lodash.clonedeep'),\n { setAllPropertiesRequired } = require('../service/all-properties-required'),\n { setNoAdditionalProperties } = require('../service/no-additional-properties');\n\n// CONSTANTS\n\nconst PATH__EXAMPLES = '$..examples[?(@property.match(/[\\/+]json/))]',\n PROP__SCHEMA = 'schema',\n PROP__EXAMPLES = 'examples';\n\nmodule.exports = {\n buildValidationMap,\n getJsonPathsToExamples,\n prepare\n};\n\n// IMPLEMENTATION DETAILS\n\n/**\n * Get the JSONPaths to the examples\n * @returns {Array.} JSONPaths to the examples\n */\nfunction getJsonPathsToExamples() { return [PATH__EXAMPLES]; }\n\n\n\n/**\n * Builds a map with the json-pointers to the response-schema as key and the json-pointers to the examples, as value.\n * The pointer of the schema is derived from the pointer to the example and doesn't necessarily mean\n * that the schema actually exists.\n * @param {Array.} pathsExamples Paths to the examples\n * @returns {Object.} Map with schema-pointers as key and example-pointers as value\n * @private\n */\nfunction buildValidationMap(pathsExamples) {\n return pathsExamples.reduce((validationMap, pathExample) => {\n const pathSchema = _getSchemaPointerOfExample(pathExample);\n validationMap[pathSchema] = (validationMap[pathSchema] || new Set())\n .add(pathExample);\n return validationMap;\n }, {});\n}\n\n/**\n * Pre-processes the OpenAPI-spec, for further use.\n * The passed spec won't be modified. If a modification happens, a modified copy will be returned.\n * @param {Object} openapiSpec The OpenAPI-spec as JSON-schema\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @return {Object} The prepared OpenAPI-spec\n */\nfunction prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired } = {}) {\n const openapiSpecCopy = cloneDeep(openapiSpec);\n noAdditionalProperties && setNoAdditionalProperties(openapiSpecCopy, getJsonPathsToExamples());\n allPropertiesRequired && setAllPropertiesRequired(openapiSpecCopy, getJsonPathsToExamples());\n return openapiSpecCopy;\n}\n\n/**\n * Gets a JSON-pointer to the corresponding response-schema, based on a JSON-pointer to an example.\n * @param {String} examplePointer JSON-pointer to example\n * @returns {String} JSON-pointer to the corresponding response-schema\n * @private\n */\nfunction _getSchemaPointerOfExample(examplePointer) {\n const pathSegs = examplePointer.split('/'),\n idxExamples = pathSegs.lastIndexOf(PROP__EXAMPLES);\n pathSegs.splice(idxExamples, pathSegs.length - idxExamples, PROP__SCHEMA);\n return pathSegs.join('/');\n}\n","/**\n * Contains validation-logic that is specific to V3 of the OpenAPI-spec\n */\n\nconst cloneDeep = require('lodash.clonedeep'),\n { ApplicationError, ErrorType } = require('../../application-error'),\n { setAllPropertiesRequired } = require('../service/all-properties-required'),\n { setNoAdditionalProperties } = require('../service/no-additional-properties');\n\n// CONSTANTS\n\nconst RESPONSES = '$..responses..content[?(@property.match(/[\\/+]json/))]';\nconst REQUEST = '$..requestBody.content[?(@property.match(/[\\/+]json/))]';\nconst SINGLE_EXAMPLE = '.example';\nconst MANY_EXAMPLES = '.examples.*.value';\n\nconst PATH__EXAMPLE = `${RESPONSES}${SINGLE_EXAMPLE}`,\n PATH__EXAMPLES = `${RESPONSES}${MANY_EXAMPLES}`,\n PATH__EXAMPLE__PARAMETER = '$..parameters..example',\n PATH__EXAMPLES__PARAMETER = '$..parameters..examples.*.value',\n PATH__EXAMPLE__REQUEST_BODY = `${REQUEST}${SINGLE_EXAMPLE}`,\n PATH__EXAMPLES__REQUEST_BODY = `${REQUEST}${MANY_EXAMPLES}`,\n PROP__SCHEMA = 'schema',\n PROP__EXAMPLE = 'example',\n PROP__EXAMPLES = 'examples';\n\nconst ExampleType = {\n single: 'single',\n multi: 'multi'\n};\n\n// PUBLIC API\n\nmodule.exports = {\n buildValidationMap,\n getJsonPathsToExamples,\n prepare\n};\n\n// IMPLEMENTATION DETAILS\n\n/**\n * Get the JSONPaths to the examples\n * @returns {Array.} JSONPaths to the examples\n */\nfunction getJsonPathsToExamples() {\n return [\n PATH__EXAMPLE,\n PATH__EXAMPLES,\n PATH__EXAMPLE__PARAMETER,\n PATH__EXAMPLES__PARAMETER,\n PATH__EXAMPLE__REQUEST_BODY,\n PATH__EXAMPLES__REQUEST_BODY\n ];\n}\n\n/**\n * Builds a map with the json-pointers to the response-schema as key and the json-pointers to the examples, as value.\n * The pointer of the schema is derived from the pointer to the example and doesn't necessarily mean\n * that the schema actually exists.\n * @param {Array.} pathsExamples Paths to the examples\n * @returns {Object.} Map with schema-pointers as key and example-pointers as value\n * @private\n */\nfunction buildValidationMap(pathsExamples) {\n const exampleTypesOfSchemas = new Map();\n return pathsExamples.reduce((validationMap, pathExample) => {\n const { pathSchemaAsArray, exampleType } = _getSchemaPointerOfExample(pathExample),\n pathSchema = pathSchemaAsArray.join('/'),\n exampleTypeOfSchema = exampleTypesOfSchemas.get(pathSchema);\n if (exampleTypeOfSchema) {\n exampleTypeOfSchema !== exampleType && _throwMutuallyExclusiveError(pathSchemaAsArray);\n }\n exampleTypesOfSchemas.set(pathSchema, exampleType);\n validationMap[pathSchema] = (validationMap[pathSchema] || new Set())\n .add(pathExample);\n return validationMap;\n }, {});\n}\n\n/**\n * Pre-processes the OpenAPI-spec, for further use.\n * The passed spec won't be modified. If a modification happens, a modified copy will be returned.\n * @param {Object} openapiSpec The OpenAPI-spec as JSON-schema\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @return {Object} The prepared OpenAPI-spec\n */\nfunction prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired } = {}) {\n const openapiSpecCopy = cloneDeep(openapiSpec);\n noAdditionalProperties && setNoAdditionalProperties(openapiSpecCopy, getJsonPathsToExamples());\n allPropertiesRequired && setAllPropertiesRequired(openapiSpecCopy, getJsonPathsToExamples());\n return openapiSpecCopy;\n}\n\n/**\n * Gets a JSON-pointer to the corresponding response-schema, based on a JSON-pointer to an example.\n *\n * It is assumed that the JSON-pointer to the example is valid and existing.\n * @param {String} examplePointer JSON-pointer to example\n * @returns {{\n * exampleType: ExampleType,\n * pathSchema: String\n * }} JSON-path to the corresponding response-schema\n * @private\n */\nfunction _getSchemaPointerOfExample(examplePointer) {\n const pathSegs = examplePointer.split('/'),\n idxExample = pathSegs.lastIndexOf(PROP__EXAMPLE),\n /** @type ExampleType */\n exampleType = idxExample > -1\n ? ExampleType.single\n : ExampleType.multi,\n idxExamples = exampleType === ExampleType.single\n ? idxExample\n : pathSegs.lastIndexOf(PROP__EXAMPLES);\n pathSegs.splice(idxExamples, pathSegs.length - idxExamples, PROP__SCHEMA);\n return {\n exampleType,\n pathSchemaAsArray: pathSegs\n };\n}\n\n\n/**\n * Checks if only `example` or `examples` is set for the schema, as they are mutually exclusive by OpenAPI-spec.\n * @param {Array.} pathSchemaAsArray JSON-path to the Schema, as JSON-path-array\n * @throws ApplicationError if both are set\n * @private\n */\nfunction _throwMutuallyExclusiveError(pathSchemaAsArray) {\n const pathContextAsArray = pathSchemaAsArray.slice(0, pathSchemaAsArray.length - 1); // Strip `schema` away\n throw ApplicationError.create({\n type: ErrorType.errorAndErrorsMutuallyExclusive,\n message: 'Properties \"error\" and \"errors\" are mutually exclusive',\n params: {\n pathContext: pathContextAsArray.join('/')\n }\n });\n}\n","/**\n * Entry-point for the validator-API\n */\n\nconst\n merge = require('lodash.merge'),\n flatten = require('lodash.flatten'),\n flatMap = require('lodash.flatmap'),\n jsonPointer = require('json-pointer'),\n fs = require('fs'),\n path = require('path'),\n glob = require('glob'),\n yaml = require('yaml'),\n { JSONPath: jsonPath } = require('jsonpath-plus'),\n refParser = require('json-schema-ref-parser'),\n { createError } = require('errno').custom,\n ResultType = require('./const/result-type'),\n { getValidatorFactory, compileValidate } = require('./validator'),\n Determiner = require('./impl'),\n { ApplicationError, ErrorType } = require('./application-error'),\n { createValidationResponse, dereferenceJsonSchema } = require('./utils');\n\n// CONSTANTS\n\nconst SYM__INTERNAL = Symbol('internal'),\n PROP__SCHEMAS_WITH_EXAMPLES = 'schemasWithExamples',\n FILE_EXTENSIONS__YAML = [\n 'yaml',\n 'yml'\n ];\n\n// STATICS\n\n/**\n * ErrorJsonPathNotFound\n * @typedef {{\n * cause: {\n * [params]: {\n * [path]: string\n * }\n * }\n * }} ErrorJsonPathNotFound\n * @augments CustomError\n */\n\n/**\n * @constructor\n * @augments CustomError\n * @returns {ErrorJsonPathNotFound}\n */\nconst ErrorJsonPathNotFound = createError(ErrorType.jsonPathNotFound);\n\n// PUBLIC API\n\nmodule.exports = {\n 'default': validateExamples,\n validateFile,\n validateExample,\n validateExamplesByMap\n};\n\n// IMPLEMENTATION DETAILS\n\n// Type definitions\n\n/**\n * ValidationStatistics\n * @typedef {{\n * schemasWithExamples: number,\n * examplesTotal: number,\n * examplesWithoutSchema: number,\n * [matchingFilePathsMapping]: number\n * }} ValidationStatistics\n */\n\n/**\n * ValidationResponse\n * @typedef {{\n * valid: boolean,\n * statistics: ValidationStatistics,\n * errors: Array.\n * }} ValidationResponse\n */\n\n/**\n * @callback ValidationHandler\n * @param {ValidationStatistics} statistics\n * @returns {Array.}\n */\n\n// Public\n\n/**\n * Validates OpenAPI-spec with embedded examples.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExamples(openapiSpec, { noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}) {\n const impl = Determiner.getImplementation(openapiSpec);\n openapiSpec = await refParser.dereference(openapiSpec);\n openapiSpec = impl.prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n let pathsExamples = impl.getJsonPathsToExamples()\n .reduce((res, pathToExamples) => {\n return res.concat(_pathToPointer(pathToExamples, openapiSpec));\n }, []);\n return _validateExamplesPaths({ impl }, pathsExamples, openapiSpec, { ignoreFormats });\n}\n\n/**\n * Validates OpenAPI-spec with embedded examples.\n * @param {string} filePath File-path to the OpenAPI-spec\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateFile(filePath, { noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}) {\n let openapiSpec = null;\n try {\n openapiSpec = await _parseSpec(filePath);\n } catch (err) {\n return createValidationResponse({ errors: [ApplicationError.create(err)] });\n }\n return validateExamples(openapiSpec, { noAdditionalProperties, ignoreFormats, allPropertiesRequired });\n}\n\n/**\n * Validates examples by mapping-files.\n * @param {string} filePathSchema File-path to the OpenAPI-spec\n * @param {string} globMapExternalExamples File-path (globs are supported) to the mapping-file containing JSON-\n * paths to schemas as key and a single file-path or Array of file-paths\n * to external examples\n * @param {boolean} [cwdToMappingFile=false] Change working directory for resolving the example-paths (relative to\n * the mapping-file)\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not defined in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExamplesByMap(filePathSchema, globMapExternalExamples,\n { cwdToMappingFile, noAdditionalProperties, ignoreFormats, allPropertiesRequired } = {}\n) {\n let matchingFilePathsMapping = 0;\n const filePathsMaps = glob.sync(\n globMapExternalExamples,\n // Using `nonull`-option to explicitly create an app-error if there's no match for `globMapExternalExamples`\n { nonull: true }\n );\n let responses = [];\n // for..of here, to support sequential execution of async calls. This is required, since dereferencing the\n // `openapiSpec` is not concurrency-safe\n for (const filePathMapExternalExamples of filePathsMaps) {\n let mapExternalExamples = null,\n openapiSpec = null;\n try {\n mapExternalExamples = JSON.parse(fs.readFileSync(filePathMapExternalExamples, 'utf-8'));\n openapiSpec = await _parseSpec(filePathSchema);\n openapiSpec = Determiner.getImplementation(openapiSpec)\n .prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n } catch (err) {\n responses.push(createValidationResponse({ errors: [ApplicationError.create(err)] }));\n continue;\n }\n // Not using `glob`'s response-length, because it is `1` if there's no match for `globMapExternalExamples`.\n // Instead, increment on every match\n matchingFilePathsMapping++;\n responses.push(\n _validate(\n statistics => {\n return _handleExamplesByMapValidation(\n openapiSpec, mapExternalExamples, statistics, {\n cwdToMappingFile,\n dirPathMapExternalExamples: path.dirname(filePathMapExternalExamples),\n ignoreFormats\n }\n ).map(\n (/** @type ApplicationError */ error) => Object.assign(error, {\n mapFilePath: path.normalize(filePathMapExternalExamples)\n })\n );\n }\n )\n );\n }\n return merge(\n responses.reduce((res, response) => {\n if (!res) {\n return response;\n }\n return _mergeValidationResponses(res, response);\n }, null),\n { statistics: { matchingFilePathsMapping } }\n );\n}\n\n/**\n * Validates a single external example.\n * @param {String} filePathSchema File-path to the OpenAPI-spec\n * @param {String} pathSchema JSON-path to the schema\n * @param {String} filePathExample File-path to the external example-file\n * @param {boolean} [noAdditionalProperties=false] Don't allow properties that are not described in the schema\n * @param {boolean} [allPropertiesRequired=false] Make all properties required\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n */\nasync function validateExample(filePathSchema, pathSchema, filePathExample, {\n noAdditionalProperties,\n ignoreFormats,\n allPropertiesRequired\n} = {}) {\n let example = null,\n schema = null,\n openapiSpec = null;\n try {\n example = JSON.parse(fs.readFileSync(filePathExample, 'utf-8'));\n openapiSpec = await _parseSpec(filePathSchema);\n openapiSpec = Determiner.getImplementation(openapiSpec)\n .prepare(openapiSpec, { noAdditionalProperties, allPropertiesRequired });\n schema = _extractSchema(_getSchmaPointer(pathSchema, openapiSpec), openapiSpec);\n } catch (err) {\n return createValidationResponse({ errors: [ApplicationError.create(err)] });\n }\n return _validate(\n statistics => _validateExample({\n createValidator: _initValidatorFactory(openapiSpec, { ignoreFormats }),\n schema,\n example,\n statistics,\n filePathExample\n })\n );\n}\n\n// Private\n\n/**\n * Parses the OpenAPI-spec (supports JSON and YAML)\n * @param {String} filePath File-path to the OpenAPI-spec\n * @returns {object} Parsed OpenAPI-spec\n * @private\n */\nasync function _parseSpec(filePath) {\n const isYaml = _isFileTypeYaml(filePath);\n let jsonSchema;\n\n if (isYaml) {\n try {\n jsonSchema = yaml.parse(fs.readFileSync(filePath, 'utf-8'));\n } catch (e) {\n const { name, message } = e;\n throw new ApplicationError(ErrorType.parseError, { message: `${name}: ${message}` });\n }\n } else {\n jsonSchema = JSON.parse(fs.readFileSync(filePath, 'utf-8'));\n }\n\n return await dereferenceJsonSchema(filePath, jsonSchema);\n}\n\n/**\n * Determines whether the filePath is pointing to a YAML-file\n * @param {String} filePath File-path to the OpenAPI-spec\n * @returns {boolean} `true`, if the file is a YAML-file\n * @private\n */\nfunction _isFileTypeYaml(filePath) {\n const extension = filePath.split('.').pop();\n return FILE_EXTENSIONS__YAML.includes(extension);\n}\n\n/**\n * Top-level validator. Prepares common values, required for the validation, then calles the validator and prepares\n * the result for the output.\n * @param {ValidationHandler} validationHandler The handler which performs the validation. It will receive the\n * statistics-object as argument and has to return an Array of\n * errors (or an empty Array, when all examples are valid)\n * @returns {ValidationResponse}\n * @private\n */\nfunction _validate(validationHandler) {\n const statistics = _initStatistics(),\n errors = validationHandler(statistics);\n return createValidationResponse({ errors, statistics });\n}\n\n/**\n * Validates examples by a mapping-file.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {Object} mapExternalExamples Mapping-file containing JSON-paths to schemas as\n * key and a single file-path or Array of file-paths\n * to external examples\n * @param {ValidationStatistics} statistics Validation-statistics\n * @param {boolean} [cwdToMappingFile=false] Change working directory for resolving the example-\n * paths (relative to the mapping-file)\n * @param {string} [dirPathMapExternalExamples] The directory-path of the mapping-file\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {Array.}\n * @private\n */\nfunction _handleExamplesByMapValidation(openapiSpec, mapExternalExamples, statistics,\n { cwdToMappingFile = false, dirPathMapExternalExamples, ignoreFormats }\n) {\n return flatMap(Object.entries(mapExternalExamples), ([pathSchema, filePathsExample]) => {\n let schema = null;\n try {\n schema = _extractSchema(_getSchmaPointer(pathSchema, openapiSpec), openapiSpec);\n } catch (/** @type ErrorJsonPathNotFound */ err) {\n // If the schema can't be found, don't even attempt to process the examples\n return ApplicationError.create(err);\n }\n return flatMap(\n flatten([filePathsExample]),\n filePathExample => {\n let examples = [];\n try {\n const resolvedFilePathExample = cwdToMappingFile\n ? path.join(dirPathMapExternalExamples, filePathExample)\n : filePathExample;\n const globResolvedFilePathExample = glob.sync(resolvedFilePathExample);\n if (globResolvedFilePathExample.length === 0) {\n return [ApplicationError.create({\n type: ErrorType.jsENOENT,\n message: `No such file or directory: '${resolvedFilePathExample}'`,\n path: resolvedFilePathExample\n })];\n }\n for (const filePathExample of globResolvedFilePathExample) {\n examples.push({\n path: path.normalize(filePathExample),\n content: JSON.parse(fs.readFileSync(filePathExample, 'utf-8'))\n });\n }\n } catch (err) {\n return [ApplicationError.create(err)];\n }\n return flatMap(examples, example => _validateExample({\n createValidator: _initValidatorFactory(openapiSpec, { ignoreFormats }),\n schema,\n example: example.content,\n statistics,\n filePathExample: example.path\n }));\n }\n );\n });\n}\n\n\n/**\n * Merges two `ValidationResponses` together and returns the merged result. The passed `ValidationResponse`s won't be\n * modified.\n * @param {ValidationResponse} response1\n * @param {ValidationResponse} response2\n * @returns {ValidationResponse}\n * @private\n */\nfunction _mergeValidationResponses(response1, response2) {\n return createValidationResponse({\n errors: response1.errors.concat(response2.errors),\n statistics: Object.entries(response1.statistics)\n .reduce((res, [key, val]) => {\n if (PROP__SCHEMAS_WITH_EXAMPLES === key) {\n [\n response1,\n response2\n ].forEach(response => {\n const schemasWithExample = response.statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES]\n .values();\n for (let schema of schemasWithExample) {\n res[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].add(schema);\n }\n });\n return res;\n }\n res[key] = val + response2.statistics[key];\n return res;\n }, _initStatistics())\n });\n}\n\n/**\n * Extract JSON-pointer(s) for specific path from a OpenAPI-spec\n * @param {String} path JSON-path in the OpenAPI-Spec\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {Array.} JSON-pointers to matching elements\n * @private\n */\nfunction _pathToPointer(path, openapiSpec) {\n return jsonPath({\n json: openapiSpec,\n path: path,\n resultType: ResultType.pointer\n });\n}\n/**\n * Extract JSON-pointer(s) for specific path from a OpenAPI-spec\n * @param {String} path JSON-path in the OpenAPI-Spec\n * @param {Object} openapiSpec OpenAPI-spec\n * @returns {String} JSON-pointer to schema or throws error\n * @private\n */\nfunction _getSchmaPointer(pathSchema, openapiSpec) {\n const schemaPointers = _pathToPointer(pathSchema, openapiSpec);\n if (schemaPointers.length === 0) {\n _pathToSchemaNotFoundError(pathSchema);\n }\n if (schemaPointers.length > 1) {\n return [ApplicationError.create({\n type: ErrorType.jsonPathNotFound,\n message: `Path to schema cannot identify unique schema: '${pathSchema}'`,\n path: pathSchema\n })];\n }\n return schemaPointers[0];\n}\n\n/**\n * Validates examples at the given paths in the OpenAPI-spec.\n * @param {Object} impl Spec-dependant validator\n * @param {Array.} pathsExamples JSON-paths to examples\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {Array.} [ignoreFormats] List of datatype formats that shall be ignored (to prevent\n * \"unsupported format\" errors). If an Array with only one string is\n * provided where the formats are separated with `\\n`, the entries\n * will be expanded to a new array containing all entries.\n * @returns {ValidationResponse}\n * @private\n */\nfunction _validateExamplesPaths({ impl }, pathsExamples, openapiSpec, { ignoreFormats }) {\n const statistics = _initStatistics(),\n validationResult = {\n valid: true,\n statistics,\n errors: []\n },\n createValidator = _initValidatorFactory(openapiSpec, { ignoreFormats });\n let validationMap;\n try {\n // Create mapping between JSON-schemas and examples\n validationMap = impl.buildValidationMap(pathsExamples);\n } catch (error) {\n // Throw unexpected errors\n if (!(error instanceof ApplicationError)) {\n throw error;\n }\n // Add known errors and stop\n validationResult.valid = false;\n validationResult.errors.push(error);\n return validationResult;\n }\n // Start validation\n const schemaPointers = Object.keys(validationMap);\n schemaPointers.forEach(schemaPointer => {\n _validateSchema({\n openapiSpec, createValidator, schemaPointer, validationMap, statistics,\n validationResult\n });\n });\n return validationResult;\n}\n\n/**\n * Validates a single schema.\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {ajv} createValidator Factory, to create JSON-schema validator\n * @param {string} schemaPointer JSON-pointer to schema (for request- or response-property)\n * @param {Object.} validationMap Map with schema-pointers as key and example-pointers as value\n * @param {Object} statistics Object to contain statistics metrics\n * @param {Object} validationResult Container, for the validation-results\n * @private\n */\nfunction _validateSchema({\n openapiSpec, createValidator, schemaPointer, validationMap, statistics,\n validationResult\n}) {\n const errors = validationResult.errors;\n validationMap[schemaPointer].forEach(pathExample => {\n const example = _getByPointer(pathExample, openapiSpec),\n // Examples with missing schemas may occur and those are considered valid\n schema = _extractSchema(schemaPointer, openapiSpec, true);\n const curErrors = _validateExample({\n createValidator,\n schema,\n example,\n statistics\n }).map(error => {\n error.examplePath = pathExample;\n return error;\n });\n if (!curErrors.length) {\n return;\n }\n validationResult.valid = false;\n errors.splice(errors.length - 1, 0, ...curErrors);\n });\n}\n\n/**\n * Creates a container-object for the validation statistics.\n * @returns {ValidationStatistics}\n * @private\n */\nfunction _initStatistics() {\n const statistics = {\n [SYM__INTERNAL]: {\n [PROP__SCHEMAS_WITH_EXAMPLES]: new Set()\n },\n examplesTotal: 0,\n examplesWithoutSchema: 0\n };\n Object.defineProperty(statistics, PROP__SCHEMAS_WITH_EXAMPLES, {\n enumerable: true,\n get: () => statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].size\n });\n return statistics;\n}\n\n/**\n * Extract object by the given JSON-pointer\n * @param {String} pointer JSON-pointer\n * @param {Object} json JSON to extract the object(s) from\n * @returns {Object} Extracted object\n */\nfunction _getByPointer(pointer, json) {\n try {\n return jsonPointer.get(json, pointer);\n } catch (_) {\n return undefined;\n }\n}\n\n/**\n * Validates example against the schema. The precondition for this function to work is that the example exists at the\n * given path.\n * `pathExample` and `filePathExample` are exclusively mandatory.\n * itself\n * @param {Function} createValidator Factory, to create JSON-schema validator\n * @param {Object} schema JSON-schema\n * @param {Object} example Example to validate\n * @param {Object} statistics Object to contain statistics metrics\n * @param {String} [filePathExample] File-path to the example file\n * @returns {Array.} Array with errors. Empty array, if examples are valid\n * @private\n */\nfunction _validateExample({ createValidator, schema, example, statistics, filePathExample }) {\n const\n errors = [];\n statistics.examplesTotal++;\n // No schema, no validation (Examples without schema are considered valid)\n if (!schema) {\n statistics.examplesWithoutSchema++;\n return errors;\n }\n statistics[SYM__INTERNAL][PROP__SCHEMAS_WITH_EXAMPLES].add(schema);\n const validate = compileValidate(createValidator(), schema);\n if (validate(example)) {\n return errors;\n }\n return errors.concat(...validate.errors.map(ApplicationError.create))\n .map(error => {\n if (!filePathExample) {\n return error;\n }\n error.exampleFilePath = filePathExample;\n return error;\n });\n}\n\n/**\n * Create a new instance of a JSON schema validator\n * @returns {ajv}\n * @private\n */\nfunction _initValidatorFactory(specSchema, { ignoreFormats }) {\n return getValidatorFactory(specSchema, {\n schemaId: 'auto',\n discriminator: true,\n strict: false,\n allErrors: true,\n formats: ignoreFormats && ignoreFormats.reduce((result, entry) => {\n result[entry] = () => true;\n return result;\n }, {})\n });\n}\n\n/**\n * Extracts the schema in the OpenAPI-spec at the given JSON-pointer.\n * @param {string} schemaPointer JSON-pointer to the schema\n * @param {Object} openapiSpec OpenAPI-spec\n * @param {boolean} [suppressErrorIfNotFound=false] Don't throw `ErrorJsonPathNotFound` if the response does not\n * exist at the given JSON-pointer\n * @returns {Object|Array.|undefined} Matching schema(s)\n * @throws {ErrorJsonPathNotFound} Thrown, when there is no schema at the given path and\n * `suppressErrorIfNotFound` is false\n * @private\n */\nfunction _extractSchema(schemaPointer, openapiSpec, suppressErrorIfNotFound = false) {\n const schema = _getByPointer(schemaPointer, openapiSpec);\n if (!suppressErrorIfNotFound && !schema) {\n _pathToSchemaNotFoundError(schemaPointer);\n }\n return schema;\n}\n\nfunction _pathToSchemaNotFoundError(schemaPointer) {\n throw new ErrorJsonPathNotFound(`Path to schema can't be found: '${schemaPointer}'`, {\n params: {\n path: schemaPointer\n }\n });\n}\n","const path = require('path'),\n refParser = require('json-schema-ref-parser');\n\nmodule.exports = {\n createValidationResponse,\n dereferenceJsonSchema\n};\n\n/**\n * Creates a unified response for the validation-result\n * @param {Array.} errors\n * @param {ValidationStatistics} statistics\n * @returns {ValidationResponse}\n * @private\n */\nfunction createValidationResponse({ errors, statistics = {} }) {\n return {\n valid: !errors.length,\n statistics,\n errors\n };\n}\n\n/**\n * Includes all referenced, external schemas (by the keyword `$ref`) into the schema\n *\n * CAUTION: This function is not concurrency-safe !!\n * This function changes the working dir and sets it back. This may become an concurrency issue when there are\n * other tasks running that rely on the working dir while this function waits for the asynchronous task of\n * dereferencing to complete.\n *\n * @param {String} pathToSchema File-path to the schema\n * @param {Object} jsonSchema Schema with potential externally referenced schemas\n * @returns {Promise} Dereferenced schema\n */\nasync function dereferenceJsonSchema(pathToSchema, jsonSchema) {\n const currentWorkingDir = process.cwd();\n // Change the working dir to the schema-path, to make sure that relative paths can be resolved\n process.chdir(path.dirname(pathToSchema));\n const dereferencedSchema = await refParser.dereference(jsonSchema);\n // Restore original working dir\n process.chdir(currentWorkingDir);\n return dereferencedSchema;\n}\n","/**\n * Wrapper for the JSONSchema-validator\n */\n\nconst { JSONPath: jsonPath } = require('jsonpath-plus'),\n JsonPointer = require('json-pointer'),\n Ajv = require('ajv-draft-04'),\n addFormats = require('ajv-formats');\n\nconst PROP__ID = '$id',\n JSON_PATH__REFS = '$..\\$ref',\n ID__SPEC_SCHEMA = 'https://www.npmjs.com/package/openapi-examples-validator/defs.json',\n ID__RESPONSE_SCHEMA = 'https://www.npmjs.com/package/openapi-examples-validator/schema.json';\n\nmodule.exports = {\n getValidatorFactory,\n compileValidate\n};\n\n/**\n * Get a factory-function to create a prepared validator-instance\n * @param {Object} specSchema OpenAPI-spec of which potential local references will be extracted\n * @param {Object} [options] Options for the validator\n * @returns {function(): (ajv | ajv.Ajv)}\n */\nfunction getValidatorFactory(specSchema, options) {\n const preparedSpecSchema = _createReferenceSchema(specSchema);\n return () => {\n const validator = new Ajv(options);\n addFormats(validator);\n\n validator.addSchema(preparedSpecSchema);\n\n return validator;\n };\n}\n\n/**\n * Compiles the validator-function.\n * @param {ajv | ajv.Ajv} validator Validator-instance\n * @param {Object} responseSchema The response-schema, against the examples will be validated\n * @returns {ajv.ValidateFunction}\n */\nfunction compileValidate(validator, responseSchema) {\n const preparedResponseSchema = _prepareResponseSchema(responseSchema, ID__RESPONSE_SCHEMA);\n _replaceRefsToPreparedSpecSchema(preparedResponseSchema);\n\n let result;\n try {\n result = validator.compile(preparedResponseSchema);\n } catch (e) {\n result = () => {};\n result.errors = [e];\n }\n return result;\n}\n\n/**\n * Prepares the schema, to be used with internal-references\n * @param {Object} specSchema The schema to be prebared\n * @param {String} idSchema The unique ID for the schema\n * @returns {Object}\n * @private\n */\nfunction _prepareResponseSchema(specSchema, idSchema) {\n const preparedSchema = Object.assign({}, specSchema);\n preparedSchema[PROP__ID] = idSchema;\n return preparedSchema;\n}\n\n/**\n * Replaces all internal references to the schema, with the extracted references, based on the origin OpenAPI-spec\n * @param {Object} schema The schema, containing references have to be replaced\n * @private\n */\nfunction _replaceRefsToPreparedSpecSchema(schema) {\n jsonPath({\n path: JSON_PATH__REFS,\n json: schema,\n callback(value, type, payload) {\n if (!value.startsWith('#')) { return; }\n payload.parent[payload.parentProperty] = `${ ID__SPEC_SCHEMA }${ value }`;\n }\n });\n}\n\n/**\n * Extracts all references and returns a new schema, containing only those.\n * @param {Object} specSchema Schema, which references shall be extracted\n * @returns {Object}\n * @private\n */\nfunction _createReferenceSchema(specSchema) {\n const refSchema = {\n [PROP__ID]: ID__SPEC_SCHEMA\n };\n jsonPath({\n path: JSON_PATH__REFS,\n json: specSchema,\n callback(value) {\n if (!value.startsWith('#')) { return; }\n const pointer = value.substring(1),\n definition = JsonPointer.get(specSchema, pointer);\n JsonPointer.set(refSchema, pointer, definition);\n }\n });\n return refSchema;\n}\n","module.exports = {\"name\":\"openapi-examples-validator\",\"version\":\"6.0.1\",\"description\":\"Validates embedded examples in OpenAPI-JSONs\",\"main\":\"dist/index.js\",\"engines\":{\"node\":\">=18\"},\"bin\":{\"openapi-examples-validator\":\"dist/cli.js\"},\"standard-version\":{\"scripts\":{\"postchangelog\":\"npm run release:create-dockerfile && npm run release:stage-artifacts\"}},\"scripts\":{\"start-dev\":\"babel-node src/cli\",\"build\":\"npm run build:clean && npm run build:webpack\",\"build:clean\":\"rimraf dist\",\"build:webpack\":\"webpack --bail --progress --profile --mode production --config ./webpack/config.babel.js\",\"coverage\":\"rimraf ./coverage && nyc --reporter=lcov --reporter=text -x \\\"dist/**/*\\\" -x \\\"test/**/*.js\\\" npm test\",\"coveralls\":\"cat ./coverage/lcov.info | coveralls\",\"test\":\"npm run build && npm run test:mocha\",\"test-mutations\":\"stryker run\",\"test:mocha\":\"mocha --require \\\"./test/util/setup-tests\\\" --recursive \\\"./test/specs/**/*.js\\\"\",\"release\":\"npm run build && standard-version -a\",\"release:create-dockerfile\":\"npm run build && node etc/src/build-dockerfile.js\",\"release:stage-artifacts\":\"git add dist/*\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/codekie/openapi-examples-validator.git\"},\"keywords\":[\"swagger\",\"openapi\",\"json\",\"validate\",\"examples\"],\"author\":\"Josua Amann\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://github.com/codekie/openapi-examples-validator/issues\"},\"homepage\":\"https://github.com/codekie/openapi-examples-validator#readme\",\"devDependencies\":{\"@babel/cli\":\"^7.25.9\",\"@babel/core\":\"^7.26.0\",\"@babel/eslint-parser\":\"^7.25.9\",\"@babel/node\":\"^7.26.0\",\"@babel/preset-env\":\"^7.26.0\",\"@babel/register\":\"^7.25.9\",\"@stryker-mutator/core\":\"^8.6.0\",\"@stryker-mutator/mocha-runner\":\"^8.6.0\",\"babel-loader\":\"^9.2.1\",\"chai\":\"^4.3.6\",\"chai-string\":\"^1.5.0\",\"core-js-pure\":\"^3.39.0\",\"coveralls\":\"^3.1.1\",\"eslint\":\"^8.41.0\",\"eslint-webpack-plugin\":\"^4.2.0\",\"json-loader\":\"^0.5.7\",\"mocha\":\"^10.8.2\",\"mocha-lcov-reporter\":\"^1.3.0\",\"nyc\":\"^15.1.0\",\"rimraf\":\"^5.0.1\",\"standard-version\":\"^9.5.0\",\"stryker-cli\":\"^1.0.2\",\"webpack\":\"^5.96.1\",\"webpack-cli\":\"^5.1.4\"},\"dependencies\":{\"ajv\":\"^8.17.1\",\"ajv-draft-04\":\"^1.0.0\",\"ajv-formats\":\"^2.1.1\",\"commander\":\"^6.2.1\",\"errno\":\"^1.0.0\",\"glob\":\"^8.1.0\",\"json-pointer\":\"^0.6.2\",\"json-schema-ref-parser\":\"^9.0.9\",\"jsonpath-plus\":\"^10.2.0\",\"lodash.clonedeep\":\"^4.5.0\",\"lodash.flatmap\":\"^4.5.0\",\"lodash.flatten\":\"^4.4.0\",\"lodash.merge\":\"^4.6.2\",\"yaml\":\"^2.6.1\"}}","module.exports = require(\"ajv-draft-04\");","module.exports = require(\"ajv-formats\");","module.exports = require(\"commander\");","module.exports = require(\"errno\");","module.exports = require(\"glob\");","module.exports = require(\"json-pointer\");","module.exports = require(\"json-schema-ref-parser\");","module.exports = require(\"jsonpath-plus\");","module.exports = require(\"lodash.clonedeep\");","module.exports = require(\"lodash.flatmap\");","module.exports = require(\"lodash.flatten\");","module.exports = require(\"lodash.merge\");","module.exports = require(\"yaml\");","module.exports = require(\"fs\");","module.exports = require(\"path\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(115);\n"],"names":["merge","require","ENOENT","ErrorType","jsENOENT","code","jsonPathNotFound","errorAndErrorsMutuallyExclusive","parseError","validation","ApplicationError","create","err","message","path","cause","type","options","params","constructor","Object","assign","this","module","exports","VERSION","program","validateFile","validateExample","validateExamplesByMap","ENV_TEST","process","env","OPENAPI_EXAMPLES_VALIDATOR_TESTS","version","arguments","description","option","action","async","filepath","schemaJsonpath","exampleFilepath","mappingFilepath","cwdToMappingFile","allPropertiesRequired","noAdditionalProperties","additionalProperties","ignoreFormats","Array","isArray","length","indexOf","split","filter","entry","match","_prepareIgnoreFormats","result","console","log","noExit","statistics","schemasWithExamples","examplesWithoutSchema","examplesTotal","matchingFilePathsMapping","strStatistics","push","stdout","write","join","_printStatistics","valid","exit","stderr","JSON","stringify","errors","_handleResult","on","parseAsync","argv","parent","parentProperty","pointer","value","implV2","implV3","REGEX__OPEN_API","getImplementation","openapiSpec","swagger","openapi","applyCallbackToAllObjectModels","setAllPropertiesRequired","openApiSpec","examplePaths","hasOwnProperty","required","keys","properties","JSONPath","jsonPath","ResultType","_find","json","resultType","callback","flatten","matchCallbackBuilder","paths","Set","forEach","consecutiveMatch","_isPropertiesDefinition","add","examplePath","exampleMatch","jsPath","startsWith","delete","_excludeExamples","data","entity","setNoAdditionalProperties","hasJsonCombinerParentRegex","RegExp","JSON_SCHEMA_COMBINERS","schema","test","warn","some","combiner","cloneDeep","getJsonPathsToExamples","buildValidationMap","pathsExamples","reduce","validationMap","pathExample","pathSchema","examplePointer","pathSegs","idxExamples","lastIndexOf","splice","_getSchemaPointerOfExample","prepare","openapiSpecCopy","RESPONSES","REQUEST","SINGLE_EXAMPLE","MANY_EXAMPLES","PATH__EXAMPLE","PATH__EXAMPLES","PATH__EXAMPLE__REQUEST_BODY","PATH__EXAMPLES__REQUEST_BODY","ExampleType","exampleTypesOfSchemas","Map","pathSchemaAsArray","exampleType","idxExample","exampleTypeOfSchema","get","pathContextAsArray","slice","pathContext","_throwMutuallyExclusiveError","set","flatMap","jsonPointer","fs","glob","yaml","refParser","createError","getValidatorFactory","compileValidate","Determiner","createValidationResponse","dereferenceJsonSchema","SYM__INTERNAL","Symbol","PROP__SCHEMAS_WITH_EXAMPLES","FILE_EXTENSIONS__YAML","ErrorJsonPathNotFound","validateExamples","impl","dereference","res","pathToExamples","concat","_pathToPointer","_initStatistics","validationResult","createValidator","_initValidatorFactory","error","schemaPointer","example","_getByPointer","_extractSchema","curErrors","_validateExample","map","_validateSchema","_validateExamplesPaths","_parseSpec","filePath","isYaml","extension","pop","includes","_isFileTypeYaml","jsonSchema","parse","readFileSync","e","name","_validate","validationHandler","_handleExamplesByMapValidation","mapExternalExamples","dirPathMapExternalExamples","entries","filePathsExample","_getSchmaPointer","filePathExample","examples","resolvedFilePathExample","globResolvedFilePathExample","sync","normalize","content","schemaPointers","_pathToSchemaNotFoundError","defineProperty","enumerable","size","_","validate","exampleFilePath","specSchema","schemaId","discriminator","strict","allErrors","formats","suppressErrorIfNotFound","filePathSchema","globMapExternalExamples","filePathsMaps","nonull","responses","filePathMapExternalExamples","dirname","mapFilePath","response","response2","response1","key","val","schemasWithExample","values","pathToSchema","currentWorkingDir","cwd","chdir","dereferencedSchema","JsonPointer","Ajv","addFormats","PROP__ID","JSON_PATH__REFS","ID__SPEC_SCHEMA","preparedSpecSchema","refSchema","substring","definition","_createReferenceSchema","validator","addSchema","responseSchema","preparedResponseSchema","preparedSchema","_prepareResponseSchema","payload","compile","__webpack_module_cache__","__webpack_exports__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"sourceRoot":""} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 806bf76..0ffa988 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openapi-examples-validator", - "version": "6.0.0", + "version": "6.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "openapi-examples-validator", - "version": "6.0.0", + "version": "6.0.1", "license": "MIT", "dependencies": { "ajv": "^8.17.1", diff --git a/package.json b/package.json index 8ca1282..5f80ca9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-examples-validator", - "version": "6.0.0", + "version": "6.0.1", "description": "Validates embedded examples in OpenAPI-JSONs", "main": "dist/index.js", "engines": {