@redocly/mock-server 0.3.10 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.js +1 -1
  2. package/package.json +2 -2
package/dist/bin.js CHANGED
@@ -245,7 +245,7 @@ ${JSON.stringify(r,null,2)}`);Ae(t.rules,r.rules),Ae(t.oas2Rules,r.oas2Rules),qe
245
245
  `).map(i=>n.repeat(r)+i).join(`
246
246
  `)}},Zs=new gb;var aC={problems:"{{problems}}"};function cC(e){let{filterInParentKeys:t,filterOutParentKeys:r,matchParentKeys:n}=e,i=n&&el(n),o=i&&(c=>i.test(c.toString())),s=Array.isArray(t)&&(c=>t.includes(c.toString())),a=Array.isArray(r)&&(c=>!r.includes(c.toString()));return[o,s,a].filter(ft)}function uC(e){let t=Ba(Qs).filter(i=>e.assertions[i]!==void 0).map(i=>({name:i,conditions:e.assertions[i],runsOnKeys:rC.has(i),runsOnValues:nC.has(i)})),r=t.find(i=>i.runsOnKeys&&!i.runsOnValues),n=t.find(i=>i.runsOnValues&&!i.runsOnKeys);if(n&&!e.subject.property)throw new Error(`The '${n.name}' assertion can't be used on all keys. Please provide a single property.`);if(r&&e.subject.property)throw new Error(`The '${r.name}' assertion can't be used on properties. Please remove the 'property' key.`);return t}function pC({subject:e}){return(Array.isArray(e.property)?e.property:[e==null?void 0:e.property]).filter(Boolean)}function fC(e,t,r){let n=pC(e),i=[];for(let o of t)if(n.length)for(let s of n)i.push(lC({assert:o,ctx:r,assertionProperty:s}));else i.push(lC({assert:o,ctx:r}));return i.flat()}function dC(e,t){var c,l;let r=cC(e.subject),n=r.length?(u,p)=>!r.every(m=>m(p)):void 0,i={[e.subject.type]:{enter:t,...n&&{skip:n}}};if(!Array.isArray(e.where))return i;let o={},s=o,a=e.where;for(let u=0;u<a.length;u++){let p=a[u];if(!dt((c=p.subject)==null?void 0:c.type))throw new Error(`${e.assertionId} -> where -> [${u}]: 'type' (String) is required`);let m=cC(p.subject),d=uC(p),f=(y,g,b)=>!m.every(v=>v(g))||!!fC(p,d,{...b,node:y}).length,h={...(m.length||d.length)&&{skip:f}};p.subject.type===e.subject.type&&u===a.length-1?i[e.subject.type]={enter:t,...h.skip&&{skip:h.skip}||n&&{skip:(y,g,b)=>{var v;return!!((v=h.skip)!=null&&v.call(h,y,g,b)||n!=null&&n(y,g))}}}:o=o[(l=p.subject)==null?void 0:l.type]=h}return o[e.subject.type]=i[e.subject.type],s}function mC(e,t){return(r,n)=>{let i=pC(t),o=`${Oe.blue(e)} failed because the ${Oe.blue(t.subject.type)} ${Oe.blue(i.join(", "))} didn't meet the assertions: ${aC.problems}`.replace(/ +/g," "),s=fC(t,uC(t),{...n,node:r});if(s.length)for(let a of qG(s)){let c=t.message||o,l=MG(a);n.report({message:c.replace(aC.problems,l),location:jG(a)||n.location,forceSeverity:t.severity||"error",suggest:t.suggest||[],ruleId:e})}}}function qG(e){let t={};for(let r of e){if(!r.location)continue;let n=r.location.pointer;t[n]=t[n]||[],t[n].push(r)}return Object.values(t)}function jG(e){return e.length?e[0].location:void 0}function MG(e){var t;return e.length===1?(t=e[0].message)!=null?t:"":e.map(r=>{var n;return`
247
247
  - ${(n=r.message)!=null?n:""}`}).join("")}function Zc(e,t){let r=new Set(t),n=0;for(let i of e)r.has(i)&&n++;return n}function oC(e,t){let r=t.direction||t,n=t.property;for(let i=1;i<e.length;i++){let o=e[i],s=e[i-1];if(n){let c=e[i][n],l=e[i-1][n];if(!c||!l)return!1;o=c,s=l}if(typeof o=="string"&&typeof s=="string"&&(o=o.toLowerCase(),s=s.toLowerCase()),!(r==="asc"?o>=s:o<=s))return!1}return!0}function lC({assert:e,ctx:t,assertionProperty:r}){var i;let n=e.name==="ref"?t.rawLocation:t.location;if(r){let o=we(t.node[r])?(i=t.resolve(t.node[r]))==null?void 0:i.node:t.node[r],s=t.rawNode[r],a=n.child(r);return Qs[e.name](o,e.conditions,{...t,baseLocation:a,rawValue:s})}else{let o=Array.isArray(t.node)?t.node:Object.keys(t.node);return Qs[e.name](o,e.conditions,{...t,rawValue:t.rawNode,baseLocation:n})}}function el(e){let t=e.match(/^\/(.*)\/(.*)|(.*)/);return t&&new RegExp(t[1]||t[3],t[2])}var Nr=e=>{let t=[],r=Object.values(e).filter(n=>typeof n=="object"&&n!==null);for(let[n,i]of r.entries()){if(!dt(i.subject.type))throw new Error(`${i.assertionId}: 'type' (String) is required`);let o=mC(i.assertionId,i),s=dC(i,o);t.push(s)}return t};var Hp=()=>{let e=new Set;return{Operation(t,{report:r,location:n}){t.operationId&&(e.has(t.operationId)&&r({message:"Every operation must have a unique `operationId`.",location:n.child([t.operationId])}),e.add(t.operationId))}}};var Kp=()=>{let e,t;return{PathItem:{enter(){e=new Set},Parameter(r,{report:n,key:i,parentLocations:o}){let s=`${r.in}___${r.name}`;e.has(s)&&n({message:`Paths must have unique \`name\` + \`in\` parameters.
248
- Repeats of \`in:${r.in}\` + \`name:${r.name}\`.`,location:o.PathItem.child(["parameters",i])}),e.add(`${r.in}___${r.name}`)},Operation:{enter(){t=new Set},Parameter(r,{report:n,key:i,parentLocations:o}){let s=`${r.in}___${r.name}`;t.has(s)&&n({message:`Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:${r.in}\` + \`name:${r.name}\`.`,location:o.Operation.child(["parameters",i])}),t.add(s)}}}}};var LG=/\{([a-zA-Z0-9_.-]+)\}+/g,ea=()=>{let e,t,r,n;return{PathItem:{enter(i,{key:o}){t=new Set,r=o,e=new Set(Array.from(o.toString().matchAll(LG)).map(s=>s[1]))},Parameter(i,{report:o,location:s}){i.in==="path"&&i.name&&(t.add(i.name),e.has(i.name)||o({message:`Path parameter \`${i.name}\` is not used in the path \`${r}\`.`,location:s.child(["name"])}))},Operation:{enter(){n=new Set},leave(i,{report:o,location:s}){for(let a of Array.from(e.keys()))!n.has(a)&&!t.has(a)&&o({message:`The operation does not define the path parameter \`{${a}}\` expected by path \`${r}\`.`,location:s.child(["parameters"]).key()})},Parameter(i,{report:o,location:s}){i.in==="path"&&i.name&&(n.add(i.name),e.has(i.name)||o({message:`Path parameter \`${i.name}\` is not used in the path \`${r}\`.`,location:s.child(["name"])}))}}}}};var Wp=()=>{let e;return{Root(t){var r;e=new Set(((r=t.tags)!=null?r:[]).map(n=>n.name))},Operation(t,{report:r,location:n}){if(t!=null&&t.tags)for(let i=0;i<t.tags.length;i++)e.has(t.tags[i])||r({message:"Operation tags should be defined in global tags.",location:n.child(["tags",i])});else r({message:"Operation tags should be defined",location:n.key()})}}};var hC=()=>({Example(e,{report:t,location:r}){e.value&&e.externalValue&&t({message:"Example object can have either `value` or `externalValue` fields.",location:r.child(["value"]).key()})}});var fn=()=>({Schema(e,{report:t,location:r}){if(!(e.enum&&!Array.isArray(e.enum))){if(e.enum&&e.type&&!Array.isArray(e.type)){let n=e.enum.filter(i=>!Js(i,e.type,e.nullable));for(let i of n)t({message:`All values of \`enum\` field must be of the same type as the \`type\` field: expected "${e.type}" but received "${Gs(i)}".`,location:r.child(["enum",e.enum.indexOf(i)])})}if(e.enum&&e.type&&Array.isArray(e.type)){let n={};for(let i of e.enum){n[i]=[];for(let o of e.type)Js(i,o,e.nullable)||n[i].push(o);n[i].length!==e.type.length&&delete n[i]}for(let i of Object.keys(n))t({message:`Enum value \`${i}\` must be of allowed types: \`${e.type}\`.`,location:r.child(["enum",e.enum.indexOf(i)])})}}}});var Yp=()=>({PathItem(e,{report:t,key:r,rawLocation:n}){r.endsWith("/")&&r!=="/"&&t({message:`\`${r}\` should not have a trailing slash.`,location:n.key()})}});var Gp=()=>({PathItem(e,{report:t,key:r}){r.indexOf("{}")!==-1&&t({message:"Path parameter declarations must be non-empty. `{}` is invalid.",location:{reportOnKey:!0}})}});var DG=/^[A-Za-z0-9-._~:/?#\[\]@!\$&'()*+,;=]*$/,Jp=()=>({Operation(e,{report:t,location:r}){e.operationId&&!DG.test(e.operationId)&&t({message:"Operation `operationId` should not have URL invalid characters.",location:r.child(["operationId"])})}});var $i=({ignoreCase:e=!1})=>({Root(t,{report:r,location:n}){if(t.tags)for(let i=0;i<t.tags.length-1;i++)Qc(t.tags[i],e)>Qc(t.tags[i+1],e)&&r({message:"The `tags` array should be in alphabetical order.",location:n.child(["tags",i])})}});var yC=()=>({Server(e,{report:t,location:r}){let n=/^(.*[\/.])?(example\.com|localhost)([\/:?].*|$)/;e.url&&n.test(e.url)&&t({message:"Server `url` should not point to example.com or localhost.",location:r.child(["url"])})}});var gC=()=>({Server(e,{report:t,location:r}){e.url&&e.url.endsWith("/")&&e.url!=="/"&&t({message:"Server `url` should not have a trailing slash.",location:r.child(["url"])})}});var Ei=()=>({Tag(e,t){cr("description",e,t)}});var dn=()=>({Info(e,{report:t,location:r}){e.contact||t({message:Xc("Info","contact"),location:r.child("contact").key()})}});var Xp=()=>({Info(e,{report:t}){e.license||t({message:Xc("Info","license"),location:{reportOnKey:!0}})}});var Ai=()=>{let e;return{Root:{enter(t){e=ms(t)},License:{leave(t,r){e==="oas3_1"||e==="oas3_2"?tC(["url","identifier"],t,r):cr("url",t,r)}}}}};var Qp=()=>({Operation(e,t){cr("description",e,t)}});var bC=()=>{let e=new Map;function t(r,n){var i;e.set(r.absolutePointer,{used:((i=e.get(r.absolutePointer))==null?void 0:i.used)||!1,location:r,name:n})}return{ref(r,{type:n,resolve:i,key:o,location:s}){if(["Schema","Header","Parameter","Response","Example","RequestBody"].includes(n.name)){let a=i(r);if(!a.location)return;e.set(a.location.absolutePointer,{used:!0,name:o.toString(),location:s})}},Root:{leave(r,{report:n}){e.forEach(i=>{i.used||n({message:`Component: "${i.name}" is never used.`,location:i.location.key()})})}},NamedSchemas:{Schema(r,{location:n,key:i}){r.allOf||t(n,i.toString())}},NamedParameters:{Parameter(r,{location:n,key:i}){t(n,i.toString())}},NamedResponses:{Response(r,{location:n,key:i}){t(n,i.toString())}},NamedExamples:{Example(r,{location:n,key:i}){t(n,i.toString())}},NamedRequestBodies:{RequestBody(r,{location:n,key:i}){t(n,i.toString())}},NamedHeaders:{Header(r,{location:n,key:i}){t(n,i.toString())}}}};var Zp=()=>({Paths:{PathItem(e,{report:t,key:r}){r.toString().includes("?")&&t({message:"Don't put query string items in the path, they belong in parameters with `in: query`.",location:{reportOnKey:!0}})}}});var ef=()=>({Parameter(e,{report:t,location:r}){e.description===void 0?t({message:"Parameter object description must be present.",location:{reportOnKey:!0}}):e.description||t({message:"Parameter object description must be non-empty string.",location:r.child(["description"])})}});var tf=()=>({Operation(e,{report:t,location:r}){e.tags&&e.tags.length>1&&t({message:"Operation `tags` object should have only one tag.",location:r.child(["tags"]).key()})}});var rf=e=>{let t=new Map,r=[],n=!0,i;return{Root:{leave(o,{report:s}){for(let[a,c]of t.entries())if(!c.defined)for(let l of c.from)s({message:`There is no \`${a}\` security scheme defined.`,location:l.key()});if(!(o.security||n))for(let a of r)s({message:"Every operation should have security defined on it or on the root level.",location:a.key()})}},SecurityScheme(o,{key:s}){t.set(s.toString(),{defined:!0,from:[]})},SecurityRequirement(o,{location:s}){for(let a of Object.keys(o)){let c=t.get(a),l=s.child([a]);c?c.from.push(l):t.set(a,{from:[l]})}},PathItem:{enter(o,{key:s}){i=s},Operation(o,{location:s,key:a}){var l;let c=(l=e.exceptions)==null?void 0:l.some(u=>{var p;return u.path===i&&(!u.methods||((p=u.methods)==null?void 0:p.some(m=>m.toLowerCase()===a)))});!(o!=null&&o.security)&&!c&&(n=!1,r.push(s))}}}};var dr=()=>({ref:{leave(e,{report:t,location:r},n){n.node===void 0&&ta(n,t,r)}},DiscriminatorMapping(e,{report:t,resolve:r,location:n}){for(let i of Object.keys(e)){let o=r({$ref:e[i]});if(o.node!==void 0)return;ta(o,t,n.child(i))}}});function ta(e,t,r){var o;let n=e.error;n instanceof qn&&t({message:"Failed to parse: "+n.message,location:{source:n.source,pointer:void 0,start:{col:n.col,line:n.line}}});let i=(o=e.error)==null?void 0:o.message;t({location:r,message:`Can't resolve $ref${i?": "+i:""}`})}var vC=e=>{let t=e.prefixes||["is","has"],r=new RegExp(`^(${t.join("|")})[A-Z-_]`),n=t.map(o=>`\`${o}\``),i=n.length===1?n[0]:n.slice(0,-1).join(", ")+" or "+n[t.length-1];return{Parameter:{Schema(o,{report:s,parentLocations:a},c){o.type==="boolean"&&!r.test(c.Parameter.name)&&s({message:`Boolean parameter \`${c.Parameter.name}\` should have ${i} prefix.`,location:a.Parameter.child(["name"])})}}}};var nf=()=>({PathItem(e,{report:t,key:r}){r.substr(1).split("/").filter(i=>i!=="").every(i=>/^{.+}$/.test(i)||/^[a-z0-9-.]+$/.test(i))||t({message:`\`${r}\` does not use kebab-case.`,location:{reportOnKey:!0}})}});var FG=["get","head","post","put","patch","delete","options","query","trace"],of=e=>{let t=e&&e.order||FG;if(!Array.isArray(t))throw new Error("path-http-verbs-order `order` option must be an array");return{PathItem(r,{report:n,location:i}){let o=Object.keys(r).filter(s=>t.includes(s));for(let s=0;s<o.length-1;s++){let a=t.indexOf(o[s]);t.indexOf(o[s+1])<a&&n({message:"Operation http verbs must be ordered.",location:{reportOnKey:!0,...i.child(o[s+1])}})}}}};var wC=()=>({Root(e,{report:t,location:r}){if(!e.hasOwnProperty("servers")){t({message:"Servers must be present.",location:r.child(["openapi"]).key()});return}(!Array.isArray(e.servers)||e.servers.length===0)&&t({message:"Servers must be a non-empty array.",location:r.child(["servers"]).key()})}});var xC=e=>({MediaType:{leave(t,r){let{location:n,resolve:i}=r;if(!t.schema)return;if(t.example!==void 0)o(t.example,n.child("example"));else if(t.examples)for(let s of Object.keys(t.examples))o(t.examples[s],n.child(["examples",s,"value"]),!0);function o(s,a,c){if(we(s)){let l=i(s);if(!l.location)return;a=c?l.location.child("value"):l.location,s=l.node}c&&typeof(s==null?void 0:s.value)>"u"||Oi(c?s.value:s,t.schema,a,r,!!e.allowAdditionalProperties)}}}});var sf=()=>({Paths(e,{report:t,location:r}){let n=new Map;for(let i of Object.keys(e)){let o=i.replace(/{.+?}/g,"{VARIABLE}"),s=n.get(o);s?t({message:`The path already exists which differs only by path parameter name(s): \`${s}\` and \`${i}\`.`,location:r.child([i]).key()}):n.set(o,i)}}});var SC=()=>({Server(e,{report:t,location:r}){var o;if(!(e!=null&&e.url))return;let n=((o=e.url.match(/{[^}]+}/g))==null?void 0:o.map(s=>s.slice(1,s.length-1)))||[],i=(e==null?void 0:e.variables)&&Object.keys(e.variables)||[];for(let s of n)i.includes(s)||t({message:`The \`${s}\` variable is not defined in the \`variables\` objects.`,location:r.child(["url"])});for(let s of i)n.includes(s)||t({message:`The \`${s}\` variable is not used in the server's \`url\` field.`,location:r.child(["variables",s]).key(),from:r.child("url")})}});var Ci=()=>({Root:{PathItem:{Operation(e,t){cr("operationId",e,t)}}}});var af=()=>({Operation(e,t){cr("summary",e,t)}});var cf=()=>({Paths(e,{report:t,location:r}){let n=[];for(let i of Object.keys(e)){let o=n.find(s=>BG(s,i));o&&t({message:`Paths should resolve unambiguously. Found two ambiguous paths: \`${o}\` and \`${i}\`.`,location:r.child([i]).key()}),n.push(i)}}});function BG(e,t){let r=e.split("/"),n=t.split("/");if(r.length!==n.length)return!1;let i=0,o=0,s=!0;for(let a=0;a<r.length;a++){let c=r[a].match(/^{.+?}$/),l=n[a].match(/^{.+?}$/);if(c||l){c&&i++,l&&o++;continue}else r[a]!==n[a]&&(s=!1)}return s&&i===o}var OC=()=>({Root(e,{report:t,location:r}){if(!e.servers||e.servers.length===0)return;let n=[];if(Array.isArray(e.servers))for(let i of e.servers){let o=_C(i);o&&n.push(...o)}else{let i=_C(e.servers);if(!i)return;n.push(...i)}for(let i of n)i==="empty"&&t({message:"Server variable with `enum` must be a non-empty array.",location:r.child(["servers"]).key()}),i==="invalidDefaultValue"&&t({message:"Server variable define `enum` and `default`. `enum` must include default value",location:r.child(["servers"]).key()})}});function _C(e){var r;if(e.variables&&Object.keys(e.variables).length===0)return;let t=[];for(let n in e.variables){let i=e.variables[n];if(!i.enum||(Array.isArray(i.enum)&&((r=i.enum)==null?void 0:r.length)===0&&t.push("empty"),!i.default))continue;let o=e.variables[n].default;i.enum&&!i.enum.includes(o)&&t.push("invalidDefaultValue")}if(t.length)return t}var UG=["get","head","post","put","patch","delete","options","trace","query"],lf=({splitIntoWords:e})=>({PathItem(t,{key:r,report:n,location:i}){let o=r.toString();if(!o.startsWith("/"))return;let s=o.split("/");for(let a of s){if(!a||Xl(a))continue;let c=l=>e?Rx(a).has(l):a.toLocaleLowerCase().includes(l);for(let l of UG)c(l)&&n({message:`path \`${o}\` should not contain http verb ${l}`,location:i.key()})}}});var PC=({allowedValues:e})=>({Paths:{RequestBody:{leave(t,r){si({type:"consumes",value:t},r,e)}},Callback:{RequestBody(){},Response:{leave(t,r){si({type:"consumes",value:t},r,e)}}}},WebhooksMap:{Response:{leave(t,r){si({type:"consumes",value:t},r,e)}}}});var $C=({allowedValues:e})=>({Paths:{Response:{leave(t,r){si({type:"produces",value:t},r,e)}},Callback:{Response(){},RequestBody:{leave(t,r){si({type:"produces",value:t},r,e)}}}},WebhooksMap:{RequestBody:{leave(t,r){si({type:"produces",value:t},r,e)}}}});var EC=Ee(am(),1);var uf=e=>{let{ignoreLastPathSegment:t,exceptions:r}=e;return{PathItem:{leave(n,{report:i,key:o,location:s}){let a=o.toString();if(a.startsWith("/")){let c=a.split("/");c.shift(),t&&c.length>0&&c.pop();for(let l of c)r&&r.includes(l)||!Xl(l)&&EC.default.isSingular(l)&&i({message:`path segment \`${l}\` should be plural.`,location:s.key()})}}}}};var pf=e=>({Schema:{leave(t,r){let n=t.examples;if(n)for(let i of n)Oi(i,t,r.location.child(["examples",n.indexOf(i)]),r,!!e.allowAdditionalProperties);if(t.example!==void 0){if(t.nullable===!0&&t.example===null&&t.type!==void 0)return;Oi(t.example,t,r.location.child("example"),r,!0)}}}});var ff=e=>({Parameter:{leave(t,r){if(t.example!==void 0&&Oi(t.example,t.schema,r.location.child("example"),r,!!e.allowAdditionalProperties),t.examples)for(let[n,i]of Object.entries(t.examples))"value"in i&&Oi(i.value,t.schema,r.location.child(["examples",n]),r,!0)}}});var df=e=>{let t=e.names||{};return{Operation:{Response:{enter:(r,{report:n,location:i,key:o})=>{let s=t[o]||t[En(o)]||t[En(o).toLowerCase()]||[];for(let a of s)(!(r!=null&&r.headers)||!Object.keys(r==null?void 0:r.headers).some(c=>c.toLowerCase()===a.toLowerCase()))&&n({message:`Response object must contain a "${a}" header.`,location:i.child("headers").key()})}}}}};var AC=e=>{let t=e.names||{},r;return{Operation:{Response:{skip:(n,i)=>`${i}`=="204",enter:(n,i)=>{r=i.key},MediaType:{Schema(n,{report:i,location:o}){var a;if(n.type!=="object")return;let s=t[r]||t[En(r)]||t[En(r).toLowerCase()]||[];for(let c of s)(a=n.properties)!=null&&a[c]||i({message:`Response object must contain a top-level "${c}" property.`,location:o.child("properties").key()})}}}}}};var CC=["string","integer","number","boolean","null"],mf=()=>({SchemaProperties(e,{report:t,location:r,specVersion:n,resolve:i}){for(let o of Object.keys(e)){let s=i(en(e,o)).node;!s||!VG(s)||s.example===void 0&&s.examples===void 0&&t({message:`Scalar property should have "example"${n==="oas3_1"||n==="oas3_2"?' or "examples"':""} defined.`,location:r.child(o).key()})}}});function VG(e){return!e.type||e.allOf||e.anyOf||e.oneOf||e.format==="binary"?!1:Array.isArray(e.type)?e.type.every(t=>CC.includes(t)):CC.includes(e.type)}var RC=()=>{let e="^[a-zA-Z0-9\\.\\-_]+$";function t(r,n,i,o){new RegExp(e).test(r)||n({message:`The map key in ${o} "${r}" does not match the regular expression "${e}"`,location:i.key()})}return{NamedSchemas:{Schema(r,{key:n,report:i,location:o}){t(n,i,o,"schemas")}},NamedParameters:{Parameter(r,{key:n,report:i,location:o}){t(n,i,o,"parameters")}},NamedResponses:{Response(r,{key:n,report:i,location:o}){t(n,i,o,"responses")}},NamedExamples:{Example(r,{key:n,report:i,location:o}){t(n,i,o,"examples")}},NamedRequestBodies:{RequestBody(r,{key:n,report:i,location:o}){t(n,i,o,"requestBodies")}},NamedHeaders:{Header(r,{key:n,report:i,location:o}){t(n,i,o,"headers")}},NamedSecuritySchemes:{SecurityScheme(r,{key:n,report:i,location:o}){t(n,i,o,"securitySchemes")}},NamedLinks:{Link(r,{key:n,report:i,location:o}){t(n,i,o,"links")}},NamedCallbacks:{Callback(r,{key:n,report:i,location:o}){t(n,i,o,"callbacks")}}}};var TC=()=>({Response:{skip(e,t){return!/4[Xx0-9]{2}/.test(`${t}`)},enter(e,{report:t,location:r}){(!e.content||!e.content["application/problem+json"])&&t({message:"Response `4xx` must have content-type `application/problem+json`.",location:r.key()})},MediaType:{skip(e,t){return t!=="application/problem+json"},enter(e,t){cr("schema",e,t)},SchemaProperties(e,t){cr("type",e,t),cr("title",e,t)}}}});var hf=()=>{let e,t;return{Schema:{enter(r){if(!(r!=null&&r.required)){e=!0;return}t=new Set(r.required),e=!1},SchemaProperties:{skip(){return e},Schema:{enter(r,{key:n,location:i,report:o}){t.has(n)&&r.type==="string"&&(r!=null&&r.minLength||o({message:"Property minLength is required.",location:i.key()}))}}}}}};var yf=()=>{let e=["Schema","Response","Parameter","RequestBody","Example","Header","SecurityScheme","Link","Callback","PathItem"];return{any(t,{report:r,rawNode:n,rawLocation:i,type:o}){!e.includes(o.name)&&we(n)&&r({message:"Field $ref is not expected here.",location:i.child("$ref").key()})}}};var bb="Schema",vb="Parameter",wb="Response",xb="RequestBody",zG={[bb]:"schemas",[vb]:"parameters",[wb]:"responses",[xb]:"requestBodies"},NC=e=>{let t=new Map,r=[];e.schemas!=="off"&&r.push(bb),e.parameters!=="off"&&r.push(vb),e.responses!=="off"&&r.push(wb),e.requestBodies!=="off"&&r.push(xb);let n={ref:{leave(a,{type:c,resolve:l}){let u=c.name;if(r.includes(u)){let p=l(a);if(!p.location)return;s(u,p.location)}}},Root:{leave(a,c){t.forEach((l,u,p)=>{if(l.absolutePointers.size>1){let m=WG(u),d=HG(m.typeName),f=d?e[d]:null;for(let h of l.locations){let y=Array.from(l.absolutePointers).filter(b=>b!==h.absolutePointer.toString()).map(b=>`- ${b}`).join(`
248
+ Repeats of \`in:${r.in}\` + \`name:${r.name}\`.`,location:o.PathItem.child(["parameters",i])}),e.add(`${r.in}___${r.name}`)},Operation:{enter(){t=new Set},Parameter(r,{report:n,key:i,parentLocations:o}){let s=`${r.in}___${r.name}`;t.has(s)&&n({message:`Operations must have unique \`name\` + \`in\` parameters. Repeats of \`in:${r.in}\` + \`name:${r.name}\`.`,location:o.Operation.child(["parameters",i])}),t.add(s)}}}}};var LG=/\{([a-zA-Z0-9_.-]+)\}+/g,ea=()=>{let e,t,r,n;return{PathItem:{enter(i,{key:o}){t=new Set,r=o,e=new Set(Array.from(o.toString().matchAll(LG)).map(s=>s[1]))},Parameter(i,{report:o,location:s}){i.in==="path"&&i.name&&(t.add(i.name),e.has(i.name)||o({message:`Path parameter \`${i.name}\` is not used in the path \`${r}\`.`,location:s.child(["name"])}))},Operation:{enter(){n=new Set},leave(i,{report:o,location:s}){for(let a of Array.from(e.keys()))!n.has(a)&&!t.has(a)&&o({message:`The operation does not define the path parameter \`{${a}}\` expected by path \`${r}\`.`,location:s.child(["parameters"]).key()})},Parameter(i,{report:o,location:s}){i.in==="path"&&i.name&&(n.add(i.name),e.has(i.name)||o({message:`Path parameter \`${i.name}\` is not used in the path \`${r}\`.`,location:s.child(["name"])}))}}}}};var Wp=()=>{let e;return{Root(t){var r;e=new Set(((r=t.tags)!=null?r:[]).map(n=>n.name))},Operation(t,{report:r,location:n}){if(t!=null&&t.tags)for(let i=0;i<t.tags.length;i++)e.has(t.tags[i])||r({message:"Operation tags should be defined in global tags.",location:n.child(["tags",i])});else r({message:"Operation tags should be defined",location:n.key()})}}};var hC=()=>({Example(e,{report:t,location:r}){e.value&&e.externalValue&&t({message:"Example object can have either `value` or `externalValue` fields.",location:r.child(["value"]).key()})}});var fn=()=>({Schema(e,{report:t,location:r}){if(!(e.enum&&!Array.isArray(e.enum))){if(e.enum&&e.type&&!Array.isArray(e.type)){let n=e.enum.filter(i=>!Js(i,e.type,e.nullable));for(let i of n)t({message:`All values of \`enum\` field must be of the same type as the \`type\` field: expected "${e.type}" but received "${Gs(i)}".`,location:r.child(["enum",e.enum.indexOf(i)])})}if(e.enum&&e.type&&Array.isArray(e.type)){let n={};for(let i of e.enum){n[i]=[];for(let o of e.type)Js(i,o,e.nullable)||n[i].push(o);n[i].length!==e.type.length&&delete n[i]}for(let i of Object.keys(n))t({message:`Enum value \`${i}\` must be of allowed types: \`${e.type}\`.`,location:r.child(["enum",e.enum.indexOf(i)])})}}}});var Yp=()=>({PathItem(e,{report:t,key:r,rawLocation:n}){r.endsWith("/")&&r!=="/"&&t({message:`\`${r}\` should not have a trailing slash.`,location:n.key()})}});var Gp=()=>({PathItem(e,{report:t,key:r}){r.indexOf("{}")!==-1&&t({message:"Path parameter declarations must be non-empty. `{}` is invalid.",location:{reportOnKey:!0}})}});var DG=/^[A-Za-z0-9-._~:/?#\[\]@!\$&'()*+,;=]*$/,Jp=()=>({Operation(e,{report:t,location:r}){e.operationId&&!DG.test(e.operationId)&&t({message:"Operation `operationId` should not have URL invalid characters.",location:r.child(["operationId"])})}});var $i=({ignoreCase:e=!1})=>({Root(t,{report:r,location:n}){if(t.tags)for(let i=0;i<t.tags.length-1;i++)Qc(t.tags[i],e)>Qc(t.tags[i+1],e)&&r({message:"The `tags` array should be in alphabetical order.",location:n.child(["tags",i])})}});var yC=()=>({Server(e,{report:t,location:r}){let n=/^(.*[\/.])?(example\.com|localhost)([\/:?].*|$)/;e.url&&n.test(e.url)&&t({message:"Server `url` should not point to example.com or localhost.",location:r.child(["url"])})}});var gC=()=>({Server(e,{report:t,location:r}){e.url&&e.url.endsWith("/")&&e.url!=="/"&&t({message:"Server `url` should not have a trailing slash.",location:r.child(["url"])})}});var Ei=()=>({Tag(e,t){cr("description",e,t)}});var dn=()=>({Info(e,{report:t,location:r}){e.contact||t({message:Xc("Info","contact"),location:r.child("contact").key()})}});var Xp=()=>({Info(e,{report:t}){e.license||t({message:Xc("Info","license"),location:{reportOnKey:!0}})}});var Ai=()=>{let e;return{Root:{enter(t){e=ms(t)},License:{leave(t,r){e==="oas3_1"||e==="oas3_2"?tC(["url","identifier"],t,r):cr("url",t,r)}}}}};var Qp=()=>({Operation(e,t){cr("description",e,t)}});var bC=()=>{let e=new Map;function t(r,n){var i;e.set(r.absolutePointer,{used:((i=e.get(r.absolutePointer))==null?void 0:i.used)||!1,location:r,name:n})}return{ref(r,{type:n,resolve:i,key:o,location:s}){if(["Schema","Header","Parameter","Response","Example","RequestBody"].includes(n.name)){let a=i(r);if(!a.location)return;e.set(a.location.absolutePointer,{used:!0,name:o.toString(),location:s})}},Root:{leave(r,{report:n}){e.forEach(i=>{i.used||n({message:`Component: "${i.name}" is never used.`,location:i.location.key()})})}},NamedSchemas:{Schema(r,{location:n,key:i}){r.allOf||t(n,i.toString())}},NamedParameters:{Parameter(r,{location:n,key:i}){t(n,i.toString())}},NamedResponses:{Response(r,{location:n,key:i}){t(n,i.toString())}},NamedExamples:{Example(r,{location:n,key:i}){t(n,i.toString())}},NamedRequestBodies:{RequestBody(r,{location:n,key:i}){t(n,i.toString())}},NamedHeaders:{Header(r,{location:n,key:i}){t(n,i.toString())}}}};var Zp=()=>({Paths:{PathItem(e,{report:t,key:r}){r.toString().includes("?")&&t({message:"Don't put query string items in the path, they belong in parameters with `in: query`.",location:{reportOnKey:!0}})}}});var ef=()=>({Parameter(e,{report:t,location:r}){e.description===void 0?t({message:"Parameter object description must be present.",location:{reportOnKey:!0}}):e.description||t({message:"Parameter object description must be non-empty string.",location:r.child(["description"])})}});var tf=()=>({Operation(e,{report:t,location:r}){e.tags&&e.tags.length>1&&t({message:"Operation `tags` object should have only one tag.",location:r.child(["tags"]).key()})}});var rf=e=>{let t=new Map,r=[],n=!0,i;return{Root:{leave(o,{report:s}){for(let[a,c]of t.entries())if(!c.defined)for(let l of c.from)s({message:`There is no \`${a}\` security scheme defined.`,location:l.key()});if(!(o.security||n))for(let a of r)s({message:"Every operation should have security defined on it or on the root level.",location:a.key()})}},SecurityScheme(o,{key:s}){t.set(s.toString(),{defined:!0,from:[]})},SecurityRequirement(o,{location:s}){for(let a of Object.keys(o)){let c=t.get(a),l=s.child([a]);c?c.from.push(l):t.set(a,{from:[l]})}},PathItem:{enter(o,{key:s}){i=s},Operation(o,{location:s,key:a}){var l;let c=(l=e.exceptions)==null?void 0:l.some(u=>{var p;return u.path===i&&(!u.methods||((p=u.methods)==null?void 0:p.some(m=>m.toLowerCase()===a)))});!(o!=null&&o.security)&&!c&&(n=!1,r.push(s))}}}};var dr=()=>({ref:{leave(e,{report:t,location:r},n){n.node===void 0&&ta(n,t,r)}},DiscriminatorMapping(e,{report:t,resolve:r,location:n}){for(let i of Object.keys(e)){let o=r({$ref:e[i]});if(o.node!==void 0)return;ta(o,t,n.child(i))}}});function ta(e,t,r){var o;let n=e.error;n instanceof qn&&t({message:"Failed to parse: "+n.message,location:{source:n.source,pointer:void 0,start:{col:n.col,line:n.line}}});let i=(o=e.error)==null?void 0:o.message;t({location:r,message:`Can't resolve $ref${i?": "+i:""}`})}var vC=e=>{let t=e.prefixes||["is","has"],r=new RegExp(`^(${t.join("|")})[A-Z-_]`),n=t.map(o=>`\`${o}\``),i=n.length===1?n[0]:n.slice(0,-1).join(", ")+" or "+n[t.length-1];return{Parameter:{Schema(o,{report:s,parentLocations:a},c){o.type==="boolean"&&!r.test(c.Parameter.name)&&s({message:`Boolean parameter \`${c.Parameter.name}\` should have ${i} prefix.`,location:a.Parameter.child(["name"])})}}}};var nf=()=>({PathItem(e,{report:t,key:r}){r.substr(1).split("/").filter(i=>i!=="").every(i=>/^{.+}$/.test(i)||/^[a-z0-9-.]+$/.test(i))||t({message:`\`${r}\` does not use kebab-case.`,location:{reportOnKey:!0}})}});var FG=["get","head","post","put","patch","delete","options","query","trace"],of=e=>{let t=e&&e.order||FG;if(!Array.isArray(t))throw new Error("path-http-verbs-order `order` option must be an array");return{PathItem(r,{report:n,location:i}){let o=Object.keys(r).filter(s=>t.includes(s));for(let s=0;s<o.length-1;s++){let a=t.indexOf(o[s]);t.indexOf(o[s+1])<a&&n({message:"Operation http verbs must be ordered.",location:{reportOnKey:!0,...i.child(o[s+1])}})}}}};var wC=()=>({Root(e,{report:t,location:r}){if(!e.hasOwnProperty("servers")){t({message:"Servers must be present.",location:r.child(["openapi"]).key()});return}(!Array.isArray(e.servers)||e.servers.length===0)&&t({message:"Servers must be a non-empty array.",location:r.child(["servers"]).key()})}});var xC=e=>({MediaType:{leave(t,r){let{location:n,resolve:i}=r;if(!t.schema)return;if(t.example!==void 0)o(t.example,n.child("example"));else if(t.examples)for(let s of Object.keys(t.examples))o(t.examples[s],n.child(["examples",s,"value"]),!0);function o(s,a,c){if(we(s)){let l=i(s);if(!l.location)return;a=c?l.location.child("value"):l.location,s=l.node}c&&typeof(s==null?void 0:s.value)>"u"||Oi(c?s.value:s,t.schema,a,r,!!e.allowAdditionalProperties)}}}});var sf=()=>({Paths(e,{report:t,location:r}){let n=new Map;for(let i of Object.keys(e)){let o=i.replace(/{.+?}/g,"{VARIABLE}"),s=n.get(o);s?t({message:`The path already exists which differs only by path parameter name(s): \`${s}\` and \`${i}\`.`,location:r.child([i]).key()}):n.set(o,i)}}});var SC=()=>({Server(e,{report:t,location:r}){var o;if(!(e!=null&&e.url))return;let n=((o=e.url.match(/{[^}]+}/g))==null?void 0:o.map(s=>s.slice(1,s.length-1)))||[],i=(e==null?void 0:e.variables)&&Object.keys(e.variables)||[];for(let s of n)i.includes(s)||t({message:`The \`${s}\` variable is not defined in the \`variables\` objects.`,location:r.child(["url"])});for(let s of i)n.includes(s)||t({message:`The \`${s}\` variable is not used in the server's \`url\` field.`,location:r.child(["variables",s]).key(),from:r.child("url")})}});var Ci=()=>({Root:{PathItem:{Operation(e,t){cr("operationId",e,t)}}}});var af=()=>({Operation(e,t){cr("summary",e,t)}});var cf=()=>({Paths(e,{report:t,location:r}){let n=[];for(let i of Object.keys(e)){let o=n.find(s=>BG(s,i));o&&t({message:`Paths should resolve unambiguously. Found two ambiguous paths: \`${o}\` and \`${i}\`.`,location:r.child([i]).key()}),n.push(i)}}});function BG(e,t){let r=e.split("/"),n=t.split("/");if(r.length!==n.length)return!1;let i=0,o=0,s=!0;for(let a=0;a<r.length;a++){let c=r[a].match(/^{.+?}$/),l=n[a].match(/^{.+?}$/);if(c||l){c&&i++,l&&o++;continue}else r[a]!==n[a]&&(s=!1)}return s&&i===o}var OC=()=>({Root(e,{report:t,location:r}){if(!e.servers||e.servers.length===0)return;let n=[];if(Array.isArray(e.servers))for(let i of e.servers){let o=_C(i);o&&n.push(...o)}else{let i=_C(e.servers);if(!i)return;n.push(...i)}for(let i of n)i==="empty"&&t({message:"Server variable with `enum` must be a non-empty array.",location:r.child(["servers"]).key()}),i==="invalidDefaultValue"&&t({message:"Server variable define `enum` and `default`. `enum` must include default value",location:r.child(["servers"]).key()})}});function _C(e){var r;if(e.variables&&Object.keys(e.variables).length===0)return;let t=[];for(let n in e.variables){let i=e.variables[n];if(!i.enum||(Array.isArray(i.enum)&&((r=i.enum)==null?void 0:r.length)===0&&t.push("empty"),!i.default))continue;let o=e.variables[n].default;i.enum&&!i.enum.includes(o)&&t.push("invalidDefaultValue")}if(t.length)return t}var UG=["get","head","post","put","patch","delete","options","trace"],lf=({splitIntoWords:e})=>({PathItem(t,{key:r,report:n,location:i}){let o=r.toString();if(!o.startsWith("/"))return;let s=o.split("/");for(let a of s){if(!a||Xl(a))continue;let c=l=>e?Rx(a).has(l):a.toLocaleLowerCase().includes(l);for(let l of UG)c(l)&&n({message:`path \`${o}\` should not contain http verb ${l}`,location:i.key()})}}});var PC=({allowedValues:e})=>({Paths:{RequestBody:{leave(t,r){si({type:"consumes",value:t},r,e)}},Callback:{RequestBody(){},Response:{leave(t,r){si({type:"consumes",value:t},r,e)}}}},WebhooksMap:{Response:{leave(t,r){si({type:"consumes",value:t},r,e)}}}});var $C=({allowedValues:e})=>({Paths:{Response:{leave(t,r){si({type:"produces",value:t},r,e)}},Callback:{Response(){},RequestBody:{leave(t,r){si({type:"produces",value:t},r,e)}}}},WebhooksMap:{RequestBody:{leave(t,r){si({type:"produces",value:t},r,e)}}}});var EC=Ee(am(),1);var uf=e=>{let{ignoreLastPathSegment:t,exceptions:r}=e;return{PathItem:{leave(n,{report:i,key:o,location:s}){let a=o.toString();if(a.startsWith("/")){let c=a.split("/");c.shift(),t&&c.length>0&&c.pop();for(let l of c)r&&r.includes(l)||!Xl(l)&&EC.default.isSingular(l)&&i({message:`path segment \`${l}\` should be plural.`,location:s.key()})}}}}};var pf=e=>({Schema:{leave(t,r){let n=t.examples;if(n)for(let i of n)Oi(i,t,r.location.child(["examples",n.indexOf(i)]),r,!!e.allowAdditionalProperties);if(t.example!==void 0){if(t.nullable===!0&&t.example===null&&t.type!==void 0)return;Oi(t.example,t,r.location.child("example"),r,!0)}}}});var ff=e=>({Parameter:{leave(t,r){if(t.example!==void 0&&Oi(t.example,t.schema,r.location.child("example"),r,!!e.allowAdditionalProperties),t.examples)for(let[n,i]of Object.entries(t.examples))"value"in i&&Oi(i.value,t.schema,r.location.child(["examples",n]),r,!0)}}});var df=e=>{let t=e.names||{};return{Operation:{Response:{enter:(r,{report:n,location:i,key:o})=>{let s=t[o]||t[En(o)]||t[En(o).toLowerCase()]||[];for(let a of s)(!(r!=null&&r.headers)||!Object.keys(r==null?void 0:r.headers).some(c=>c.toLowerCase()===a.toLowerCase()))&&n({message:`Response object must contain a "${a}" header.`,location:i.child("headers").key()})}}}}};var AC=e=>{let t=e.names||{},r;return{Operation:{Response:{skip:(n,i)=>`${i}`=="204",enter:(n,i)=>{r=i.key},MediaType:{Schema(n,{report:i,location:o}){var a;if(n.type!=="object")return;let s=t[r]||t[En(r)]||t[En(r).toLowerCase()]||[];for(let c of s)(a=n.properties)!=null&&a[c]||i({message:`Response object must contain a top-level "${c}" property.`,location:o.child("properties").key()})}}}}}};var CC=["string","integer","number","boolean","null"],mf=()=>({SchemaProperties(e,{report:t,location:r,specVersion:n,resolve:i}){for(let o of Object.keys(e)){let s=i(en(e,o)).node;!s||!VG(s)||s.example===void 0&&s.examples===void 0&&t({message:`Scalar property should have "example"${n==="oas3_1"||n==="oas3_2"?' or "examples"':""} defined.`,location:r.child(o).key()})}}});function VG(e){return!e.type||e.allOf||e.anyOf||e.oneOf||e.format==="binary"?!1:Array.isArray(e.type)?e.type.every(t=>CC.includes(t)):CC.includes(e.type)}var RC=()=>{let e="^[a-zA-Z0-9\\.\\-_]+$";function t(r,n,i,o){new RegExp(e).test(r)||n({message:`The map key in ${o} "${r}" does not match the regular expression "${e}"`,location:i.key()})}return{NamedSchemas:{Schema(r,{key:n,report:i,location:o}){t(n,i,o,"schemas")}},NamedParameters:{Parameter(r,{key:n,report:i,location:o}){t(n,i,o,"parameters")}},NamedResponses:{Response(r,{key:n,report:i,location:o}){t(n,i,o,"responses")}},NamedExamples:{Example(r,{key:n,report:i,location:o}){t(n,i,o,"examples")}},NamedRequestBodies:{RequestBody(r,{key:n,report:i,location:o}){t(n,i,o,"requestBodies")}},NamedHeaders:{Header(r,{key:n,report:i,location:o}){t(n,i,o,"headers")}},NamedSecuritySchemes:{SecurityScheme(r,{key:n,report:i,location:o}){t(n,i,o,"securitySchemes")}},NamedLinks:{Link(r,{key:n,report:i,location:o}){t(n,i,o,"links")}},NamedCallbacks:{Callback(r,{key:n,report:i,location:o}){t(n,i,o,"callbacks")}}}};var TC=()=>({Response:{skip(e,t){return!/4[Xx0-9]{2}/.test(`${t}`)},enter(e,{report:t,location:r}){(!e.content||!e.content["application/problem+json"])&&t({message:"Response `4xx` must have content-type `application/problem+json`.",location:r.key()})},MediaType:{skip(e,t){return t!=="application/problem+json"},enter(e,t){cr("schema",e,t)},SchemaProperties(e,t){cr("type",e,t),cr("title",e,t)}}}});var hf=()=>{let e,t;return{Schema:{enter(r){if(!(r!=null&&r.required)){e=!0;return}t=new Set(r.required),e=!1},SchemaProperties:{skip(){return e},Schema:{enter(r,{key:n,location:i,report:o}){t.has(n)&&r.type==="string"&&(r!=null&&r.minLength||o({message:"Property minLength is required.",location:i.key()}))}}}}}};var yf=()=>{let e=["Schema","Response","Parameter","RequestBody","Example","Header","SecurityScheme","Link","Callback","PathItem"];return{any(t,{report:r,rawNode:n,rawLocation:i,type:o}){!e.includes(o.name)&&we(n)&&r({message:"Field $ref is not expected here.",location:i.child("$ref").key()})}}};var bb="Schema",vb="Parameter",wb="Response",xb="RequestBody",zG={[bb]:"schemas",[vb]:"parameters",[wb]:"responses",[xb]:"requestBodies"},NC=e=>{let t=new Map,r=[];e.schemas!=="off"&&r.push(bb),e.parameters!=="off"&&r.push(vb),e.responses!=="off"&&r.push(wb),e.requestBodies!=="off"&&r.push(xb);let n={ref:{leave(a,{type:c,resolve:l}){let u=c.name;if(r.includes(u)){let p=l(a);if(!p.location)return;s(u,p.location)}}},Root:{leave(a,c){t.forEach((l,u,p)=>{if(l.absolutePointers.size>1){let m=WG(u),d=HG(m.typeName),f=d?e[d]:null;for(let h of l.locations){let y=Array.from(l.absolutePointers).filter(b=>b!==h.absolutePointer.toString()).map(b=>`- ${b}`).join(`
249
249
  `),g={message:`Component '${d}/${m.componentName}' is not unique. It is also defined at:
250
250
  ${y}`,location:h};f&&(g.forceSeverity=f),c.report(g)}}})}}};return e.schemas!="off"&&(n.NamedSchemas={Schema(a,{location:c}){s(bb,c)}}),e.responses!="off"&&(n.NamedResponses={Response(a,{location:c}){s(wb,c)}}),e.parameters!="off"&&(n.NamedParameters={Parameter(a,{location:c}){s(vb,c)}}),e.requestBodies!="off"&&(n.NamedRequestBodies={RequestBody(a,{location:c}){s(xb,c)}}),n;function i(a){let c=a.split("/").slice(-1)[0];return c.endsWith(".yml")||c.endsWith(".yaml")||c.endsWith(".json")?c.slice(0,c.lastIndexOf(".")):c}function o(a,c,l){var d;let u=KG(a,c),p=(d=t.get(u))!=null?d:{absolutePointers:new Set,locations:[]},m=l.absolutePointer.toString();p.absolutePointers.has(m)||(p.absolutePointers.add(m),p.locations.push(l)),t.set(u,p)}function s(a,c){let l=i(c.absolutePointer.toString());o(a,l,c)}};function HG(e){var t;return(t=zG[e])!=null?t:null}function KG(e,t){return`${e}/${t}`}function WG(e){let[t,r]=e.split("/");return{typeName:t,componentName:r}}var IC=e=>({Parameter:{leave(t,r){if(!t.schema)return;let n=we(t.schema)?r.resolve(t.schema).node:t.schema;n&&YG(t,n,e)&&r.report({message:`Parameter \`${t.name}\` should have \`style\` and \`explode \` fields`,location:r.location})}}});function YG(e,t,r){var n;return(t.type==="array"||t.items||t.prefixItems)&&(e.style===void 0||e.explode===void 0)&&(!r.in||e.in&&((n=r.in)==null?void 0:n.includes(e.in)))}var mn=()=>({Schema:{enter(e,{location:t,report:r,resolve:n}){if(!e.required)return;let i=new Set,o=(a,c)=>{var l,u,p,m,d;if(i.has(a))return{};if(i.add(a),we(a)){let f=n(a,c);return o(f.node,(l=f.location)==null?void 0:l.source.absoluteRef)}return Object.assign({},a.properties,...(p=(u=a.allOf)==null?void 0:u.map(f=>o(f,c)))!=null?p:[],...(d=(m=a.anyOf)==null?void 0:m.map(f=>o(f,c)))!=null?d:[])},s=o(e);for(let[a,c]of e.required.entries())(!s||en(s,c)===void 0)&&r({message:`Required property '${c}' is undefined.`,location:t.child(["required",a])})}}});var hn=()=>({Schema(e,{report:t,location:r}){e.type==="object"&&e.items&&t({message:"Schema type mismatch: 'object' type should not contain 'items' field.",location:r.child("items")}),e.type==="array"&&e.properties&&t({message:"Schema type mismatch: 'array' type should not contain 'properties' field.",location:r.child("properties")})}});var Ri=({ignoreCase:e=!1})=>{let t=new Set;return{Tag:{leave(r,n){let i=Qc(r,e);t.has(i)?n.report({message:`Duplicate tag name found: '${r.name}'.`,location:n.location}):t.add(i)}}}};var kC=()=>({Schema:{leave(e,t){"nullable"in e&&!("type"in e)&&t.report({message:"The `type` field must be defined when the `nullable` field is used.",location:t.location.child(["nullable"])})}}});var qC={struct:fr,"info-contact":dn,"info-license":Xp,"info-license-strict":Ai,"operation-2xx-response":Vp,"operation-4xx-response":zp,"operation-4xx-problem-details-rfc7807":TC,assertions:Nr,"operation-operationId-unique":Hp,"operation-parameters-unique":Kp,"operation-tag-defined":Wp,"no-example-value-and-externalValue":hC,"no-enum-type-mismatch":fn,"no-path-trailing-slash":Yp,"no-empty-servers":wC,"path-declaration-must-exist":Gp,"operation-operationId-url-safe":Jp,"operation-operationId":Ci,"operation-summary":af,"tags-alphabetical":$i,"no-server-example.com":yC,"no-server-trailing-slash":gC,"tag-description":Ei,"operation-description":Qp,"no-unused-components":bC,"path-not-include-query":Zp,"path-parameters-defined":ea,"path-params-defined":ea,"parameter-description":ef,"operation-singular-tag":tf,"security-defined":rf,"no-unresolved-refs":dr,"paths-kebab-case":nf,"boolean-parameter-prefixes":vC,"path-http-verbs-order":of,"no-invalid-media-type-examples":xC,"no-identical-paths":sf,"no-ambiguous-paths":cf,"no-undefined-server-variable":SC,"no-server-variables-empty-enum":OC,"no-http-verbs-in-paths":lf,"request-mime-type":PC,"response-mime-type":$C,"path-segment-plural":uf,"no-invalid-schema-examples":pf,"no-invalid-parameter-examples":ff,"response-contains-header":df,"response-contains-property":AC,"scalar-property-missing-example":mf,"spec-components-invalid-map-name":RC,"required-string-property-missing-min-length":hf,"spec-strict-refs":yf,"component-name-unique":NC,"array-parameter-serialization":IC,"no-required-schema-properties-undefined":mn,"no-schema-type-mismatch":hn,"no-duplicated-tag-names":Ri,"nullable-type-sibling":kC},jC={};var MC=e=>{let t=e.prefixes||["is","has"],r=new RegExp(`^(${t.join("|")})[A-Z-_]`),n=t.map(o=>`\`${o}\``),i=n.length===1?n[0]:n.slice(0,-1).join(", ")+" or "+n[t.length-1];return{Parameter(o,{report:s,location:a}){o.type==="boolean"&&!r.test(o.name)&&s({message:`Boolean parameter \`${o.name}\` should have ${i} prefix.`,location:a.child("name")})}}};var LC=({allowedValues:e})=>({Root(t,r){ss({type:"consumes",value:t},r,e)},Operation:{leave(t,r){ss({type:"consumes",value:t},r,e)}}});var DC=({allowedValues:e})=>({Root(t,r){ss({type:"produces",value:t},r,e)},Operation:{leave(t,r){ss({type:"produces",value:t},r,e)}}});var FC=e=>{let t=e.names||{},r;return{Operation:{Response:{skip:(n,i)=>`${i}`=="204",enter:(n,i)=>{r=i.key},Schema(n,{report:i,location:o}){var a;if(n.type!=="object")return;let s=t[r]||t[En(r)]||t[En(r).toLowerCase()]||[];for(let c of s)(a=n.properties)!=null&&a[c]||i({message:`Response object must contain a top-level "${c}" property.`,location:o.child("properties").key()})}}}}};var BC={struct:fr,"no-invalid-schema-examples":pf,"no-invalid-parameter-examples":ff,"info-contact":dn,"info-license":Xp,"info-license-strict":Ai,"tag-description":Ei,"tags-alphabetical":$i,"paths-kebab-case":nf,"no-enum-type-mismatch":fn,"boolean-parameter-prefixes":MC,"no-path-trailing-slash":Yp,"operation-2xx-response":Vp,"operation-4xx-response":zp,assertions:Nr,"operation-operationId-unique":Hp,"operation-parameters-unique":Kp,"path-parameters-defined":ea,"operation-tag-defined":Wp,"path-declaration-must-exist":Gp,"operation-operationId-url-safe":Jp,"operation-operationId":Ci,"operation-summary":af,"operation-description":Qp,"path-not-include-query":Zp,"path-params-defined":ea,"parameter-description":ef,"operation-singular-tag":tf,"security-defined":rf,"no-unresolved-refs":dr,"no-identical-paths":sf,"no-ambiguous-paths":cf,"path-http-verbs-order":of,"no-http-verbs-in-paths":lf,"request-mime-type":LC,"response-mime-type":DC,"path-segment-plural":uf,"response-contains-header":df,"response-contains-property":FC,"scalar-property-missing-example":mf,"required-string-property-missing-min-length":hf,"spec-strict-refs":yf,"no-required-schema-properties-undefined":mn,"no-schema-type-mismatch":hn,"no-duplicated-tag-names":Ri},UC={};var VC=()=>({Channel(e,{report:t,key:r}){r.split(/[/.:]/).filter(i=>i!=="").every(i=>/^{.+}$/.test(i)||/^[a-z0-9-.]+$/.test(i))||t({message:`\`${r}\` does not use kebab-case.`,location:{reportOnKey:!0}})}});var zC=()=>({Channel(e,{report:t,key:r,location:n}){r.endsWith("/")&&r!=="/"&&t({message:`\`${r}\` should not have a trailing slash.`,location:n.key()})}});var HC={struct:fr,"no-unresolved-refs":dr,assertions:Nr,"info-contact":dn,"info-license-strict":Ai,"operation-operationId":Ci,"channels-kebab-case":VC,"no-channel-trailing-slash":zC,"tag-description":Ei,"tags-alphabetical":$i,"no-duplicated-tag-names":Ri,"no-required-schema-properties-undefined":mn,"no-enum-type-mismatch":fn,"no-schema-type-mismatch":hn},KC={};var WC=()=>({Channel(e,{report:t}){(e.address||"").split(/[/.:]/).filter(n=>n!=="").every(n=>/^{.+}$/.test(n)||/^[a-z0-9-.]+$/.test(n))||t({message:`\`${e.address}\` does not use kebab-case.`,location:{reportOnKey:!0}})}});var YC=()=>({Channel(e,{report:t,location:r}){var n;(n=e==null?void 0:e.address)!=null&&n.endsWith("/")&&(e==null?void 0:e.address)!=="/"&&t({message:`\`${e.address}\` should not have a trailing slash.`,location:r.key()})}});var GC={struct:fr,"no-unresolved-refs":dr,assertions:Nr,"info-contact":dn,"info-license-strict":Ai,"operation-operationId":Ci,"channels-kebab-case":WC,"no-channel-trailing-slash":YC,"tag-description":Ei,"tags-alphabetical":$i,"no-duplicated-tag-names":Ri,"no-required-schema-properties-undefined":mn,"no-enum-type-mismatch":fn,"no-schema-type-mismatch":hn},JC={};var XC=()=>({SourceDescriptions:{enter(e,{report:t,location:r}){if(e.length)for(let n of e)["openapi","arazzo"].includes(n==null?void 0:n.type)||t({message:"The `type` property of the `sourceDescription` object must be either `openapi` or `arazzo`.",location:r.child([e.indexOf(n)])})}}});var QC=()=>({SourceDescriptions:{enter(e,{report:t,location:r}){e!=null&&e.length||t({message:"The `sourceDescriptions` list must have at least one entry.",location:r})}}});var ZC=()=>{let e=fu.join(", ");return{Root:{enter(t,{report:r,location:n}){fu.includes(t.arazzo)||r({message:`Only ${e} Arazzo ${Om("version is",fu.length)} fully supported by Respect.`,location:n.child("arazzo")})}}}};var e2=()=>{let e=new Set;return{Workflow:{enter(t,{report:r,location:n}){t.workflowId&&(e.has(t.workflowId)&&r({message:"Every workflow must have a unique `workflowId`.",location:n.child([t.workflowId])}),e.add(t.workflowId))}}}};var t2=()=>({Workflow:{enter(e,{report:t,location:r}){if(!e.steps)return;let n=new Set;for(let i of e.steps){if(!i.stepId)return;n.has(i.stepId)&&t({message:"The `stepId` must be unique amongst all steps described in the workflow.",location:r.child(["steps",e.steps.indexOf(i)])}),n.add(i.stepId)}}}});var r2=()=>{let e=new Set;return{SourceDescriptions:{enter(t,{report:r,location:n}){if(t.length)for(let i of t)e.has(i.name)&&r({message:"The `name` must be unique amongst all SourceDescriptions.",location:n.child([t.indexOf(i)])}),e.add(i.name)}}}};var n2=()=>{let e=new Set,t=new Set,r=new Set;return{SourceDescriptions:{enter(n){for(let i of n)t.add(i.name)}},Workflows:{enter(n){for(let i of n)r.add(i.workflowId)}},Workflow:{leave(n,{report:i,location:o}){if(n.dependsOn)for(let s of n.dependsOn){if(s.startsWith("$sourceDescriptions.")){let a=s.split(".")[1];t.has(a)||i({message:`SourceDescription ${a} must be defined in sourceDescriptions.`,location:o.child(["dependsOn",n.dependsOn.indexOf(s)])})}!s.startsWith("$sourceDescriptions")&&!r.has(s)&&i({message:`Workflow ${s} must be defined in workflows.`,location:o.child(["dependsOn",n.dependsOn.indexOf(s)])}),e.has(s)&&i({message:"Every workflow in dependsOn must be unique.",location:o.child(["dependsOn"])}),e.add(s)}}}}};var i2=()=>({Parameters:{enter(e,{report:t,location:r}){if(!e)return;let n=new Set;for(let i of e)n.has(i==null?void 0:i.name)&&t({message:"The parameter `name` must be unique amongst listed parameters.",location:r.child([e.indexOf(i)])}),n.has(i==null?void 0:i.reference)&&t({message:"The parameter `reference` must be unique amongst listed parameters.",location:r.child([e.indexOf(i)])}),i!=null&&i.name?n.add(i.name):n.add(i.reference)}}});var o2=()=>({OnSuccessActionList:{enter(e,{report:t,location:r}){if(!e)return;let n=new Set;for(let i of e)n.has(i==null?void 0:i.name)&&t({message:"The action `name` must be unique amongst listed `onSuccess` actions.",location:r.child([e.indexOf(i)])}),n.has(i==null?void 0:i.reference)&&t({message:"The action `reference` must be unique amongst listed `onSuccess` actions.",location:r.child([e.indexOf(i)])}),i!=null&&i.name?n.add(i.name):n.add(i.reference)}}});var s2=()=>({OnFailureActionList:{enter(e,{report:t,location:r}){if(!e)return;let n=new Set;for(let i of e)n.has(i==null?void 0:i.name)&&t({message:"The action `name` must be unique amongst listed `onFailure` actions.",location:r.child([e.indexOf(i)])}),n.has(i==null?void 0:i.reference)&&t({message:"The action `reference` must be unique amongst listed `onFailure` actions.",location:r.child([e.indexOf(i)])}),i!=null&&i.name?n.add(i.name):n.add(i.reference)}}});var a2=()=>{let e=new Set;return{Step:{leave(){e.clear()},RequestBody:{enter(t,{report:r,location:n}){if(t.replacements)for(let i of t.replacements)e.has(i.target)&&r({message:"Every `replacement` in `requestBody` must be unique.",location:n.child(["replacements",t.replacements.indexOf(i),"target"])}),e.add(i.target)}}}}};var c2=()=>({CriterionObject:{enter(e,{report:t,location:r}){var n;e.type&&(((n=e==null?void 0:e.type)==null?void 0:n.type)==="xpath"||(e==null?void 0:e.type)==="xpath")&&t({message:"The `xpath` type criteria is not supported by Respect.",location:r.child(["type"])})}}});var l2=()=>({FailureActionObject:{enter(e,{report:t,location:r}){let n=e==null?void 0:e.criteria;if(!Array.isArray(n))return;let i=new Set;for(let o of n){let s=JSON.stringify(o);i.has(s)?t({message:"The FailureAction criteria items must be unique.",location:r.child(["criteria",n.indexOf(o)])}):i.add(s)}}},SuccessActionObject:{enter(e,{report:t,location:r}){let n=e==null?void 0:e.criteria;if(!Array.isArray(n))return;let i=new Set;for(let o of n){let s=JSON.stringify(o);i.has(s)?t({message:"The SuccessAction criteria items must be unique.",location:r.child(["criteria",n.indexOf(o)])}):i.add(s)}}},Step:{enter(e,{report:t,location:r}){let n=e==null?void 0:e.successCriteria;if(!Array.isArray(n))return;let i=new Set;for(let o of n){let s=JSON.stringify(o);i.has(s)?t({message:"The Step SuccessCriteria items must be unique.",location:r.child(["successCriteria",n.indexOf(o)])}):i.add(s)}}}});var u2=()=>({Step:{enter(e,{report:t,location:r}){if(!(e==null?void 0:e["x-operation"]))return;let i=e==null?void 0:e["x-security"];if(i)for(let o of i)"schemeName"in o&&t({message:"The `schemeName` can be only used in Step with OpenAPI operation, please use `scheme` instead.",location:r.child(["x-security",i.indexOf(o)])})}}});var GG={apiKey:["apiKey"],basic:["username","password"],digest:["username","password"],bearer:["token"],oauth2:["accessToken"],openIdConnect:["accessToken"],mutualTLS:[]};function p2(e,{report:t,location:r}){if(e)for(let n of e){if("schemeName"in n)continue;let{scheme:i,values:o}=n,s=(i==null?void 0:i.type)==="http"?i.scheme:i==null?void 0:i.type;if(s==="mutualTLS"){Zs.warn("Please use CLI option to provide mutualTLS certificates for mutualTls authentication security schema.");continue}let a=GG[s];if(a)for(let c of a)(!o||!(c in o))&&t({message:`The \`${c}\` is required when using the ${s} authentication security schema.`,location:r.child(["x-security",e.indexOf(n)])});else t({message:`The \`${s}\` authentication security schema is not supported.`,location:r.child(["x-security",e.indexOf(n)])})}}var f2=()=>({Step:{enter(e,t){p2(e==null?void 0:e["x-security"],t)}},Workflow:{enter(e,t){p2(e==null?void 0:e["x-security"],t)}}});var d2=()=>({Workflow:{enter(e,{report:t,location:r}){let n=e==null?void 0:e["x-security"];if(n)for(let i of n)"schemeName"in i&&t({message:"The `schemeName` can't be used in Workflow, please use `scheme` instead.",location:r.child(["x-security",n.indexOf(i)])})}}});var m2={struct:fr,"no-unresolved-refs":dr,assertions:Nr,"sourceDescription-type":XC,"respect-supported-versions":ZC,"workflowId-unique":e2,"stepId-unique":t2,"sourceDescription-name-unique":r2,"sourceDescriptions-not-empty":QC,"workflow-dependsOn":n2,"parameters-unique":i2,"step-onSuccess-unique":o2,"step-onFailure-unique":s2,"requestBody-replacements-unique":a2,"no-criteria-xpath":c2,"criteria-unique":l2,"no-x-security-scheme-name-without-openapi":u2,"x-security-scheme-required-values":f2,"no-x-security-scheme-name-in-workflow":d2,"no-required-schema-properties-undefined":mn,"no-enum-type-mismatch":fn,"no-schema-type-mismatch":hn},h2={};var y2={"info-contact":dn,struct:fr,"no-unresolved-refs":dr,assertions:Nr},g2={};var gf=({operationIds:e})=>({Operation:{leave(t,{report:r,location:n,config:i}){if(!t.operationId)return;if(!e)throw new Error('Parameter "operationIds" is not provided for "operation-description-override" rule');let o=t.operationId;if(e[o])try{let s=e[o];t.description=as(An(s,i==null?void 0:i.configPath))}catch(s){r({message:`Failed to read markdown override file for operation "${o}".
251
251
  ${s.message}`,location:n.child("operationId").key()})}}}});var bf=({tagNames:e})=>({Tag:{leave(t,{report:r,config:n}){if(!e)throw new Error('Parameter "tagNames" is not provided for "tag-description-override" rule');let i=e[t.name];if(i)try{t.description=as(An(i,n==null?void 0:n.configPath))}catch(o){r({message:`Failed to read markdown override file for tag "${t.name}".
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@redocly/mock-server",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Redocly Mock server",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
7
7
  "main": "dist/bin.js",
8
8
  "dependencies": {
9
9
  "@redocly/ajv": "8.11.3",
10
- "@redocly/openapi-core": "2.5.0",
10
+ "@redocly/openapi-core": "2.5.1",
11
11
  "ajv": "8.17.1",
12
12
  "ajv-formats": "^2.1.1",
13
13
  "js-yaml": "4.1.0",