@redocly/openapi-docs 3.4.2 → 3.4.4
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.
- package/dist/redocly-openapi-docs.min.js +781 -772
- package/lib/components/PayloadSamples/Example.js +1 -1
- package/lib/components/PayloadSamples/index.d.ts +0 -1
- package/lib/components/PayloadSamples/index.js +1 -1
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/RequestSamples/CodeSample.js +1 -1
- package/lib/components/Samples/use-example-key.js +1 -1
- package/lib/components/Schema/OneOfSchema.js +1 -0
- package/lib/components/common/linkify.js +3 -1
- package/lib/components/common/schema.js +3 -1
- package/lib/models/example.d.ts +0 -1
- package/lib/models/example.js +1 -1
- package/lib/models/index.d.ts +1 -1
- package/lib/models/index.js +1 -1
- package/lib/models/operation.js +1 -1
- package/lib/models/security.d.ts +1 -6
- package/lib/models/security.js +1 -1
- package/lib/models/types.d.ts +0 -1
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib/types/open-api.d.ts +1 -0
- package/lib/utils/openapi.js +1 -1
- package/lib-esm/components/PayloadSamples/Example.js +1 -1
- package/lib-esm/components/PayloadSamples/index.d.ts +0 -1
- package/lib-esm/components/PayloadSamples/index.js +1 -1
- package/lib-esm/components/Replay/Replay.js +1 -1
- package/lib-esm/components/Replay/utils.js +1 -1
- package/lib-esm/components/RequestSamples/CodeSample.js +1 -1
- package/lib-esm/components/Samples/use-example-key.js +1 -1
- package/lib-esm/components/Schema/OneOfSchema.js +1 -0
- package/lib-esm/components/common/linkify.js +3 -1
- package/lib-esm/components/common/schema.js +3 -1
- package/lib-esm/models/example.d.ts +0 -1
- package/lib-esm/models/example.js +1 -1
- package/lib-esm/models/index.d.ts +1 -1
- package/lib-esm/models/index.js +1 -1
- package/lib-esm/models/operation.js +1 -1
- package/lib-esm/models/security.d.ts +1 -6
- package/lib-esm/models/security.js +1 -1
- package/lib-esm/models/types.d.ts +0 -1
- package/lib-esm/services/OpenAPIParser.js +1 -1
- package/lib-esm/types/open-api.d.ts +1 -0
- package/lib-esm/utils/openapi.js +1 -1
- package/package.json +6 -5
- package/lib/components/PayloadSamples/ExternalExample.d.ts +0 -3
- package/lib/components/PayloadSamples/ExternalExample.js +0 -2
- package/lib/components/PayloadSamples/useExternalExample.d.ts +0 -2
- package/lib/components/PayloadSamples/useExternalExample.js +0 -2
- package/lib-esm/components/PayloadSamples/ExternalExample.d.ts +0 -3
- package/lib-esm/components/PayloadSamples/ExternalExample.js +0 -2
- package/lib-esm/components/PayloadSamples/useExternalExample.d.ts +0 -2
- package/lib-esm/components/PayloadSamples/useExternalExample.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var __rest=this&&this.__rest||function(e,
|
|
1
|
+
var __rest=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i};import{IS_BROWSER,isObject,isString,isUndefined}from"@redocly/theme";import{getDefinitionName}from"../utils";import{JsonPointer}from"../utils/JsonPointer";import{normalizeOptions}from"./config-options/normalizeOptions";export function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}export function concatRefStacks(e,t){return t?e.concat(t):e}export class OpenAPIParser{constructor(e,t,i=normalizeOptions({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=decodeURIComponent(e);try{t=JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const r=IS_BROWSER?window.location.href:"";isString(t)&&(this.definitionUrl=new URL(t,r).href)}validate(e){if(isUndefined(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],i=!1){const r=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,r),this.isRef(e)){const r=getDefinitionName(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(t.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){n=this.deref(n,t,i).resolved}return this.allowMergeRefs&&(n=this.mergeRefs(e,n,i)),{resolved:n,refsStack:pushRef(t,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(t,r)}}mergeRefs(e,t,i){const{$ref:r}=e,n=__rest(e,["$ref"]),s=Object.keys(n);if(0===s.length)return t;if(i&&s.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly"].includes(e)))){const e=n,{description:i,title:r,readOnly:s,writeOnly:o}=e;return{allOf:[{description:i,title:r,readOnly:s,writeOnly:o},t,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},t),n)}mergeAllOf(e,t,i,r=""){var n;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:r},e);let s=Object.assign(Object.assign({},e),{"x-parentRefs":[],absolutePointer:JsonPointer.join(r,["allOf"]),allOf:void 0,title:e.title||getDefinitionName(t)});!isUndefined(s.properties)&&isObject(s.properties)&&(s.properties=Object.assign({},s.properties)),!isUndefined(s.items)&&isObject(s.items)&&(s.items=Object.assign({},s.items));const o=e.allOf.map(((e,t)=>{var n;const{resolved:o,refsStack:f}=this.deref(e,i,!0),l=e.$ref,a=l||JsonPointer.join(r,[String(t)]),c=this.mergeAllOf(o,l,f,a);if(!c["x-circular-ref"]||!c.allOf)return l&&(null===(n=s["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],l)),{$ref:l,refsStack:pushRef(f,l),schema:c,absolutePointer:a}})).filter(Boolean);for(const[e,{schema:i,refsStack:r,absolutePointer:f}]of o.entries()){const{type:o,enum:l,properties:a,items:c,required:d,title:p,description:O,readOnly:u,writeOnly:y,oneOf:m,anyOf:b,"x-circular-ref":h}=i,g=__rest(i,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(s.type===o||isUndefined(s.type)||isUndefined(o)){if(isUndefined(o)||(Array.isArray(o)&&Array.isArray(s.type)?s.type=[...o,...s.type]:s.type=o),isUndefined(l)||(Array.isArray(l)&&Array.isArray(s.enum)?s.enum=Array.from(new Set([...l,...s.enum])):s.enum=l),!isUndefined(a)&&isObject(a)){s.properties=s.properties||{};for(const i in a){const o=concatRefStacks(r,null===(n=a[i])||void 0===n?void 0:n["x-refsStack"]);if(s.properties[i]){if(!h){const r=this.mergeAllOf({allOf:[s.properties[i],a[i]],"x-refsStack":o},t+"/properties/"+i,o,JsonPointer.join(f,["allOf",String(e),"properties",i]));s.properties[i]=r}}else s.properties[i]=Object.assign(Object.assign({},a[i]),{absolutePointer:JsonPointer.join(f,["properties",i]),"x-refsStack":o})}}if(!isUndefined(c)&&!h){const e="boolean"==typeof s.items?{}:Object.assign({},s.items),n="boolean"==typeof i.items?{}:Object.assign({},i.items);s.items=this.mergeAllOf({allOf:[e,n]},t+"/items",r)}isUndefined(m)||(s.oneOf=m),isUndefined(b)||(s.anyOf=b),Array.isArray(d)&&(s.required=[...s.required||[],...d]),s=Object.assign(Object.assign(Object.assign({},s),{title:s.title||p,description:s.description||O,readOnly:isUndefined(s.readOnly)?u:s.readOnly,writeOnly:isUndefined(s.writeOnly)?y:s.writeOnly,"x-circular-ref":s["x-circular-ref"]||h}),g)}}return s}findDerived(e){const t={},i=this.definition.components&&this.definition.components.schemas||{};for(const r in i){const{resolved:n}=this.deref(i[r]);!isUndefined(n.allOf)&&n.allOf.find((t=>!isUndefined(t.$ref)&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+r]=[n["x-discriminator-value"]||r])}return t}hoistOneOfs(e){if(isUndefined(e.allOf))return e;const{allOf:t}=e,i=__rest(e,["allOf"]);for(let e=0;e<t.length;e++){const r=t[e],{oneOf:n}=r,s=__rest(r,["oneOf"]);if(n&&Array.isArray(n)){const r=t.slice(0,e),o=t.slice(e+1),f=Object.keys(s).length>0?[s]:[];return Object.assign(Object.assign({},i),{oneOf:n.map((e=>({allOf:[...r,...f,e,...o]})))})}}return e}}
|
|
2
2
|
//# sourceMappingURL=OpenAPIParser.js.map
|
|
@@ -317,6 +317,7 @@ export interface OpenAPISecurityScheme extends ParsedDescription {
|
|
|
317
317
|
tokenUrl: string;
|
|
318
318
|
'x-defaultClientId'?: string;
|
|
319
319
|
'x-tokenEndpointAuthMethod'?: string;
|
|
320
|
+
'x-assertionType'?: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
|
|
320
321
|
};
|
|
321
322
|
authorizationCode?: {
|
|
322
323
|
refreshUrl?: string;
|
package/lib-esm/utils/openapi.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{dirname}from"path";import UrlTemplate from"url-template";import{IS_BROWSER}from"@redocly/theme";import{deleteEmptyArrayItem,isArrayOfObjects,isNumeric,removeQueryStringAndHash,resolveUrl,sanitizeItemId,normalizeText,getValueFromMdParsedExtension}from"./helpers";import{DEFAULT_TAG_SLUG,MediaTypes}from"../constants";import{JsonPointer}from"./JsonPointer";import{joinWithSeparator}from"../services";function isWildcardStatusCode(e){return"string"==typeof e&&/\dxx/i.test(e)}export function isStatusCode(e){return"default"===e||isNumeric(e)||isWildcardStatusCode(e)}export function getStatusCodeType(e,r=!1){if("default"===e)return r?"error":"success";let t="string"==typeof e?parseInt(e,10):e;if(isWildcardStatusCode(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let i="success";return t>=300&&t<400?i="redirect":t>=400?i="error":t<200&&(i="info"),i}const operationNames={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};export function isOperationName(e){return e in operationNames}export function getOperationName(e){const{operationId:r,pathName:t}=e,i=normalizeText(getValueFromMdParsedExtension(e,"description"));return normalizeText(getValueFromMdParsedExtension(e,"summary"))||r||i&&i.substring(0,50)||t||"<no summary>"}export function getOperationId(e,r){var t;return(null==r?void 0:r.id)?joinWithSeparator(r.id,sanitizeItemId(e.operationId?e.operationId:pointerToId(e.pointer))).toLowerCase():(null===(t=e.tags)||void 0===t?void 0:t.length)?sanitizeItemId(e.operationId?e.operationId:pointerToId(e.pointer)):sanitizeItemId(e.operationId?joinWithSeparator(DEFAULT_TAG_SLUG,e.operationId):pointerToId(e.pointer))}function pointerToId(e){return(null==e?void 0:e.startsWith("/"))?e.slice(1,e.length):e}const schemaKeywordTypes={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};export function detectType(e){if(void 0!==e.type&&!Array.isArray(e.type))return e.type;const r=Object.keys(schemaKeywordTypes);for(const t of r){const r=schemaKeywordTypes[t];if(void 0!==e[t])return r}return"any"}export function isPrimitiveType(e,r=e.type){if(e["x-circular-ref"])return!0;if(void 0!==e.oneOf||void 0!==e.anyOf)return!1;if(e.if&&e.then||e.if&&e.else)return!1;let t=!0;const i=Array.isArray(r);return("object"===r||i&&(null==r?void 0:r.includes("object")))&&(t=void 0!==e.properties?0===Object.keys(e.properties).length:void 0===e.additionalProperties&&void 0===e.unevaluatedProperties&&void 0===e.patternProperties),!Array.isArray(e.items)&&!Array.isArray(e.prefixItems)&&(void 0!==e.items&&"boolean"!=typeof e.items&&("array"===r||i&&(null==r?void 0:r.includes("array")))&&(t=isPrimitiveType(e.items,e.items.type)),t)}export function isJsonLike(e){return-1!==e.search(/json/i)}export function isXmlLike(e){return-1!==(null==e?void 0:e.search(/xml/i))}export function isFormUrlEncoded(e){return e===MediaTypes.URL_ENCODED}export function isMultipartFormData(e){return e===MediaTypes.MULTIPART}function delimitedEncodeField(e,r,t){return Array.isArray(e)?e.map((e=>e.toString())).join(t):"object"==typeof e?Object.keys(e).map((r=>`${r}${t}${e[r]}`)).join(t):r+"="+e.toString()}function deepObjectEncodeField(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):"object"==typeof e?Object.keys(e).map((t=>e[t]?`${r}[${t}]=${e[t]}`:void 0)).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function serializeFormValue(e,r,t){const i="__redoc_param_name__",n=r?"*":"";return UrlTemplate.parse(`{?${i}${n}}`).expand({[i]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function serializeSimpleValue(e,r){const t=e?"*":"",i="__redoc_param_name__",n=UrlTemplate.parse(`{${i}${t}}`);return decodeURIComponent(n.expand({[i]:r}))}export function urlFormEncodePayload(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map((t=>{const i=e[t],{style:n="form",explode:o=!0}=r[t]||{};switch(n){case"form":return serializeFormValue(t,o,i);case"spaceDelimited":return delimitedEncodeField(i,t,"%20");case"pipeDelimited":return delimitedEncodeField(i,t,"|");case"deepObject":return deepObjectEncodeField(i,t);default:return console.warn("Incorrect or unsupported encoding style: "+n),""}})).join("&")}function serializePathParameter(e,r,t,i){const n=t?"*":"";let o="";"label"===r?o=".":"matrix"===r&&(o=";");const a="__redoc_param_name__";return UrlTemplate.parse(`{${o}${a}${n}}`).expand({[a]:i}).replace(/__redoc_param_name__/g,e)}export function serializeQueryParameter(e,r,t,i){const n=n=>{switch(r){case"form":return serializeFormValue(e,t,n);case"spaceDelimited":return Array.isArray(n)||"object"==typeof n?t?serializeFormValue(e,t,n):delimitedEncodeField(i,e,"%20"):(console.warn("The style spaceDelimited is applicable to arrays or objects"),"");case"pipeDelimited":return Array.isArray(n)||"object"==typeof n?t?serializeFormValue(e,t,n):delimitedEncodeField(i,e,"|"):(console.warn("The style pipeDelimited is applicable to arrays or objects"),"");case"deepObject":return!t||Array.isArray(n)||"object"!=typeof n?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):deepObjectEncodeField(n,e);case"simple":return serializeSimpleValue(t,i);default:return console.warn("Unexpected style for query: "+r),""}};return isArrayOfObjects(i)&&(i=deleteEmptyArrayItem(i).map((e=>n(e)))),n(i)}function serializeHeaderParameter(e,r,t){return"simple"===e?serializeSimpleValue(r,t):(console.warn("Unexpected style for header: "+e),"")}function serializeCookieParameter(e,r,t,i){return"form"===r?serializeFormValue(e,t,i):(console.warn("Unexpected style for cookie: "+r),"")}export function serializeParameterValueWithMime(e,r){return isJsonLike(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}export function serializeParameterValue(e,r){const{name:t,style:i,explode:n=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return serializeParameterValueWithMime(r,o);case"cookie":case"query":return`${t}=${serializeParameterValueWithMime(r,o)}`;default:return console.warn("Unexpected parameter location: "+e.in),""}if(!i)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return serializePathParameter(t,i,n,r);case"query":return serializeQueryParameter(t,i,n,r);case"header":return serializeHeaderParameter(i,n,r);case"cookie":return serializeCookieParameter(t,i,n,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}export function langFromMime(e){return-1!==e.search(/xml/i)?"xml":"clike"}const DEFINITION_NAME_REGEX=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;export function isNamedDefinition(e){return DEFINITION_NAME_REGEX.test(e||"")}export function getDefinitionName(e){var r;return null===(r=null==e?void 0:e.match(DEFINITION_NAME_REGEX))||void 0===r?void 0:r.pop()}function humanizeMultipleOfConstraint(e){if(void 0===e)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function humanizeRangeConstraint(e,r,t){let i;return void 0!==r&&void 0!==t?i=r===t?`= ${r} ${e}`:`[ ${r} .. ${t} ] ${e}`:void 0!==t?i=`<= ${t} ${e}`:void 0!==r&&(i=1===r?"non-empty":`>= ${r} ${e}`),i}export function humanizeNumberRange(e){var r,t;const i="number"==typeof e.exclusiveMinimum?Math.min(e.exclusiveMinimum,null!==(r=e.minimum)&&void 0!==r?r:1/0):e.minimum,n="number"==typeof e.exclusiveMaximum?Math.max(e.exclusiveMaximum,null!==(t=e.maximum)&&void 0!==t?t:-1/0):e.maximum,o="number"==typeof e.exclusiveMinimum||e.exclusiveMinimum,a="number"==typeof e.exclusiveMaximum||e.exclusiveMaximum;return void 0!==i&&void 0!==n?`${o?"( ":"[ "}${i} .. ${n}${a?" )":" ]"}`:void 0!==n?`${a?"< ":"<= "}${n}`:void 0!==i?`${o?"> ":">= "}${i}`:void 0}export function humanizeConstraints(e){const r=[],t=humanizeRangeConstraint("characters",e.minLength,e.maxLength);void 0!==t&&r.push(t);const i=humanizeRangeConstraint("items",e.minItems,e.maxItems);void 0!==i&&r.push(i);const n=humanizeRangeConstraint(1===e.minProperties&&1===e.maxProperties?"property":"properties",e.minProperties,e.maxProperties);void 0!==n&&r.push(n);const o=humanizeMultipleOfConstraint(e.multipleOf);void 0!==o&&r.push(o);const a=humanizeNumberRange(e);return void 0!==a&&r.push(a),e.uniqueItems&&r.push("unique"),r}export function sortByRequired(e,r=[]){const t=[],i=[],n=[];return e.forEach((e=>{e.required?r.includes(e.name)?i.push(e):n.push(e):t.push(e)})),i.sort(((e,t)=>r.indexOf(e.name)-r.indexOf(t.name))),[...i,...n,...t]}export function sortByDeprecated(e){return e.sort(((e,r)=>Number(e.deprecated)-Number(r.deprecated)))}export function mergeParams(e,r=[],t=[],{pathPointer:i,operationPointer:n}){const o={};t.forEach((r=>{({resolved:r}=e.deref(r)),o[r.name+"_"+r.in]=!0}));return[...r.map(((e,r)=>({paramOrRef:e,pointer:JsonPointer.join(i,["parameters",String(r)])}))).filter((({paramOrRef:r})=>(({resolved:r}=e.deref(r)),!o[r.name+"_"+r.in]))),...t.map(((e,r)=>({paramOrRef:e,pointer:JsonPointer.join(n,["parameters",String(r)])})))]}export function normalizeServers(e,r){const t=void 0===e?removeQueryStringAndHash((()=>{if(!IS_BROWSER)return globalThis.SSR_HOSTNAME||"";const e=window.location.href;return e.endsWith(".html")?dirname(e):e})()):dirname(e);return 0===r.length&&(r=[{url:"/"}]),r.map((e=>{return Object.assign(Object.assign({},e),{url:(r=e.url,resolveUrl(t,r)),description:e.description||""});var r}))}export const shortenHTTPVerb=e=>({delete:"del",options:"opts"}[e]||e);export function isRedocExtension(e){return e in{"x-circular-ref":!0,"x-parentRefs":!0,"x-refsStack":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-hideReplay":!0,"x-tokenEndpointAuthMethod":!0,"x-feedback":!0,"x-badges":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}export function extractExtensions(e,r){return Object.keys(e).filter((e=>!0===r?e.startsWith("x-")&&!isRedocExtension(e):e.startsWith("x-")&&r.indexOf(e)>-1)).reduce(((r,t)=>(r[t]=e[t],r)),{})}export function pluralizeType(e){return e.split(" or ").map((e=>e.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2"))).join(" or ")}export function getContentWithLegacyExamples(e){let r=e.content;const t=e["x-examples"],i=e["x-example"];if(t){r=Object.assign({},r);for(const e of Object.keys(t)){const i=t[e];r[e]=Object.assign(Object.assign({},r[e]),{examples:i})}}else if(i){r=Object.assign({},r);for(const e of Object.keys(i)){const t=i[e];r[e]=Object.assign(Object.assign({},r[e]),{example:t})}}return r}
|
|
1
|
+
import{dirname}from"path";import UrlTemplate from"url-template";import{IS_BROWSER}from"@redocly/theme";import{deleteEmptyArrayItem,isArrayOfObjects,isNumeric,removeQueryStringAndHash,resolveUrl,sanitizeItemId,normalizeText,getValueFromMdParsedExtension}from"./helpers";import{DEFAULT_TAG_SLUG,MediaTypes}from"../constants";import{JsonPointer}from"./JsonPointer";import{joinWithSeparator}from"../services";function isWildcardStatusCode(e){return"string"==typeof e&&/\dxx/i.test(e)}export function isStatusCode(e){return"default"===e||isNumeric(e)||isWildcardStatusCode(e)}export function getStatusCodeType(e,r=!1){if("default"===e)return r?"error":"success";let t="string"==typeof e?parseInt(e,10):e;if(isWildcardStatusCode(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let i="success";return t>=300&&t<400?i="redirect":t>=400?i="error":t<200&&(i="info"),i}const operationNames={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};export function isOperationName(e){return e in operationNames}export function getOperationName(e){const{operationId:r,pathName:t}=e,i=normalizeText(getValueFromMdParsedExtension(e,"description"));return normalizeText(getValueFromMdParsedExtension(e,"summary"))||r||i&&i.substring(0,50)||t||"<no summary>"}export function getOperationId(e,r){var t;return(null==r?void 0:r.id)?joinWithSeparator(r.id,sanitizeItemId(e.operationId?e.operationId:pointerToId(e.pointer))).toLowerCase():(null===(t=e.tags)||void 0===t?void 0:t.length)?sanitizeItemId(e.operationId?e.operationId:pointerToId(e.pointer)):sanitizeItemId(e.operationId?joinWithSeparator(DEFAULT_TAG_SLUG,e.operationId):pointerToId(e.pointer))}function pointerToId(e){return(null==e?void 0:e.startsWith("/"))?e.slice(1,e.length):e}const schemaKeywordTypes={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};export function detectType(e){if(void 0!==e.type&&!Array.isArray(e.type))return e.type;const r=Object.keys(schemaKeywordTypes);for(const t of r){const r=schemaKeywordTypes[t];if(void 0!==e[t])return r}return"any"}export function isPrimitiveType(e,r=e.type){if(e["x-circular-ref"])return!0;if(void 0!==e.oneOf||void 0!==e.anyOf)return!1;if(e.if&&e.then||e.if&&e.else)return!1;let t=!0;const i=Array.isArray(r);return("object"===r||i&&(null==r?void 0:r.includes("object")))&&(t=void 0!==e.properties?0===Object.keys(e.properties).length:void 0===e.additionalProperties&&void 0===e.unevaluatedProperties&&void 0===e.patternProperties),!Array.isArray(e.items)&&!Array.isArray(e.prefixItems)&&(void 0!==e.items&&"boolean"!=typeof e.items&&("array"===r||i&&(null==r?void 0:r.includes("array")))&&(t=isPrimitiveType(e.items,e.items.type)),t)}export function isJsonLike(e){return-1!==e.search(/json/i)}export function isXmlLike(e){return-1!==(null==e?void 0:e.search(/xml/i))}export function isFormUrlEncoded(e){return e===MediaTypes.URL_ENCODED}export function isMultipartFormData(e){return e===MediaTypes.MULTIPART}function delimitedEncodeField(e,r,t){return Array.isArray(e)?e.map((e=>e.toString())).join(t):"object"==typeof e?Object.keys(e).map((r=>`${r}${t}${e[r]}`)).join(t):r+"="+e.toString()}function deepObjectEncodeField(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):"object"==typeof e?Object.keys(e).map((t=>e[t]?`${r}[${t}]=${e[t]}`:void 0)).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function serializeFormValue(e,r,t){const i="__redoc_param_name__",n=r?"*":"";return UrlTemplate.parse(`{?${i}${n}}`).expand({[i]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function serializeSimpleValue(e,r){const t=e?"*":"",i="__redoc_param_name__",n=UrlTemplate.parse(`{${i}${t}}`);return decodeURIComponent(n.expand({[i]:r}))}export function urlFormEncodePayload(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map((t=>{const i=e[t],{style:n="form",explode:o=!0}=r[t]||{};switch(n){case"form":return serializeFormValue(t,o,i);case"spaceDelimited":return delimitedEncodeField(i,t,"%20");case"pipeDelimited":return delimitedEncodeField(i,t,"|");case"deepObject":return deepObjectEncodeField(i,t);default:return console.warn("Incorrect or unsupported encoding style: "+n),""}})).join("&")}function serializePathParameter(e,r,t,i){const n=t?"*":"";let o="";"label"===r?o=".":"matrix"===r&&(o=";");const a="__redoc_param_name__";return UrlTemplate.parse(`{${o}${a}${n}}`).expand({[a]:i}).replace(/__redoc_param_name__/g,e)}export function serializeQueryParameter(e,r,t,i){const n=n=>{switch(r){case"form":return serializeFormValue(e,t,n);case"spaceDelimited":return Array.isArray(n)||"object"==typeof n?t?serializeFormValue(e,t,n):delimitedEncodeField(i,e,"%20"):(console.warn("The style spaceDelimited is applicable to arrays or objects"),"");case"pipeDelimited":return Array.isArray(n)||"object"==typeof n?t?serializeFormValue(e,t,n):delimitedEncodeField(i,e,"|"):(console.warn("The style pipeDelimited is applicable to arrays or objects"),"");case"deepObject":return!t||Array.isArray(n)||"object"!=typeof n?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):deepObjectEncodeField(n,e);case"simple":return serializeSimpleValue(t,i);default:return console.warn("Unexpected style for query: "+r),""}};return isArrayOfObjects(i)&&(i=deleteEmptyArrayItem(i).map((e=>n(e)))),n(i)}function serializeHeaderParameter(e,r,t){return"simple"===e?serializeSimpleValue(r,t):(console.warn("Unexpected style for header: "+e),"")}function serializeCookieParameter(e,r,t,i){return"form"===r?serializeFormValue(e,t,i):(console.warn("Unexpected style for cookie: "+r),"")}export function serializeParameterValueWithMime(e,r){return isJsonLike(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}export function serializeParameterValue(e,r){const{name:t,style:i,explode:n=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return serializeParameterValueWithMime(r,o);case"cookie":case"query":return`${t}=${serializeParameterValueWithMime(r,o)}`;default:return console.warn("Unexpected parameter location: "+e.in),""}if(!i)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return serializePathParameter(t,i,n,r);case"query":return serializeQueryParameter(t,i,n,r);case"header":return serializeHeaderParameter(i,n,r);case"cookie":return serializeCookieParameter(t,i,n,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}export function langFromMime(e){return-1!==e.search(/xml/i)?"xml":"clike"}const DEFINITION_NAME_REGEX=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;export function isNamedDefinition(e){return DEFINITION_NAME_REGEX.test(e||"")}export function getDefinitionName(e){var r;return null===(r=null==e?void 0:e.match(DEFINITION_NAME_REGEX))||void 0===r?void 0:r.pop()}function humanizeMultipleOfConstraint(e){if(void 0===e)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function humanizeRangeConstraint(e,r,t){let i;return void 0!==r&&void 0!==t?i=r===t?`= ${r} ${e}`:`[ ${r} .. ${t} ] ${e}`:void 0!==t?i=`<= ${t} ${e}`:void 0!==r&&(i=1===r?"non-empty":`>= ${r} ${e}`),i}export function humanizeNumberRange(e){var r,t;const i="number"==typeof e.exclusiveMinimum?Math.min(e.exclusiveMinimum,null!==(r=e.minimum)&&void 0!==r?r:1/0):e.minimum,n="number"==typeof e.exclusiveMaximum?Math.max(e.exclusiveMaximum,null!==(t=e.maximum)&&void 0!==t?t:-1/0):e.maximum,o="number"==typeof e.exclusiveMinimum||e.exclusiveMinimum,a="number"==typeof e.exclusiveMaximum||e.exclusiveMaximum;return void 0!==i&&void 0!==n?`${o?"( ":"[ "}${i} .. ${n}${a?" )":" ]"}`:void 0!==n?`${a?"< ":"<= "}${n}`:void 0!==i?`${o?"> ":">= "}${i}`:void 0}export function humanizeConstraints(e){const r=[],t=humanizeRangeConstraint("characters",e.minLength,e.maxLength);void 0!==t&&r.push(t);const i=humanizeRangeConstraint("items",e.minItems,e.maxItems);void 0!==i&&r.push(i);const n=humanizeRangeConstraint(1===e.minProperties&&1===e.maxProperties?"property":"properties",e.minProperties,e.maxProperties);void 0!==n&&r.push(n);const o=humanizeMultipleOfConstraint(e.multipleOf);void 0!==o&&r.push(o);const a=humanizeNumberRange(e);return void 0!==a&&r.push(a),e.uniqueItems&&r.push("unique"),r}export function sortByRequired(e,r=[]){const t=[],i=[],n=[];return e.forEach((e=>{e.required?r.includes(e.name)?i.push(e):n.push(e):t.push(e)})),i.sort(((e,t)=>r.indexOf(e.name)-r.indexOf(t.name))),[...i,...n,...t]}export function sortByDeprecated(e){return e.sort(((e,r)=>Number(e.deprecated)-Number(r.deprecated)))}export function mergeParams(e,r=[],t=[],{pathPointer:i,operationPointer:n}){const o={};t.forEach((r=>{({resolved:r}=e.deref(r)),o[r.name+"_"+r.in]=!0}));return[...r.map(((e,r)=>({paramOrRef:e,pointer:JsonPointer.join(i,["parameters",String(r)])}))).filter((({paramOrRef:r})=>(({resolved:r}=e.deref(r)),!o[r.name+"_"+r.in]))),...t.map(((e,r)=>({paramOrRef:e,pointer:JsonPointer.join(n,["parameters",String(r)])})))]}export function normalizeServers(e,r){const t=void 0===e?removeQueryStringAndHash((()=>{if(!IS_BROWSER)return globalThis.SSR_HOSTNAME||"";const e=window.location.href;return e.endsWith(".html")?dirname(e):e})()):dirname(e);return 0===r.length&&(r=[{url:"/"}]),r.map((e=>{return Object.assign(Object.assign({},e),{url:(r=e.url,resolveUrl(t,r)),description:e.description||""});var r}))}export const shortenHTTPVerb=e=>({delete:"del",options:"opts"}[e]||e);export function isRedocExtension(e){return e in{"x-circular-ref":!0,"x-parentRefs":!0,"x-refsStack":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-hideReplay":!0,"x-tokenEndpointAuthMethod":!0,"x-feedback":!0,"x-badges":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}export function extractExtensions(e,r){return Object.keys(e).filter((e=>!0===r?e.startsWith("x-")&&!isRedocExtension(e):e.startsWith("x-")&&r.indexOf(e)>-1)).reduce(((r,t)=>(r[t]=e[t],r)),{})}export function pluralizeType(e){return e.split(" or ").map((e=>e.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2"))).join(" or ")}export function getContentWithLegacyExamples(e){let r=e.content;const t=e["x-examples"],i=e["x-example"];if(t){r=Object.assign({},r);for(const e of Object.keys(t)){const i=t[e];r[e]=Object.assign(Object.assign({},r[e]),{examples:i})}}else if(i){r=Object.assign({},r);for(const e of Object.keys(i)){const t=i[e];r[e]=Object.assign(Object.assign({},r[e]),{example:t})}}return r}
|
|
2
2
|
//# sourceMappingURL=openapi.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.4",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"url": "~0.11.0",
|
|
46
46
|
"url-template": "^2.0.8",
|
|
47
47
|
"util": "~0.12.5",
|
|
48
|
-
"@redocly/replay": "0.7.
|
|
48
|
+
"@redocly/replay": "0.7.3",
|
|
49
49
|
"@redocly/config": "0.13.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"compare-versions": "5.0.3",
|
|
68
68
|
"core-js": "3.29.1",
|
|
69
69
|
"css-loader": "6.11.0",
|
|
70
|
-
"esbuild-loader": "
|
|
71
|
-
"fork-ts-checker-webpack-plugin": "
|
|
70
|
+
"esbuild-loader": "4.2.2",
|
|
71
|
+
"fork-ts-checker-webpack-plugin": "9.0.2",
|
|
72
72
|
"html-webpack-plugin": "4.5.2",
|
|
73
73
|
"jest": "29.5.0",
|
|
74
74
|
"jest-environment-jsdom": "29.5.0",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"js-yaml": "4.1.0",
|
|
78
78
|
"json-schema": "0.4.0",
|
|
79
79
|
"outdent": "0.8.0",
|
|
80
|
+
"prettier-2": "npm:prettier@^2",
|
|
80
81
|
"react": "18.2.0",
|
|
81
82
|
"react-dom": "18.2.0",
|
|
82
83
|
"react-is": "18.2.0",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"webpack": "5.94.0",
|
|
94
95
|
"webpack-cli": "5.1.4",
|
|
95
96
|
"webpack-dev-server": "5.1.0",
|
|
96
|
-
"@redocly/theme": "0.44.
|
|
97
|
+
"@redocly/theme": "0.44.6"
|
|
97
98
|
},
|
|
98
99
|
"scripts": {
|
|
99
100
|
"start": "webpack serve --mode=development --hot",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExternalExample=ExternalExample;const jsx_runtime_1=require("react/jsx-runtime"),theme_1=require("@redocly/theme"),useExternalExample_1=require("./useExternalExample"),ExampleValue_1=require("./ExampleValue");function ExternalExample({example:e,mimeType:r,onCopyClick:l}){const a=(0,useExternalExample_1.useExternalExample)(e,r);return void 0===a?(0,jsx_runtime_1.jsx)("span",{children:"Loading..."}):a instanceof Error?(0,jsx_runtime_1.jsxs)(theme_1.CodeBlockContainer,{children:["Error loading external example: ",(0,jsx_runtime_1.jsx)("br",{}),(0,jsx_runtime_1.jsx)("a",{className:"token string",href:e.externalValueUrl,target:"_blank",rel:"noopener noreferrer",children:e.externalValueUrl})]}):(0,jsx_runtime_1.jsx)(ExampleValue_1.ExampleValue,{value:a,mimeType:r,onCopyClick:l})}
|
|
2
|
-
//# sourceMappingURL=ExternalExample.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(a,c){function u(e){try{o(n.next(e))}catch(e){c(e)}}function i(e){try{o(n.throw(e))}catch(e){c(e)}}function o(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,i)}o((n=n.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.useExternalExample=useExternalExample;const react_1=require("react"),models_1=require("../../models");function useExternalExample(e,t){const[,r]=(0,react_1.useState)(!0),n=(0,react_1.useRef)(void 0),a=(0,react_1.useRef)(void 0);return a.current!==e&&(n.current=void 0),a.current=e,(0,react_1.useEffect)((()=>{(()=>{__awaiter(this,void 0,void 0,(function*(){r(!0);try{n.current=yield(0,models_1.getExternalExampleValue)(t,e.externalValueUrl)}catch(e){n.current=e}r(!1)}))})()}),[e,t]),n.current}
|
|
2
|
-
//# sourceMappingURL=useExternalExample.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{CodeBlockContainer}from"@redocly/theme";import{useExternalExample}from"./useExternalExample";import{ExampleValue}from"./ExampleValue";export function ExternalExample({example:e,mimeType:r,onCopyClick:a}){const l=useExternalExample(e,r);return void 0===l?_jsx("span",{children:"Loading..."}):l instanceof Error?_jsxs(CodeBlockContainer,{children:["Error loading external example: ",_jsx("br",{}),_jsx("a",{className:"token string",href:e.externalValueUrl,target:"_blank",rel:"noopener noreferrer",children:e.externalValueUrl})]}):_jsx(ExampleValue,{value:l,mimeType:r,onCopyClick:a})}
|
|
2
|
-
//# sourceMappingURL=ExternalExample.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(u,a){function c(e){try{o(r.next(e))}catch(e){a(e)}}function i(e){try{o(r.throw(e))}catch(e){a(e)}}function o(e){var t;e.done?u(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,i)}o((r=r.apply(e,t||[])).next())}))};import{useEffect,useRef,useState}from"react";import{getExternalExampleValue}from"../../models";export function useExternalExample(e,t){const[,n]=useState(!0),r=useRef(void 0),u=useRef(void 0);return u.current!==e&&(r.current=void 0),u.current=e,useEffect((()=>{(()=>{__awaiter(this,void 0,void 0,(function*(){n(!0);try{r.current=yield getExternalExampleValue(t,e.externalValueUrl)}catch(e){r.current=e}n(!1)}))})()}),[e,t]),r.current}
|
|
2
|
-
//# sourceMappingURL=useExternalExample.js.map
|