openapi-examples-validator
Version:
Validates embedded examples in OpenAPI-JSONs
2 lines • 42.7 kB
JavaScript
(()=>{var e,t,r={476(e,t,r){const o=r(711),{ENOENT:n}=r(184).code,s={jsENOENT:n.code,jsonPathNotFound:"JsonPathNotFound",errorAndErrorsMutuallyExclusive:"ErrorErrorsMutuallyExclusive",parseError:"ParseError",validation:"Validation"};class a{static create(e){const{code:t,message:r,path:n,cause:i}=e,c=t||e.type||s.validation,l={message:r};return s.validation===c||s.errorAndErrorsMutuallyExclusive===c?o(l,e):(n&&o(l,{params:{path:n}}),i&&o(l,i)),new a(c,l)}constructor(e,t={}){Object.assign(this,{type:e,...t})}}e.exports={ApplicationError:a,ErrorType:s}},285(e){e.exports={parent:"parent",parentProperty:"parentProperty",path:"path",pointer:"pointer",value:"value"}},600(e,t,r){const o=r(273),n=r(474),s=/^3\./;e.exports={getImplementation:function(e){return"string"==typeof e.swagger?o:e.openapi&&e.openapi.match(s)?n:null}}},299(e,t,r){const{applyCallbackToAllObjectModels:o}=r(935);e.exports={setAllPropertiesRequired:function(e,t=[]){o(e,t,()=>e=>{e.hasOwnProperty("properties")&&(e.required=Object.keys(e.properties))})}}},935(e,t,r){const{JSONPath:o}=r(940),n=r(285);function s(e,t,r=n.path,s){return o({json:e,path:t,flatten:!0,resultType:r,callback:s})}e.exports={applyCallbackToAllObjectModels:function(e,t,r){const o=new Set;s(e,"$..schema..").forEach(e=>{(function(e){if(!e.match(/\['properties']$/))return;const t=e.match(/(?<!\['properties'])(\['properties']\['properties'])+$/);return!t||t.length%2!=0})(e)||o.add(e)}),function(e,t,r){r.forEach(r=>{s(e,r).forEach(e=>{for(const r of t)r.startsWith(e)&&t.delete(r)})})}(e,o,t);for(const t of o){const o=r(t);s(e,t,n.value,(e,t,r)=>{var n;(n=e)&&("object"===n.type||n.properties)&&o(e,t,r)})}}}},305(e,t,r){const{applyCallbackToAllObjectModels:o}=r(935);e.exports={setNoAdditionalProperties:function(e,t=[]){const r=new RegExp("(?<!\\['properties'\\])\\['(?:"+n.join("|")+")'\\]");o(e,t,e=>t=>{r.test(e)?console.warn(`"additionalProperties" flag not set for ${e} because it has a parent with a JSON-schema combiner keyword.`):n.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 n=["oneOf","allOf","anyOf","not"]},273(e,t,r){const o=r(984),{setAllPropertiesRequired:n}=r(299),{setNoAdditionalProperties:s}=r(305);function a(){return['$..examples[?(@property && typeof @property === "string" && @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:a,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const a=o(e);return t&&s(a,['$..examples[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]']),r&&n(a,['$..examples[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]']),a}}},474(e,t,r){const o=r(984),{ApplicationError:n,ErrorType:s}=r(476),{setAllPropertiesRequired:a}=r(299),{setNoAdditionalProperties:i}=r(305),c='$..responses..content[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]',l='$..requestBody.content[?(@property && typeof @property === "string" && @property.match(/[/+]json/))]',u=".example",f=".examples.*.value",p=`${c}${u}`,h=`${c}${f}`,d=`${l}${u}`,m=`${l}${f}`,y="single";function $(){return[p,h,"$..parameters..example","$..parameters..examples.*.value",d,m]}e.exports={buildValidationMap:function(e){const t=new Map;return e.reduce((e,r)=>{const{pathSchemaAsArray:o,exampleType:a}=function(e){const t=e.split("/"),r=t.lastIndexOf("example"),o=r>-1?y:"multi",n=o===y?r:t.lastIndexOf("examples");return t.splice(n,t.length-n,"schema"),{exampleType:o,pathSchemaAsArray:t}}(r),i=o.join("/"),c=t.get(i);return c&&c!==a&&function(e){const t=e.slice(0,e.length-1);throw n.create({type:s.errorAndErrorsMutuallyExclusive,message:'Properties "error" and "errors" are mutually exclusive',params:{pathContext:t.join("/")}})}(o),t.set(i,a),e[i]=(e[i]||new Set).add(r),e},{})},getJsonPathsToExamples:$,prepare:function(e,{noAdditionalProperties:t,allPropertiesRequired:r}={}){const n=o(e);return t&&i(n,$()),r&&a(n,$()),n}}},427(e,t,r){const o=r(928),n=r(231);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(o.dirname(e));const s=await n.dereference(t);return process.chdir(r),s}}},631(e,t,r){const{JSONPath:o}=r(940),n=r(258),{default:s}=r(804),{default:a}=r(402),i="$id",c="$..$ref",l="https://www.npmjs.com/package/openapi-examples-validator/defs.json";e.exports={getValidatorFactory:function(e,t){const r=function(e){const t={[i]:l};return o({path:c,json:e,callback(r){if(!r.startsWith("#"))return;const o=r.substring(1),s=n.get(e,o);n.set(t,o,s)}}),t}(e);return()=>{const e=new s(t);return a(e),e.addSchema(r),e}},compileValidate:function(e,t){const r=(n=t,{...n,[i]:"https://www.npmjs.com/package/openapi-examples-validator/schema.json"});var n;let s;o({path:c,json:r,callback(e,t,r){e.startsWith("#")&&(r.parent[r.parentProperty]=`${l}${e}`)}});try{s=e.compile(r)}catch(e){s=()=>{},s.errors=[e]}return s}}},804(e){"use strict";e.exports=require("ajv-draft-04")},402(e){"use strict";e.exports=require("ajv-formats")},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")},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")},115(e){"use strict";e.exports=require("yaml")},896(e){"use strict";e.exports=require("fs")},928(e){"use strict";e.exports=require("path")},231(e,t,r){"use strict";function o(e){return e.startsWith("\\\\?\\")?e:e.split("\\").join("/")}r.r(t),r.d(t,{$RefParser:()=>We,$Refs:()=>re,FileResolver:()=>$e,HTTPResolver:()=>ge,InvalidPointerError:()=>B,JSONParserError:()=>S,JSONParserErrorGroup:()=>A,MissingPointerError:()=>F,ParserError:()=>_,ResolverError:()=>T,UnmatchedParserError:()=>I,UnmatchedResolverError:()=>N,bundle:()=>Le,default:()=>Ce,dereference:()=>De,dereferenceInternal:()=>Te,getJsonSchemaRefParserDefaultOptions:()=>we,isHandledError:()=>k,isUnsafeUrl:()=>w,jsonSchemaParserNormalizeArgs:()=>Re,parse:()=>Je,resolve:()=>Ve});const n=/^win/.test(globalThis.process?globalThis.process.platform:""),s=()=>n,a=/\//g,i=/^(\w{2,}):\/\//i,c=/~1/g,l=/~0/g,u=/^[a-zA-Z]:[\\/]/,f=[[/\?/g,"%3F"],[/#/g,"%23"]],p=[/%23/g,"#",/%24/g,"$",/%26/g,"&",/%2C/g,",",/%40/g,"@"],h=e=>new URL(e);function d(e,t){const r=new URL(o(e),"https://aaa.nonexistanturl.com"),n=new URL(o(t),r),s=t.match(/(\s*)$/)?.[1]||"";if("aaa.nonexistanturl.com"===n.hostname){const{pathname:e,search:t,hash:r}=n;return e+t+decodeURIComponent(r)+s}const a=n.toString()+s;if(a.includes("#")){const[e,t]=a.split("#",2);return e+"#"+decodeURIComponent(t||"")}return a}function m(){if("undefined"!=typeof window&&window.location&&window.location.href){const e=window.location.href;if(!e||!e.startsWith("http"))try{return new URL(e),e}catch{return"/"}return e}if("undefined"!=typeof process&&process.cwd){const e=process.cwd(),t=e.slice(-1);return"/"===t||"\\"===t?e:e+"/"}return"/"}function y(e){const t=i.exec(e||"");if(t)return t[1].toLowerCase()}function $(e){const t=e.lastIndexOf(".");return t>=0?function(e){const t=e.indexOf("?");return t>=0&&(e=e.substring(0,t)),e}(e.substring(t).toLowerCase()):""}function g(e){if(!e)return"#";const t=e.indexOf("#");return t>=0?e.substring(t):"#"}function v(e){if(!e)return"";const t=e.indexOf("#");return t>=0&&(e=e.substring(0,t)),e}function w(e){if(!e||"string"!=typeof e)return!0;const t=e.trim().toLowerCase();if(!t)return!0;if(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:"))return!0;if(t.startsWith("file:"))return!0;if("undefined"!=typeof window&&window.location&&window.location.href)return!1;const r=["localhost","127.0.0.1","::1","10.","172.16.","172.17.","172.18.","172.19.","172.20.","172.21.","172.22.","172.23.","172.24.","172.25.","172.26.","172.27.","172.28.","172.29.","172.30.","172.31.","192.168.","169.254.",".local",".internal",".intranet",".corp",".home",".lan"];try{const e=new URL(t.startsWith("//")?"http:"+t:t),o=e.hostname.toLowerCase();for(const e of r)if(o===e||o.startsWith(e)||o.endsWith(e))return!0;if(function(e){const t=e.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(!t)return!1;const[,r,o,n,s]=t.map(Number);return!(r>255||o>255||n>255||s>255)&&(10===r||127===r||172===r&&o>=16&&o<=31||192===r&&168===o||169===r&&254===o)}(o))return!0;const n=e.port;if(n&&function(e){return[22,23,25,53,135,139,445,993,995,1433,1521,3306,3389,5432,5900,6379,8080,8443,9200,27017].includes(e)}(parseInt(n)))return!0}catch{if(t.startsWith("/")&&!t.startsWith("//"))return!1;for(const e of r)if(t.includes(e))return!0}return!1}function x(e){if("undefined"!=typeof window||"undefined"!=typeof process&&process.browser)return!1;const t=y(e);return void 0===t||"file"===t}function E(e,t){e=e.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"),e=decodeURI(e);for(let t=0;t<p.length;t+=2)e=e.replace(p[t],p[t+1]);let r=e.toLowerCase().startsWith("file://");return r&&(e=e.replace(/^file:\/\//,"").replace(/^\//,""),s()&&"/"===e[1]&&(e=`${e[0]}:${e.substring(1)}`),t?e="file:///"+e:(r=!1,e=s()?e:"/"+e)),s()&&!r&&(e=e.replace(a,"\\")).match(/^[a-z]:\\/i)&&(e=e[0].toUpperCase()+e.substring(1)),e}function b(e){return e.length<=1||"#"!==e[0]||"/"!==e[1]?[]:e.slice(2).split("/").map(e=>e.replace(c,"/").replace(l,"~"))}const R=["function","symbol","undefined"],P=["constructor","prototype","__proto__"],j=Object.getPrototypeOf({});function O(){const e={},t=this;for(const r of function(e,t=[]){let r=[];for(;e&&e!==j;)r=r.concat(Object.getOwnPropertyNames(e),Object.getOwnPropertySymbols(e)),e=Object.getPrototypeOf(e);const o=new Set(r);for(const e of t.concat(P))o.delete(e);return o}(t))if("string"==typeof r){const o=t[r],n=typeof o;R.includes(n)||(e[r]=o)}return e}class S extends Error{name;message;source;path;code;constructor(e,t){super(),this.code="EUNKNOWN",this.name="JSONParserError",this.message=e,this.source=t,this.path=null}toJSON=O.bind(this);get footprint(){return`${this.path}+${this.source}+${this.code}+${this.message}`}}class A extends Error{files;constructor(e){super(),this.files=e,this.name="JSONParserErrorGroup",this.message=`${this.errors.length} error${this.errors.length>1?"s":""} occurred while reading '${E(e.$refs._root$Ref.path)}'`}toJSON=O.bind(this);static getParserErrors(e){const t=[];for(const r of Object.values(e.$refs._$refs))r.errors&&t.push(...r.errors);return t}get errors(){return A.getParserErrors(this.files)}}class _ extends S{code="EPARSER";name="ParserError";constructor(e,t){super(`Error parsing ${t}: ${e}`,t)}}class I extends S{code="EUNMATCHEDPARSER";name="UnmatchedParserError";constructor(e){super(`Could not find parser for "${e}"`,e)}}class T extends S{code="ERESOLVER";name="ResolverError";ioErrorCode;constructor(e,t){super(e.message||`Error reading file "${t}"`,t),"code"in e&&(this.ioErrorCode=String(e.code))}}class N extends S{code="EUNMATCHEDRESOLVER";name="UnmatchedResolverError";constructor(e){super(`Could not find resolver for "${e}"`,e)}}class F extends S{code="EMISSINGPOINTER";name="MissingPointerError";targetToken;targetRef;targetFound;parentPath;constructor(e,t,r,o,n){super(`Missing $ref pointer "${g(t)}". Token "${e}" does not exist.`,v(t)),this.targetToken=e,this.targetRef=r,this.targetFound=o,this.parentPath=n}}class M extends S{code="ETIMEOUT";name="TimeoutError";constructor(e){super(`Dereferencing timeout reached: ${e}ms`)}}class B extends S{code="EUNMATCHEDRESOLVER";name="InvalidPointerError";constructor(e,t){super(`Invalid $ref pointer "${e}". Pointers must begin with "#/"`,v(t))}}function k(e){return e instanceof S||e instanceof A}function U(e){return null===e.path&&(e.path=[]),e}function W(e,t){const r=function(e){if(e&&"object"==typeof e&&"$id"in e&&"string"==typeof e.$id&&e.$id.length>0)return e.$id}(t);return r?d(e,r):e}function C(e){if(!e||"object"!=typeof e||ArrayBuffer.isView(e))return!1;const t=e.$schema;if("string"==typeof t&&(t.includes("draft/2019-09/")||t.includes("draft/2020-12/")||t.includes("oas/3.1/")))return!0;const r=e.openapi;return"string"==typeof r&&/^3\.1(?:\.|$)/.test(r)}function q(e,t,r,o,n=!1){if(!n)return;const s=new Set,a=(t,r)=>{if(!t||"object"!=typeof t||ArrayBuffer.isView(t)||s.has(t))return;s.add(t);const i=W(r,t);i!==r&&e._addAlias(i,t,o,n);for(const e of Object.keys(t))a(t[e],i)};a(r,t)}const J=Symbol("null"),V=/\//g,L=/~/g,D=/~1/g,z=/~0/g;class H{$ref;path;originalPath;scopeBase;value;circular;indirections;constructor(e,t,r){this.$ref=e,this.path=t,this.originalPath=r||t,this.scopeBase=e.path||v(t),this.value=void 0,this.circular=!1,this.indirections=0}resolve(e,t,r){const o=H.parse(this.path,this.originalPath),n=[];this.value=Y(e),this.$ref.dynamicIdScope&&!Z(this.$ref)&&(this.scopeBase=W(this.scopeBase,this.value));for(let e=0;e<o.length;e++){const s=this.circular,a=te.isExtended$Ref(this.value);G(this,t,r)?this.path=H.join(this.path,o.slice(e)):!s&&this.circular&&a&&(this.circular=!1);const i=o[e];if(void 0===this.value[i]||null===this.value[i]&&e===o.length-1){let t=!1;for(let r=o.length-1;r>e;r--){const n=o.slice(e,r+1).join("/");if(void 0!==this.value[n]){this.value=this.value[n],e=r,t=!0;break}}if(t)continue;if(i in this.value&&null===this.value[i]){this.value=J;continue}this.value=null;const s=this.$ref.path||"",a=this.path.replace(s,""),c=H.join("",n),l=r?.replace(s,"");throw new F(i,decodeURI(this.originalPath),a,c,l)}this.value=this.value[i],n.push(i),this.$ref.dynamicIdScope&&(this.scopeBase=W(this.scopeBase,this.value))}const s=this.$ref.dynamicIdScope?this.scopeBase:this.path;return(!this.value||this.value.$ref&&d(s,this.value.$ref)!==r)&&G(this,t,r),this}set(e,t,r){const o=H.parse(this.path);let n;if(0===o.length)return this.value=t,t;this.value=Y(e),this.$ref.dynamicIdScope&&!Z(this.$ref)&&(this.scopeBase=W(this.scopeBase,this.value));for(let e=0;e<o.length-1;e++)G(this,r),n=o[e],this.value&&void 0!==this.value[n]?this.value=this.value[n]:this.value=X(this,n,{}),this.$ref.dynamicIdScope&&(this.scopeBase=W(this.scopeBase,this.value));return G(this,r),n=o[o.length-1],X(this,n,t),e}static parse(e,t){const r=g(e).substring(1);if(!r)return[];const o=r.split("/");for(let e=0;e<o.length;e++)o[e]=o[e].replace(D,"/").replace(z,"~");if(""!==o[0])throw new B(r,void 0===t?e:t);return o.slice(1)}static join(e,t){-1===e.indexOf("#")&&(e+="#"),t=Array.isArray(t)?t:[t];for(let r=0;r<t.length;r++)e+="/"+t[r].replace(L,"~0").replace(V,"~1");return e}}function G(e,t,r){if(te.isAllowed$Ref(e.value,t)){const o=d(e.$ref.dynamicIdScope?e.scopeBase:e.path,e.value.$ref);if(o!==e.path||function(e){return"string"==typeof e&&0==H.parse(e).length}(r)){const r=e.$ref.$refs._resolve(o,e.path,t);return null!==r&&(e.indirections+=r.indirections+1,te.isExtended$Ref(e.value)?(e.value=te.dereference(e.value,r.value,t),!1):(e.$ref=r.$ref,e.path=r.path,e.value=r.value,e.scopeBase=e.$ref.path,!0))}e.circular=!0}}const K=H;function X(e,t,r){if(!e.value||"object"!=typeof e.value)throw new S(`Error assigning $ref pointer "${e.path}". \nCannot set "${t}" of a non-object.`);return"-"===t&&Array.isArray(e.value)?e.value.push(r):e.value[t]=r,r}function Y(e){if(k(e))throw e;return e}function Z(e){return Boolean(e.path&&e.path in e.$refs._aliases)}class Q{path;value;$refs;pathType;dynamicIdScope=!1;errors=[];constructor(e){this.$refs=e}addError(e){void 0===this.errors&&(this.errors=[]);const t=this.errors.map(({footprint:e})=>e);"errors"in e&&Array.isArray(e.errors)?this.errors.push(...e.errors.map(U).filter(({footprint:e})=>!t.includes(e))):"footprint"in e&&t.includes(e.footprint)||this.errors.push(U(e))}exists(e,t){try{return this.resolve(e,t),!0}catch{return!1}}get(e,t){return this.resolve(e,t)?.value}resolve(e,t,r,o){const n=new K(this,e,r);try{const e=n.resolve(this.value,t,o);return e.value===J&&(e.value=null),e}catch(e){if(!t||!t.continueOnError||!k(e))throw e;return null===e.path&&(e.path=b(g(o))),e instanceof B&&(e.source=decodeURI(v(o))),this.addError(e),null}}set(e,t){const r=new K(this,e);this.value=r.set(this.value,t),this.value===J&&(this.value=null)}static is$Ref(e){return Boolean(e)&&"object"==typeof e&&null!==e&&"$ref"in e&&"string"==typeof e.$ref&&e.$ref.length>0}static isExternal$Ref(e){return Q.is$Ref(e)&&"#"!==e.$ref[0]}static isAllowed$Ref(e,t){if(this.is$Ref(e)){if("#/"===e.$ref.substring(0,2)||"#"===e.$ref)return!0;if("#"!==e.$ref[0]&&(!t||t.resolve?.external))return!0}}static isExtended$Ref(e){return Q.is$Ref(e)&&Object.keys(e).length>1}static dereference(e,t,r){if(t&&"object"==typeof t&&Q.isExtended$Ref(e)){const o={};for(const t of Object.keys(e))"$ref"!==t&&(o[t]=e[t]);const n=r?.dereference?.mergeKeys??!0;for(const e of Object.keys(t)){const r=e;r in o?n&&"object"==typeof o[r]&&null!==o[r]&&"object"==typeof t[r]&&null!==t[r]&&(o[r]=ee(t[r],o[r])):o[r]=t[r]}return o}return t}}function ee(e,t){if("object"!=typeof e||null===e)return t;if("object"!=typeof t||null===t)return t;const r=Array.isArray(e)?[...e]:{...e};for(const o of Object.keys(t))Array.isArray(t[o])?r[o]=[...t[o]]:"object"==typeof t[o]&&null!==t[o]?r[o]=ee(e[o],t[o]):r[o]=t[o];return r}const te=Q;class re{circular;paths(...e){return oe(this._$refs,e.flat()).map(e=>o(e.decoded))}values(...e){const t=this._$refs;return oe(t,e.flat()).reduce((e,r)=>(e[o(r.decoded)]=t[r.encoded].value,e),{})}exists(e,t){try{return this._resolve(e,"",t),!0}catch{return!1}}get(e,t){return this._resolve(e,"",t).value}set(e,t){const r=d(this._root$Ref.path,e),o=this._getRef(r);if(!o)throw new Error(`Error resolving $ref pointer "${e}". \n"${v(r)}" not found.`);o.set(r,t)}_get$Ref(e){return e=d(this._root$Ref.path,e),this._getRef(e)}_add(e){const t=v(e),r=new te(this);return r.path=t,this._$refs[t]=r,this._root$Ref=this._root$Ref||r,r}_addAlias(e,t,r,o=!1){const n=v(e);if(!n||this._$refs[n]||this._aliases[n])return this._$refs[n]||this._aliases[n];const s=new te(this);return s.path=n,s.pathType=r,s.value=t,s.dynamicIdScope=o,this._aliases[n]=s,s}_resolve(e,t,r){const o=d(this._root$Ref.path,e),n=this._getRef(o);if(!n)throw new Error(`Error resolving $ref pointer "${e}". \n"${v(o)}" not found.`);return n.resolve(o,r,e,t)}_$refs={};_aliases={};_root$Ref;constructor(){this.circular=!1,this._$refs={},this._aliases={},this._root$Ref=null}toJSON=this.values;_getRef(e){const t=v(e);return this._$refs[t]||this._aliases[t]}}function oe(e,t){let r=Object.keys(e);return(t=Array.isArray(t[0])?t[0]:Array.prototype.slice.call(t)).length>0&&t[0]&&(r=r.filter(r=>t.includes(e[r].pathType))),r.map(t=>({encoded:t,decoded:"file"===e[t].pathType?E(t,!0):t}))}function ne(e){return Object.keys(e||{}).filter(t=>"object"==typeof e[t]).map(t=>(e[t].name=t,e[t]))}function se(e,t,r,o,n){return e.filter(e=>!!ce(e,t,r,o,n))}function ae(e){for(const t of e)t.order=t.order||Number.MAX_SAFE_INTEGER;return e.sort((e,t)=>e.order-t.order)}async function ie(e,t,r,o){let n,s,a=0;return new Promise((i,c)=>{function l(){if(n=e[a++],!n)return c(s);try{const s=ce(n,t,r,u,o);if(s&&"function"==typeof s.then)s.then(f,p);else if(void 0!==s)f(s);else if(a===e.length)throw new Error("No promise has been returned or callback has been called.")}catch(e){p(e)}}function u(e,t){e?p(e):f(t)}function f(e){i({plugin:n,result:e})}function p(e){s={plugin:n,error:e},l()}l()})}function ce(e,t,r,o,n){const s=e[t];if("function"==typeof s)return s.apply(e,[r,o,n]);if(!o){if(s instanceof RegExp)return s.test(r.url);if("string"==typeof s)return s===r.extension;if(Array.isArray(s))return-1!==s.indexOf(r.extension)}return s}const le=async function(e,t,r){let o="string"==typeof e?e:e.url;const n="string"==typeof e?void 0:e.baseUrl;let s="string"==typeof e?void 0:e.reference;const a=o.indexOf("#");let i="";if(a>=0&&(i=o.substring(a),o=o.substring(0,a)),s){const e=s.indexOf("#");e>=0&&(s=s.substring(0,e))}const c=t._add(o),l={url:o,hash:i,extension:$(o),...void 0!==s?{reference:s}:{},...void 0!==n?{baseUrl:n}:{}};try{const e=await async function(e,t,r){let o=ne(t.resolve);o=se(o,"canRead",e,void 0,r),ae(o);try{return await ie(o,"read",e,r)}catch(r){throw!r&&t.continueOnError?new N(e.url):r&&"error"in r?r.error instanceof T?r.error:new T(r,e.url):new SyntaxError(`Unable to resolve $ref pointer "${e.url}"`,{cause:r})}}(l,r,t);c.pathType=e.plugin.name,l.data=e.result;const o=await async function(e,t,r){const o=ne(t.parse),n=se(o,"canParse",e),s=n.length>0?n:o;ae(s);try{const t=await ie(s,"parse",e,r);if(!t.plugin.allowEmpty&&(void 0===(a=t.result)||"object"==typeof a&&0===Object.keys(a).length||"string"==typeof a&&0===a.trim().length||Buffer.isBuffer(a)&&0===a.length))throw new SyntaxError(`Error parsing "${e.url}" as ${t.plugin.name}. \nParsed value is empty`);return t}catch(r){throw!r&&t.continueOnError?new I(e.url):r&&r.message&&r.message.startsWith("Error parsing")?r:r&&"error"in r?r.error instanceof _?r.error:new _(r.error.message,e.url):new SyntaxError(`Unable to parse ${e.url}`,{cause:r})}var a}(l,r,t);return c.value=o.result,c.dynamicIdScope=C(c.value),q(t,c.path,c.value,c.pathType,c.dynamicIdScope),o.result}catch(e){throw k(e)&&(c.value=e),e}},ue={order:100,allowEmpty:!0,canParse:".json",allowBOM:!0,async parse(e){let t=e.data;if(Buffer.isBuffer(t)&&(t=t.toString()),"string"!=typeof t)return t;if(0!==t.trim().length)try{return JSON.parse(t)}catch(r){if(this.allowBOM)try{const e=t.indexOf("{");return t=t.slice(e),JSON.parse(t)}catch(t){throw new _(t.message,e.url)}throw new _(r.message,e.url)}}},fe=require("js-yaml"),pe={order:200,allowEmpty:!0,canParse:[".yaml",".yml",".json"],async parse(e){let t=e.data;if(Buffer.isBuffer(t)&&(t=t.toString()),"string"!=typeof t)return t;try{return fe.load(t,{schema:fe.JSON_SCHEMA})}catch{try{return fe.load(t)}catch(t){throw new _(t?.message||"Parser Error",e.url)}}}},he=/\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i,de={order:300,allowEmpty:!0,encoding:"utf8",canParse:e=>("string"==typeof e.data||Buffer.isBuffer(e.data))&&he.test(e.url),parse(e){if("string"==typeof e.data)return e.data;if(Buffer.isBuffer(e.data))return e.data.toString(this.encoding);throw new _("data is not text",e.url)}},me=/\.(jpeg|jpg|gif|png|bmp|ico)$/i,ye={order:400,allowEmpty:!0,canParse:e=>Buffer.isBuffer(e.data)&&me.test(e.url),parse:e=>Buffer.isBuffer(e.data)?e.data:Buffer.from(e.data)},$e={order:100,canRead:e=>x(e.url),async read(e){let t;const o=await Promise.resolve().then(r.t.bind(r,896,19));try{t=E(e.url)}catch(t){const r=t;throw r.message=`Malformed URI: ${e.url}: ${r.message}`,new T(r,e.url)}(t.endsWith("/")||t.endsWith("\\"))&&(t=t.slice(0,-1));try{return await o.promises.readFile(t)}catch(e){const r=e;throw r.message=`Error opening file ${t}: ${r.message}`,new T(r,t)}}},ge={order:200,headers:null,timeout:6e4,redirects:5,withCredentials:!1,safeUrlResolver:!0,canRead(e){return function(e){const t=y(e);return"http"===t||"https"===t||void 0===t&&"undefined"!=typeof window}(e.url)&&(!this.safeUrlResolver||!w(e.url))},read(e){const t=h(e.url);return"undefined"==typeof window||t.protocol||(t.protocol=h(location.href).protocol),ve(t,this)}};async function ve(e,t,r){e=h(e);const o=r||[];o.push(e.href);try{const r=await async function(e,t){let r,o;t.timeout&&"undefined"!=typeof AbortController&&(r=new AbortController,o=setTimeout(()=>r.abort(),t.timeout));const n=await fetch(e,{method:"GET",headers:t.headers||{},credentials:t.withCredentials?"include":"same-origin",signal:r?r.signal:null});return o&&clearTimeout(o),n}(e,t);if(r.status>=400){const e=new Error(`HTTP ERROR ${r.status}`);throw e.status=r.status,e}if(r.status>=300){if(!Number.isNaN(t.redirects)&&o.length>t.redirects){const e=new Error(`Error downloading ${o[0]}. \nToo many redirects: \n ${o.join(" \n ")}`);throw e.status=r.status,new T(e)}if("location"in r.headers&&r.headers.location)return ve(d(e.href,r.headers.location),t,o);{const e=new Error(`HTTP ${r.status} redirect with no location header`);throw e.status=r.status,e}}if(r.body){const e=await r.arrayBuffer();return Buffer.from(e)}return Buffer.alloc(0)}catch(t){const r=t;throw r.message=`Error downloading ${e.href}: ${r.message}`,new T(r,e.href)}}const we=()=>({parse:{json:{...ue},yaml:{...pe},text:{...de},binary:{...ye}},resolve:{file:{...$e},http:{...ge},external:!0},continueOnError:!1,bundle:{excludedPathMatcher:()=>!1},dereference:{circular:!0,excludedPathMatcher:()=>!1,referenceResolution:"relative",mergeKeys:!0},mutateInputSchema:!0}),xe=e=>{const t=we();return e&&Ee(t,e),t};function Ee(e,t){if(be(t)){const r=Object.keys(t).filter(e=>!["__proto__","constructor","prototype"].includes(e));for(let o=0;o<r.length;o++){const n=r[o],s=t[n],a=e[n];be(s)?e[n]=Ee(a||{},s):void 0!==s&&(e[n]=s)}}return e}function be(e){return e&&"object"==typeof e&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}const Re=function(e){let t,r,o,n;const s=Array.prototype.slice.call(e);"function"==typeof s[s.length-1]&&(n=s.pop()),"string"==typeof s[0]?(t=s[0],"object"==typeof s[2]?(r=s[1],o=s[2]):(r=void 0,o=s[1])):(t="",r=s[0],o=s[1]);try{o=xe(o)}catch(e){console.error(`JSON Schema Ref Parser: Error normalizing options: ${e}`)}return o.mutateInputSchema||"object"!=typeof r||(r=JSON.parse(JSON.stringify(r))),{path:t,schema:r,options:o,callback:n}};function Pe(e,t,r,o,n,s,a,i){a||=new Set;let c=[];if(e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!a.has(e)){a.add(e);const l=r;te.isExternal$Ref(e)&&c.push(async function(e,t,r,o,n,s){const a="root"===s.dereference?.externalReferenceResolution?m():o?r:t,i=d(a,e.$ref),c=v(i),l=n._get$Ref(c);if(l)return Promise.resolve(l.value);try{const t=e.$ref,r={url:i,baseUrl:a};"string"==typeof t&&(r.reference=t);const o=await le(r,n,s),l=n._get$Ref(c),u=Pe(o,c+"#",c,l?.dynamicIdScope??!1,n,s,new Set,!0);return Promise.all(u)}catch(e){if(!s?.continueOnError||!k(e))throw e;return n._$refs[c]&&(e.source=decodeURI(v(t)),e.path=b(g(t))),[]}}(e,t,l,o,n,s));const u=Object.keys(e);for(const r of u){const u=K.join(t,r),f=e[r],p=o&&f&&"object"==typeof f&&!ArrayBuffer.isView(f)?W(l,f):l;c=c.concat(Pe(f,u,p,o,n,s,a,i))}}return c}const je=function(e,t){if(!t.resolve?.external)return Promise.resolve();try{const r=e.$refs._root$Ref.dynamicIdScope?W(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,o=Pe(e.schema,e.$refs._root$Ref.path+"#",r,e.$refs._root$Ref.dynamicIdScope,e.$refs,t);return Promise.all(o)}catch(e){return Promise.reject(e)}};function Oe(e,t,r,o,n,s,a,i,c,l){const u=null===t?e:e[t],f=l.bundle||{},p=f.excludedPathMatcher||(()=>!1);if(u&&"object"==typeof u&&!ArrayBuffer.isView(u)&&!p(s)){const p=o;if(te.isAllowed$Ref(u))Se(e,t,r,p,n,s,a,i,c,l);else{const e=Object.keys(u).sort((e,t)=>"definitions"===e||"$defs"===e?-1:"definitions"===t||"$defs"===t?1:e.length-t.length);for(const t of e){const e=K.join(r,t),o=K.join(s,t),h=u[t],d=n&&h&&"object"==typeof h&&!ArrayBuffer.isView(h)?W(p,h):p;te.isAllowed$Ref(h)?Se(u,t,e,d,n,o,a,i,c,l):Oe(u,t,e,d,n,o,a,i,c,l),h&&"object"==typeof h&&!Array.isArray(h)&&"$ref"in h&&f?.onBundle?.(h.$ref,u[t],u,t)}}}}function Se(e,t,r,o,n,s,a,i,c,l){const u=null===t?e:e[t],f=d(n?o:r,u.$ref),p=c._resolve(f,s,l);if(null===p)return;const h=K.parse(s).length,m=v(p.path),y=g(p.path),$=m!==c._root$Ref.path&&!c._aliases[m],w=te.isExtended$Ref(u);a+=p.indirections;const x=function(e,t,r){for(const o of e)if(o&&o.parent===t&&o.key===r)return o}(i,e,t);if(x){if(!(h<x.depth||a<x.indirections))return;!function(e,t){const r=e.indexOf(t);e.splice(r,1)}(i,x)}i.push({$ref:u,parent:e,key:t,pathFromRoot:s,depth:h,file:m,hash:y,value:p.value,circular:p.circular,extended:w,external:$,indirections:a}),x&&!$||Oe(p.value,null,p.path,p.$ref.path,p.$ref.dynamicIdScope,s,a+1,i,c,l)}function Ae(e,t){if(!t.startsWith("#/"))return t;const r=t.slice(2).split("/");let o=e;const n=[];for(const s of r){if(null==o||"object"!=typeof o)return t;if("$ref"in o&&"string"==typeof o.$ref&&o.$ref.startsWith("#/")){const r=o.$ref.slice(2).split("/");if(n.length=0,n.push(...r),o=_e(e,o.$ref),null==o||"object"!=typeof o)return t}const r=s.replace(/~1/g,"/").replace(/~0/g,"~");o=o[Array.isArray(o)?parseInt(r):r],n.push(s)}return"#/"+n.join("/")}function _e(e,t){if(!t.startsWith("#/"))return;const r=t.slice(2).split("/");let o=e;for(const e of r){if(null==o||"object"!=typeof o)return;const t=e.replace(/~1/g,"/").replace(/~0/g,"~");o=o[Array.isArray(o)?parseInt(t):t]}return o}function Ie(e,t){for(const r of e)if("#"!==r.pathFromRoot&&"#/"!==r.pathFromRoot&&t.pathFromRoot.startsWith(r.pathFromRoot+"/")&&r.value&&"object"==typeof r.value&&"$id"in r.value)return!0;return!1}const Te=function(e,t){const r=Date.now(),o=e.$refs._root$Ref.dynamicIdScope?W(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,n=Ne(e.schema,e.$refs._root$Ref.path,o,e.$refs._root$Ref.dynamicIdScope,"#",new Set,new Set,new Map,e.$refs,t,r,0);e.$refs.circular=n.circular,e.schema=n.value};function Ne(e,t,r,o,n,s,a,i,c,l,u,f){let p;const h={value:e,circular:!1};Me(u,l);const d=l.dereference||{},m=d.maxDepth??500;if(f>m)throw new RangeError(`Maximum dereference depth (${m}) exceeded at ${n}. This likely indicates an extremely deep or recursive schema. You can increase this limit with the dereference.maxDepth option.`);const y=d.excludedPathMatcher||(()=>!1);if(("ignore"===d?.circular||!a.has(e))&&e&&"object"==typeof e&&!ArrayBuffer.isView(e)&&!y(n)){s.add(e),a.add(e);const m=r;if(te.isAllowed$Ref(e,l))p=Fe(e,t,m,o,n,s,a,i,c,l,u,f),h.circular=p.circular,h.value=p.value;else for(const r of Object.keys(e)){Me(u,l);const $=K.join(t,r),g=K.join(n,r);if(y(g))continue;const v=e[r],w=o&&v&&"object"==typeof v&&!ArrayBuffer.isView(v)?W(m,v):m;let x;if(te.isAllowed$Ref(v,l)){if(p=Fe(v,$,w,o,g,s,a,i,c,l,u,f),x=p.circular,e[r]!==p.value){const t=new Map;d?.preservedProperties&&("object"!=typeof e[r]||Array.isArray(e[r])||d?.preservedProperties.forEach(o=>{o in e[r]&&t.set(o,e[r][o])}));let o=p.value;d?.cloneReferences&&!x&&o&&"object"==typeof o&&(o=structuredClone(o)),e[r]=o,d?.preservedProperties&&t.size&&"object"==typeof e[r]&&!Array.isArray(e[r])&&t.forEach((t,o)=>{e[r][o]=t}),d?.onDereference?.(v.$ref,e[r],e,r)}}else s.has(v)?x=Be($,c,l):(p=Ne(v,$,w,o,g,s,a,i,c,l,u,f+1),x=p.circular,e[r]!==p.value&&(e[r]=p.value));h.circular=h.circular||x}s.delete(e)}return h}function Fe(e,t,r,o,n,s,a,i,c,l,u,f){const p=d(te.isExternal$Ref(e)&&"root"===l?.dereference?.externalReferenceResolution?m():o?r:t,e.$ref),h=i.get(p);if(h){if(!h.circular){const t=Object.keys(e);if(t.length>1){const r={};for(const o of t)"$ref"===o||o in h.value||(r[o]=e[o]);return{circular:h.circular,value:Object.assign({},h.value,r)}}return h}if("object"!=typeof h.value||!("$ref"in h.value)||!("$ref"in e))return Be(t,c,l),h;if(h.value.$ref===e.$ref)return Be(t,c,l),h}const y=c._resolve(p,t,l);if(null===y)return{circular:!1,value:null};const $=y.circular;let g=$||s.has(y.value);g&&Be(t,c,l);let v=te.dereference(e,y.value,l);if(!g){const e=Ne(v,y.path,y.$ref.path,y.$ref.dynamicIdScope,n,s,a,i,c,l,u,f+1);g=e.circular,v=e.value}g&&!$&&"ignore"===l.dereference?.circular&&(v=e),$&&(v.$ref=n);const w={circular:g,value:v};return 1===Object.keys(e).length&&i.set(p,w),w}function Me(e,t){if(t&&t.timeoutMs&&Date.now()-e>t.timeoutMs)throw new M(t.timeoutMs)}function Be(e,t,r){if(t.circular=!0,r?.dereference?.onCircular?.(e),!r.dereference.circular)throw new ReferenceError(`Circular $ref pointer found at ${e}`);return!0}const ke="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(e){setTimeout(e,0)};function Ue(e,t){return e?void t.then(function(t){ke(function(){e(null,t)})},function(t){ke(function(){e(t)})}):t}class We{schema=null;$refs=new re;async parse(){const e=Re(arguments);let t;if(!e.path&&!e.schema){const t=new Error(`Expected a file path, URL, or object. Got ${e.path||e.schema}`);return Ue(e.callback,Promise.reject(t))}this.schema=null,this.$refs=new re;let r="http";if(x(e.path))e.path=function(e){if(s()){const n=m(),s=e.toUpperCase(),a=o(n).toUpperCase(),i=s.includes(a),c=s.includes(a),l=u.test(e)||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("file://");i||c||l||n.startsWith("http")||(r=e,e=(t=n).endsWith("/")||t.endsWith("\\")?t+r:t+"/"+r),e=o(e)}var t,r;e=encodeURI(e);for(const t of f)e=e.replace(t[0],t[1]);return e}(e.path),r="file";else if(!e.path&&e.schema&&"$id"in e.schema&&e.schema.$id){const t=h(e.schema.$id),r=t.port??("https:"===t.protocol?443:80);e.path=`${t.protocol}//${t.hostname}:${r}`}if(e.path=d(m(),e.path),e.schema&&"object"==typeof e.schema){const o=this.$refs._add(e.path);o.value=e.schema,o.pathType=r,o.dynamicIdScope=C(o.value),q(this.$refs,o.path,o.value,o.pathType,o.dynamicIdScope),t=Promise.resolve(e.schema)}else t=le(e.path,this.$refs,e.options);try{const r=await t;if(null===r||"object"!=typeof r||Buffer.isBuffer(r)){if(e.options.continueOnError)return this.schema=null,Ue(e.callback,Promise.resolve(this.schema));throw new SyntaxError(`"${this.$refs._root$Ref.path||r}" is not a valid JSON Schema`)}return this.schema=r,Ue(e.callback,Promise.resolve(this.schema))}catch(t){return e.options.continueOnError&&k(t)?(this.$refs._$refs[v(e.path)]&&this.$refs._$refs[v(e.path)].addError(t),Ue(e.callback,Promise.resolve(null))):Ue(e.callback,Promise.reject(t))}}static parse(){const e=new We;return e.parse.apply(e,arguments)}async resolve(){const e=Re(arguments);try{return await this.parse(e.path,e.schema,e.options),await je(this,e.options),qe(this),Ue(e.callback,Promise.resolve(this.$refs))}catch(t){return Ue(e.callback,Promise.reject(t))}}static resolve(){const e=new We;return e.resolve.apply(e,arguments)}static bundle(){const e=new We;return e.bundle.apply(e,arguments)}async bundle(){const e=Re(arguments);try{return await this.resolve(e.path,e.schema,e.options),function(e,t){const r=e.$refs._root$Ref.dynamicIdScope?W(e.$refs._root$Ref.path,e.schema):e.$refs._root$Ref.path,o=[];Oe(e,"schema",e.$refs._root$Ref.path+"#",r,e.$refs._root$Ref.dynamicIdScope,"#",0,o,e.$refs,t),function(e,t,r){let o,n,s;e.sort((e,t)=>{if(e.file!==t.file)return e.file<t.file?-1:1;if(e.hash!==t.hash)return e.hash<t.hash?-1:1;if(e.circular!==t.circular)return e.circular?-1:1;if(e.extended!==t.extended)return e.extended?1:-1;if(e.indirections!==t.indirections)return e.indirections-t.indirections;if(e.depth!==t.depth)return e.depth-t.depth;{const r=Math.max(e.pathFromRoot.lastIndexOf("/definitions"),e.pathFromRoot.lastIndexOf("/$defs")),o=Math.max(t.pathFromRoot.lastIndexOf("/definitions"),t.pathFromRoot.lastIndexOf("/$defs"));return r!==o?o-r:e.pathFromRoot.length-t.pathFromRoot.length}});for(const a of e){const i=t.bundle||{};if(a.external)if(a.file===o&&a.hash===n)r&&Ie(e,a)?a.$ref.$ref=r+s:a.$ref.$ref=s;else if(a.file===o&&0===a.hash.indexOf(n+"/")){const t=K.join(s,K.parse(a.hash.replace(n,"#")));r&&Ie(e,a)?a.$ref.$ref=r+t:a.$ref.$ref=t}else o=a.file,n=a.hash,s=a.pathFromRoot,a.$ref=a.parent[a.key]=te.dereference(a.$ref,a.value,t),a.circular&&(a.$ref.$ref=a.pathFromRoot);else!1!==i.optimizeInternalRefs&&(a.$ref.$ref=a.hash)}}(o,t,e.schema&&"object"==typeof e.schema&&"$id"in e.schema?e.schema.$id:void 0),!1!==(t.bundle||{}).optimizeInternalRefs&&function(e,t){for(const r of e){if(!r.$ref||"object"!=typeof r.$ref||!("$ref"in r.$ref))continue;const e=r.$ref.$ref;if("string"!=typeof e||!e.startsWith("#/"))continue;const o=Ae(t,e);o!==e&&(r.$ref.$ref=o)}}(o,e.schema)}(this,e.options),qe(this),Ue(e.callback,Promise.resolve(this.schema))}catch(t){return Ue(e.callback,Promise.reject(t))}}static dereference(){const e=new We;return e.dereference.apply(e,arguments)}async dereference(){const e=Re(arguments);try{return await this.resolve(e.path,e.schema,e.options),Te(this,e.options),qe(this),Ue(e.callback,Promise.resolve(this.schema))}catch(t){return Ue(e.callback,Promise.reject(t))}}}const Ce=We;function qe(e){if(A.getParserErrors(e).length>0)throw new A(e)}const Je=We.parse,Ve=We.resolve,Le=We.bundle,De=We.dereference}},o={};function n(e){var t=o[e];if(void 0!==t)return t.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,n),s.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(r,o){if(1&o&&(r=this(r)),8&o)return r;if("object"==typeof r&&r){if(4&o&&r.__esModule)return r;if(16&o&&"function"==typeof r.then)return r}var s=Object.create(null);n.r(s);var a={};e=e||[null,t({}),t([]),t(t)];for(var i=2&o&&r;("object"==typeof i||"function"==typeof i)&&!~e.indexOf(i);i=t(i))Object.getOwnPropertyNames(i).forEach(e=>a[e]=()=>r[e]);return a.default=()=>r,n.d(s,a),s},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};for(var a in(()=>{var e=s;const t=n(711),r=n(149),o=n(668),a=n(258),i=n(896),c=n(928),l=n(410),u=n(115),{JSONPath:f}=n(940),p=n(231),{createError:h}=n(184).custom,d=n(285),{getValidatorFactory:m,compileValidate:y}=n(631),$=n(600),{ApplicationError:g,ErrorType:v}=n(476),{createValidationResponse:w,dereferenceJsonSchema:x}=n(427),E=Symbol("internal"),b="schemasWithExamples",R=["yaml","yml"],P=h(v.jsonPathNotFound);async function j(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o}={}){const n=$.getImplementation(e);e=await p.dereference(e),e=n.prepare(e,{noAdditionalProperties:t,allPropertiesRequired:o});let s=n.getJsonPathsToExamples().reduce((t,r)=>t.concat(_(r,e)),[]);return function({impl:e},t,r,{ignoreFormats:o}){const n=T(),s={valid:!0,statistics:n,errors:[]},a=M(r,{ignoreFormats:o});let i;try{i=e.buildValidationMap(t)}catch(e){if(!(e instanceof g))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:o,statistics:n,validationResult:s}){const a=s.errors;o[r].forEach(o=>{const i=N(o,e),c=B(r,e,!0),l=F({createValidator:t,schema:c,example:i,statistics:n}).map(e=>(e.examplePath=o,e));l.length&&(s.valid=!1,a.splice(a.length-1,0,...l))})}({openapiSpec:r,createValidator:a,schemaPointer:e,validationMap:i,statistics:n,validationResult:s})}),s}({impl:n},s,e,{ignoreFormats:r})}async function O(e){const t=function(e){const t=e.split(".").pop();return R.includes(t)}(e);let r;if(t)try{r=u.parse(i.readFileSync(e,"utf-8"))}catch(e){const{name:t,message:r}=e;throw new g(v.parseError,{message:`${t}: ${r}`})}else r=JSON.parse(i.readFileSync(e,"utf-8"));return await x(e,r)}function S(e){const t=T(),r=e(t);return w({errors:r,statistics:t})}function A(e,t,n,{cwdToMappingFile:s=!1,dirPathMapExternalExamples:a,ignoreFormats:u}){return o(Object.entries(t),([t,f])=>{let p=null;try{p=B(I(t,e),e)}catch(e){return g.create(e)}return o(r([f]),t=>{let r=[];try{const e=s?c.join(a,t):t,o=l.sync(e);if(0===o.length)return[g.create({type:v.jsENOENT,message:`No such file or directory: '${e}'`,path:e})];for(const e of o)r.push({path:c.normalize(e),content:JSON.parse(i.readFileSync(e,"utf-8"))})}catch(e){return[g.create(e)]}return o(r,t=>F({createValidator:M(e,{ignoreFormats:u}),schema:p,example:t.content,statistics:n,filePathExample:t.path}))})})}function _(e,t){return f({json:t,path:e,resultType:d.pointer})}function I(e,t){const r=_(e,t);return 0===r.length&&k(e),r.length>1?[g.create({type:v.jsonPathNotFound,message:`Path to schema cannot identify unique schema: '${e}'`,path:e})]:r[0]}function T(){const e={[E]:{[b]:new Set},examplesTotal:0,examplesWithoutSchema:0,get[b](){return e[E][b].size}};return e}function N(e,t){try{return a.get(t,e)}catch(e){return}}function F({createValidator:e,schema:t,example:r,statistics:o,filePathExample:n}){const s=[];if(o.examplesTotal++,!t)return o.examplesWithoutSchema++,s;o[E][b].add(t);const a=y(e(),t);return a(r)?s:s.concat(...a.errors.map(g.create)).map(e=>n?(e.exampleFilePath=n,e):e)}function M(e,{ignoreFormats:t}){return m(e,{schemaId:"auto",discriminator:!0,strict:!1,allErrors:!0,formats:t&&t.reduce((e,t)=>(e[t]=()=>!0,e),{})})}function B(e,t,r=!1){const o=N(e,t);return r||o||k(e),o}function k(e){throw new P(`Path to schema can't be found: '${e}'`,{params:{path:e}})}e.default=j,e.validateExamples=j,e.validateFile=async function(e,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o}={}){let n=null;try{n=await O(e)}catch(e){return w({errors:[g.create(e)]})}return j(n,{noAdditionalProperties:t,ignoreFormats:r,allPropertiesRequired:o})},e.validateExample=async function(e,t,r,{noAdditionalProperties:o,ignoreFormats:n,allPropertiesRequired:s}={}){let a=null,c=null,l=null;try{a=JSON.parse(i.readFileSync(r,"utf-8")),l=await O(e),l=$.getImplementation(l).prepare(l,{noAdditionalProperties:o,allPropertiesRequired:s}),c=B(I(t,l),l)}catch(e){return w({errors:[g.create(e)]})}return S(e=>F({createValidator:M(l,{ignoreFormats:n}),schema:c,example:a,statistics:e,filePathExample:r}))},e.validateExamplesByMap=async function(e,r,{cwdToMappingFile:o,noAdditionalProperties:n,ignoreFormats:s,allPropertiesRequired:a}={}){let u=0;const f=l.sync(r,{nonull:!0});let p=[];for(const t of f){let r=null,l=null;try{r=JSON.parse(i.readFileSync(t,"utf-8")),l=await O(e),l=$.getImplementation(l).prepare(l,{noAdditionalProperties:n,allPropertiesRequired:a})}catch(e){p.push(w({errors:[g.create(e)]}));continue}u++,p.push(S(e=>A(l,r,e,{cwdToMappingFile:o,dirPathMapExternalExamples:c.dirname(t),ignoreFormats:s}).map(e=>Object.assign(e,{mapFilePath:c.normalize(t)}))))}return t(p.reduce((e,t)=>{return e?(o=t,w({errors:(r=e).errors.concat(o.errors),statistics:Object.entries(r.statistics).reduce((e,[t,n])=>b===t?([r,o].forEach(t=>{const r=t.statistics[E][b].values();for(let t of r)e[E][b].add(t)}),e):(e[t]=n+o.statistics[t],e),T())})):t;var r,o},null),{statistics:{matchingFilePathsMapping:u}})}})(),exports.default=s.default,exports.validateExample=s.validateExample,exports.validateExamples=s.validateExamples,exports.validateExamplesByMap=s.validateExamplesByMap,exports.validateFile=s.validateFile,s)-1===["default","validateExample","validateExamples","validateExamplesByMap","validateFile"].indexOf(a)&&(exports[a]=s[a]);Object.defineProperty(exports,"__esModule",{value:!0})})();
//# sourceMappingURL=index.js.map