@redocly/openapi-docs 3.12.0-next.2 → 3.12.0-next.20
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 +7496 -7418
- package/lib/components/ApiInfo/ApiInfo.d.ts +1 -1
- package/lib/components/ApiInfo/ApiInfo.js +1 -1
- package/lib/components/ApiInfo/Metadata.d.ts +1 -1
- package/lib/components/ApiInfo/Metadata.js +1 -1
- package/lib/components/ApiInfo/styled.js +6 -6
- package/lib/components/CallbackSamples/CallbackSamples.d.ts +1 -1
- package/lib/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib/components/Callbacks/CallbackDetails.d.ts +1 -1
- package/lib/components/Callbacks/CallbackDetails.js +1 -1
- package/lib/components/Callbacks/CallbackSummary.d.ts +2 -1
- package/lib/components/Callbacks/CallbackSummary.js +2 -2
- package/lib/components/Callbacks/styled.js +1 -1
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ContentItem/useIsExpanded.js +1 -1
- package/lib/components/ContentItems/VirtualList.js +1 -1
- package/lib/components/ContentItems/useScrollOnRender.js +1 -1
- package/lib/components/Discriminator/Discriminator.d.ts +1 -1
- package/lib/components/Download/DownloadSpecification.js +2 -2
- package/lib/components/ExpandAllButton/ExpandAllButton.js +1 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.js +1 -1
- package/lib/components/Language/LanguageDropdown.js +1 -1
- package/lib/components/Language/LanguageItem.js +1 -1
- package/lib/components/Language/LanguageList.js +1 -1
- package/lib/components/Language/styled.js +9 -9
- package/lib/components/Markdown/Markdown.d.ts +1 -1
- package/lib/components/Markdown/Markdown.js +1 -1
- package/lib/components/Markdown/types.d.ts +11 -2
- package/lib/components/OperationItem/Description.d.ts +1 -4
- package/lib/components/OperationItem/Description.js +1 -1
- package/lib/components/OperationItem/OperationItem.js +3 -3
- package/lib/components/Overview/Overview.d.ts +1 -1
- package/lib/components/Overview/Overview.js +1 -1
- package/lib/components/PageFooter/PageFooter.js +1 -1
- package/lib/components/Panel/ResponsePanel.js +1 -1
- package/lib/components/PanelItem/styled.js +1 -1
- package/lib/components/PayloadSamples/ExampleValue.js +1 -1
- package/lib/components/PayloadSamples/styled.js +1 -1
- package/lib/components/PropertyDetails/Extensions.js +1 -1
- package/lib/components/PropertyDetails/FieldDetails.js +1 -1
- package/lib/components/PropertyDetails/styled.js +1 -1
- package/lib/components/PropertyDetails/types.d.ts +1 -1
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/types.d.ts +2 -2
- package/lib/components/Replay/EmbeddedReplay.js +3 -3
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/components/Replay/utils.d.ts +1 -1
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/Request/RequestDetails.js +2 -2
- package/lib/components/Request/types.d.ts +1 -1
- package/lib/components/RequestParameters/ParametersGroup.js +1 -1
- package/lib/components/RequestSamples/CodeSample.js +1 -1
- package/lib/components/RequestSamples/Example.js +1 -1
- package/lib/components/RequestSamples/RequestSamples.js +1 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +1 -1
- package/lib/components/ResponseSamples/Summary.js +1 -1
- package/lib/components/RightPanel/RightPanel.js +1 -1
- package/lib/components/Samples/ExampleSwitch.js +1 -1
- package/lib/components/Schema/helpers.js +1 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +1 -1
- package/lib/components/SectionContent/SectionContent.js +5 -5
- package/lib/components/SectionItem/SectionItem.d.ts +1 -1
- package/lib/components/SectionItem/SectionItem.js +1 -1
- package/lib/components/Security/OAuthScopes.js +1 -1
- package/lib/components/Security/Security.js +1 -1
- package/lib/components/Security/SecurityButton.js +2 -2
- package/lib/components/Security/SecurityModal.js +5 -5
- package/lib/components/ServerList/ServerList.js +1 -1
- package/lib/components/ServerList/types.d.ts +1 -1
- package/lib/components/ServerListDropdown/ServerListDropdown.js +1 -1
- package/lib/components/ServerListDropdown/styled.js +6 -6
- package/lib/components/SideMenu/SideMenu.js +1 -1
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/StickySidebar/SidebarActions.js +2 -2
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +3 -3
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/Tabs/useTabsState.js +1 -1
- package/lib/components/TagItem/OperationNavigationItems.d.ts +1 -1
- package/lib/components/TagItem/OperationsNavigation.js +1 -1
- package/lib/components/TagItem/TagItem.js +7 -7
- package/lib/components/TagItem/styled.js +1 -1
- package/lib/components/ViewNested/ViewNested.js +1 -1
- package/lib/components/common/Badges.js +1 -1
- package/lib/components/common/BodyContent/BodyContent.js +1 -1
- package/lib/components/common/CodeBlockPanel.js +3 -3
- package/lib/components/common/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/common/Dropdown/Dropdown.js +4 -4
- package/lib/components/common/ExpandableExample/ExpandableExample.js +1 -1
- package/lib/components/common/Extensions.js +1 -1
- package/lib/components/common/Fields/fields-layout.js +1 -1
- package/lib/components/common/Fields/fields.js +1 -1
- package/lib/components/common/LinkToField.js +1 -1
- package/lib/components/common/OperationItemTitle.js +3 -3
- package/lib/components/common/SchemaSelection/SchemaSelection.d.ts +1 -1
- package/lib/components/common/SchemaSelection/SchemaSelection.js +1 -1
- package/lib/components/common/Select/styled.js +1 -1
- package/lib/components/common/Skeleton/Skeleton.js +1 -1
- package/lib/components/common/linkify.js +1 -1
- package/lib/components/common/panels.js +9 -13
- package/lib/components/common/styled.js +1 -1
- package/lib/hoc/types.d.ts +1 -1
- package/lib/hoc/withRouter.js +1 -1
- package/lib/hooks/usePerformanceMetrics.js +1 -1
- package/lib/hooks/useTelemetry.d.ts +1 -1
- package/lib/hooks/useTelemetry.js +1 -1
- package/lib/hooks/useTranslate.d.ts +1 -1
- package/lib/hooks/useTranslate.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/jotai/app.d.ts +2 -2
- package/lib/jotai/app.js +1 -1
- package/lib/models/callback.d.ts +1 -1
- package/lib/models/mediaType.js +1 -1
- package/lib/models/operation.d.ts +1 -1
- package/lib/models/operation.js +1 -1
- package/lib/models/schema.js +2 -2
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib/services/code-samples/generator.d.ts +4 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +2 -2
- package/lib/services/code-samples/httpsnippet/index.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +1 -1
- package/lib/services/config-options/normalizeOptions.js +1 -1
- package/lib/services/config-options/types.d.ts +3 -11
- package/lib/services/menu/markdown.js +1 -1
- package/lib/services/utils.js +1 -1
- package/lib/types/open-api.d.ts +3 -1
- package/lib/utils/configure-helpers.d.ts +1 -1
- package/lib/utils/configure-helpers.js +1 -1
- package/lib/utils/helpers.js +2 -2
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -1
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/lib/utils/local-storage.js +1 -1
- package/lib/utils/openapi.js +1 -1
- package/lib/utils/saveTextBeforeHeading.js +1 -1
- package/lib/utils/security-details.js +1 -1
- package/lib/utils/session-storage.js +1 -1
- package/lib/utils/telemetry.d.ts +1 -0
- package/lib/utils/telemetry.js +1 -0
- package/package.json +6 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as p from"util";import{Lang as i,NamingVariableConventions as l,VariableType as c}from"./constants.js";import o from"./string-utility.js";const S={[i.NODEJS]:l.CAMEL_CASE,[i.JAVASCRIPT]:l.CAMEL_CASE,[i.PYTHON]:l.UNDER_SCORES,[i.JAVA8]:l.CAMEL_CASE,[i.JAVA]:l.CAMEL_CASE,[i.CSHARP]:l.PASCAL_CASE,[i.CSHARPNEWTONSOFT]:l.PASCAL_CASE,[i.CURL]:l.CAMEL_CASE,[i.GO]:l.CAMEL_CASE,[i.PHP]:l.CAMEL_CASE,[i.RUBY]:l.UNDER_SCORES,[i.R]:l.UNDER_SCORES},u={default:{joinSymbol:"",variableWrapperFn:a=>a,stringLiteral:a=>a,variableDeclaration:a=>a,urlFieldName:"url"},[i.CSHARP]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"fullUrl"},[i.CSHARPNEWTONSOFT]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"fullUrl"},[i.GO]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`${a} := %s;`},[i.JAVA]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`var ${a} = %s;`,urlFieldName:"pathname"},[i.JAVA8]:{joinSymbol:" + ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`String ${a} = %s;`,urlFieldName:"fullUrl"},[i.JAVASCRIPT]:{variableWrapperFn:a=>"${"+a+"}",variableDeclaration:(a,e)=>`const ${a} = ${e?.hasVariableInterpolation?"`%s`":"'%s'"};`},[i.NODEJS]:{variableWrapperFn:a=>"${"+a+"}",variableDeclaration:(a,e)=>`const ${a} = ${e?.hasVariableInterpolation?"`%s`":"'%s'"};`},[i.PHP]:{joinSymbol:" . ",stringLiteral:a=>`"${a}"`,variableDeclaration:a=>`const ${a} = %s;`},[i.PYTHON]:{stringLiteral:a=>`"${a}"`,joinSymbol:" + ",variableDeclaration:a=>`${a} = %s`},[i.RUBY]:{joinSymbol:" + ",stringLiteral:a=>`'${a}'`,variableDeclaration:a=>`${a} = %s`},[i.CURL]:{variableWrapperFn:(a,e)=>e||`{${a}}`,urlFieldName:"fullUrl",rawName:!0},[i.R]:{joinSymbol:" %&% ",variableDeclaration:a=>`${a} = %s`,urlFieldName:"fullUrl",stringLiteral:a=>`"${a}"`,variableWrapperFn:a=>`${a}`}},b=["response","request","requests","data","url","payload","main","accessToken","resp","Program","client","postData","App","httpClient","params","pathname","host","body","fetch","query"];class A{code;indentation;variablesPrefix;lineJoin;capitalize;lang;langOptions;constructor({indentation:e,lineJoin:t=`
|
|
2
2
|
`,variablesPrefix:r="",capitalize:n=!1,lang:s=i.CURL}){this.code=[],this.indentation=e,this.variablesPrefix=r,this.lineJoin=t||`
|
|
3
|
-
`,this.capitalize=n,this.lang=s,this.langOptions={...u.default,...u[s]}}buildLine(e,t){let r="",n=2;if(typeof e=="string")n=1,t=e,e=0;else if(e===null)return null;for(;e;)r+=this.indentation,e--;const s=Array.prototype.slice.call(arguments,n,arguments.length);return s.unshift(r+t),
|
|
3
|
+
`,this.capitalize=n,this.lang=s,this.langOptions={...u.default,...u[s]}}buildLine(e,t){let r="",n=2;if(typeof e=="string")n=1,t=e,e=0;else if(e===null)return null;for(;e;)r+=this.indentation,e--;const s=Array.prototype.slice.call(arguments,n,arguments.length);return s.unshift(r+t),p.format.apply(this,s)}unshift(...e){return this.code.unshift(this.buildLine.apply(this,e)),this}push(...e){return this.code.push(this.buildLine.apply(this,e)),this}blank(){return this.code.push(null),this}join(){return this.code.join(this.lineJoin)}clean(){this.code.splice(1)}var(e,t=c.CUSTOM){if(t===c.PATH){let r=this.variablesPrefix+e;switch(b.includes(r)&&(r=`${r}_path`),S[this.lang]){case l.UNDER_SCORES:r=o.toSnakeCase(r);break;case l.PASCAL_CASE:r=o.toPascalCase(r);break;case l.CAMEL_CASE:default:r=o.toCamelCase(r);break}return r}return this.variablesPrefix?this.variablesPrefix+(this.capitalize?o.toPascalCase(e):e):e}}export{A as CodeBuilder};
|
|
@@ -24,5 +24,5 @@ export type CodeOperand = {
|
|
|
24
24
|
* parseUrlIntoOperands("/url/:test/", {test: 1})
|
|
25
25
|
**/
|
|
26
26
|
export declare function parseUrlIntoOperands(url: string, params: Record<string, unknown>): CodeOperand[];
|
|
27
|
-
export declare function buildUrlExpression(source: SnippetRequest, code: CodeBuilder): string;
|
|
28
|
-
export declare function printUrlVariablesDeclarations(
|
|
27
|
+
export declare function buildUrlExpression(source: SnippetRequest, code: CodeBuilder, url?: string): string;
|
|
28
|
+
export declare function printUrlVariablesDeclarations(source: SnippetRequest, code: CodeBuilder, indentationLevel?: number): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{VariableType as
|
|
2
|
-
${e}`);return
|
|
1
|
+
import{VariableType as f}from"./constants.js";function x({body:r,authorizationHeader:a}){return function(n,s,e){return r&&s==="body"&&typeof n.body=="string"?n.body:a&&s==="Authorization"&&typeof n.Authorization=="string"?n.Authorization:e}}function d(r,{level:a=0,indent:n=" ",firstLine:s=!0}={}){const e=n.repeat(a),i=r.replace(/(\r\n|\n|\r)/gm,`
|
|
2
|
+
${e}`);return s?e.concat(i):i}function c(r,a){const s=Object.keys(a).map(t=>({name:t,idx:r.indexOf(`{${t}}`)})).filter(({idx:t})=>t>-1).sort((t,o)=>t.idx-o.idx),e=[];let i=0;for(const{name:t,idx:o}of s)o>i&&e.push({type:"string",value:r.substring(i,o)}),e.push({type:"variable",name:t}),i=o+t.length+2;return i<r.length&&e.push({type:"string",value:r.substring(i)}),e}function h(r,a,n){const{joinSymbol:s,variableWrapperFn:e,stringLiteral:i,urlFieldName:t,rawName:o}=a.langOptions,{pathParameters:b={},serverVariables:u={}}=r,p={...b,...u};return c(n??r[t]??"",p).map(l=>{if(l.type==="variable"){const m=p[l.name],v=o?l.name:a.var(l.name,f.PATH);return e(v,m)}else return i(l.value)}).join(s)}function y(r,a,n){const s={...r.pathParameters,...r.serverVariables};Object.entries(s).forEach(([e,i])=>{if(e==="server")return;const t=i||`YOUR_${e}_PARAMETER`,o=a.var(e,f.PATH),u=c(t,s).some(l=>l.type==="variable"),p=h(r,a,t);n!==void 0?a.push(n,a.langOptions.variableDeclaration(o,{hasVariableInterpolation:u}),p):a.push(a.langOptions.variableDeclaration(o,{hasVariableInterpolation:u}),p)})}export{d as addIndentation,h as buildUrlExpression,x as getPreserveTransformer,c as parseUrlIntoOperands,y as printUrlVariablesDeclarations};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{normalizeMimeType as
|
|
1
|
+
import{normalizeMimeType as b,unescapeServerVariables as p}from"../../utils.js";import{MediaTypes as s}from"../../../constants.js";import e from"./targets/index.js";import m from"./helpers/reducer.js";import{queryString as h}from"../../../utils/index.js";import{urlParse as j}from"../../../utils/url.js";class D{request;constructor(a){const r={...a};this.request=this.prepare({...r,httpVersion:r.httpVersion||"HTTP/1.1",queryString:r.queryString||[],headers:r.headers||[],cookies:r.cookies||[],postData:r.postData?{...r.postData,jsonObj:void 0,paramsObj:void 0}:void 0,bodySize:0,headersSize:0,queryObj:{},headersObj:{},cookiesObj:{},allHeaders:{},uriObj:{},fullUrl:"",pathParameters:r.pathParameters||{},serverVariables:r.serverVariables||{}})}prepare(a){if(a.queryString&&a.queryString.length&&(a.queryObj=a.queryString.reduce(m,{})),a.headers&&a.headers.length){const i=/^HTTP\/2/;a.headersObj=a.headers.reduce(function(t,c){let n=c.name;return a.httpVersion.match(i)&&(n=n.toLowerCase()),t[n]=c.value,t},{})}a.cookies&&a.cookies.length&&(a.cookiesObj=a.cookies.reduceRight(function(i,t){return i[t.name]=t.value,i},{}));const r=a.cookies.map(function(i){return encodeURIComponent(i.name)+"="+encodeURIComponent(i.value)});if(r.length&&(a.allHeaders.cookie=r.join("; ")),a.postData)switch(b(a.postData.mimeType)){case"multipart/mixed":case"multipart/related":case s.MULTIPART:case"multipart/alternative":break;case s.URL_ENCODED:a.postData?.params?(a.postData.paramsObj=a.postData.params.reduce(m,{}),a.postData.text=h.stringify(a.postData.paramsObj)):a.postData.text="";break;case"text/json":case"text/x-json":case s.JSON:case"application/x-json":if(a.postData.text)try{a.postData.jsonObj=JSON.parse(a.postData.text)}catch{a.postData.mimeType="text/plain"}break}if(a.allHeaders=Object.assign(a.allHeaders,a.headersObj),a.uriObj=j(a.url,!0),!a.uriObj)return{...a,uriObj:{protocol:"",path:"",queryObj:{},query:{}}};if(a.queryObj)for(const[i,t]of Object.entries(a.queryObj))a.uriObj.searchParams.has(i,t)||a.uriObj.searchParams.set(i,t);a.uriObj.query=Object.fromEntries(a.uriObj.searchParams.entries()),a.queryObj=a.uriObj.query,a.uriObj.path=a.uriObj.pathname=p(a.uriObj.pathname);const o=new URL(a.uriObj.toString());return o.search="",a.url=p(o.toString()),a.uriObj.search&&(a.uriObj.path=a.uriObj.pathname+"?"+a.uriObj.search),a.fullUrl=p(a.uriObj.toString()),a}convert(a,r,o){!o&&r&&(o=r);const i=this._matchTarget(a,r);if(i){const t=i(this.request,o,{target:a,client:r});return t.length===1?t[0]:t}throw new Error("Cannot match target")}_matchTarget(a,r){return Object.prototype.hasOwnProperty.call(e,a)?typeof r=="string"&&typeof e[a][r]=="function"?e[a][r]:e[a][e[a].info.default]:!1}}export{D as HTTPSnippet};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isObject as d}from"@redocly/theme";import{CodeBuilder as T}from"../../helpers/code-builder.js";import{HTTPSnippet as w}from"../../index.js";import{buildUrlExpression as S,printUrlVariablesDeclarations as E}from"../../helpers/code-helpers.js";import{isEmptyObject as A,normalizeMimeType as m}from"../../../../utils.js";import{capitalizeFirst as O}from"../../../generator.js";import{Lang as k}from"../../helpers/constants.js";import{MediaTypes as i}from"../../../../../constants.js";import{isLastInArray as H,isLastProperty as j}from"../../../../../utils/index.js";const x=function(s,c,{target:C,client:D}){const r=Object.assign({indent:" ",withWrapper:!0},c),t=new T({indentation:r.indent,variablesPrefix:r.variablesPrefix,capitalize:!0,lang:k.CSHARP}),b=L(s.method);if(r.withComments&&P(t),r.withWrapper&&(t.push("using System;"),t.push("using System.Net.Http;"),t.push("using System.Threading.Tasks;"),(h(i.JSON)||h(i.XML)||s.basicAuth)&&t.push("using System.Text;"),(h(i.URL_ENCODED)||s.securityOAuth2ExtraCalls?.length)&&t.push("using System.Collections.Generic;"),(h(i.JSON)||s.securityOAuth2ExtraCalls?.length)&&t.push("using System.Text.Json;"),l()&&t.push("using System.IO;"),(l()||s.basicAuth)&&t.push("using System.Net.Http.Headers;"),t.blank(),t.push("public class Program"),t.push("{"),t.push(1,"public static async Task Main()"),t.push(1,"{")),s.securityOAuth2ExtraCalls?.length){const e=new w(s.securityOAuth2ExtraCalls?.[0]).convert(C,D,{...r,withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"});t.push(e),t.push(2,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),t.push(2,"JObject inputJObject = JObject.Parse(oauth2Response);"),t.push(2,'var accessToken = inputJObject["access_token"].ToString();'),t.blank()}const f=Object.keys(s.allHeaders).filter(e=>{switch(e.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}});if(f.length?(t.push(2,"System.Net.Http.HttpClient client = new()"),t.push(2,"{"),t.push(3,"DefaultRequestHeaders ="),t.push(3,"{"),f.forEach(e=>{t.push(4,'{"%s", %s},',e,s.securityOAuth2ExtraCalls?.length?'"Bearer " + accessToken':`"${s.allHeaders[e]}"`)}),t.push(3,"}"),t.push(2,"};")):t.push(2,"System.Net.Http.HttpClient client = new();"),t.blank(),s.basicAuth){const{username:e,password:a}=s.basicAuth;t.push(2,`string base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("${e}:${a}"));`),t.push(2,'client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@"Basic", base64String);'),t.blank()}if(s.postData)switch(m(s.postData.mimeType)){case i.URL_ENCODED:s.postData.params&&(t.blank(),t.push(2,"List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();"),s.postData.params.forEach(e=>{t.push(2,'postData.Add(new KeyValuePair<string, string>("%s", "%s"));',e.name,e.value)}),t.blank());break;case i.MULTIPART:s.postData.params&&(t.blank(),t.push(2,"MultipartFormDataContent postData = new MultipartFormDataContent();"),s.postData.params.forEach(e=>{t.push(2,'postData.Add(new StringContent("%s"), "%s");',e.value,e.name)}));break;case i.JSON:s.postData.jsonObj&&(t.push(2,"string json = JsonSerializer.Serialize(new"),t.push(2,"{"),u(s.postData.jsonObj,3),t.push(2,"});"),t.blank(),t.push(2,'using StringContent postData = new(json, Encoding.UTF8, "%s");',s.postData.mimeType));break;case i.XML:s.postData.text&&(s.postData.text.trim().split(`
|
|
1
|
+
import{isObject as d}from"@redocly/theme/core/openapi";import{CodeBuilder as T}from"../../helpers/code-builder.js";import{HTTPSnippet as w}from"../../index.js";import{buildUrlExpression as S,printUrlVariablesDeclarations as E}from"../../helpers/code-helpers.js";import{isEmptyObject as A,normalizeMimeType as m}from"../../../../utils.js";import{capitalizeFirst as O}from"../../../generator.js";import{Lang as k}from"../../helpers/constants.js";import{MediaTypes as i}from"../../../../../constants.js";import{isLastInArray as H,isLastProperty as j}from"../../../../../utils/index.js";const x=function(s,c,{target:C,client:D}){const r=Object.assign({indent:" ",withWrapper:!0},c),t=new T({indentation:r.indent,variablesPrefix:r.variablesPrefix,capitalize:!0,lang:k.CSHARP}),b=L(s.method);if(r.withComments&&P(t),r.withWrapper&&(t.push("using System;"),t.push("using System.Net.Http;"),t.push("using System.Threading.Tasks;"),(h(i.JSON)||h(i.XML)||s.basicAuth)&&t.push("using System.Text;"),(h(i.URL_ENCODED)||s.securityOAuth2ExtraCalls?.length)&&t.push("using System.Collections.Generic;"),(h(i.JSON)||s.securityOAuth2ExtraCalls?.length)&&t.push("using System.Text.Json;"),l()&&t.push("using System.IO;"),(l()||s.basicAuth)&&t.push("using System.Net.Http.Headers;"),t.blank(),t.push("public class Program"),t.push("{"),t.push(1,"public static async Task Main()"),t.push(1,"{")),s.securityOAuth2ExtraCalls?.length){const e=new w(s.securityOAuth2ExtraCalls?.[0]).convert(C,D,{...r,withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"});t.push(e),t.push(2,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),t.push(2,"JObject inputJObject = JObject.Parse(oauth2Response);"),t.push(2,'var accessToken = inputJObject["access_token"].ToString();'),t.blank()}const f=Object.keys(s.allHeaders).filter(e=>{switch(e.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}});if(f.length?(t.push(2,"System.Net.Http.HttpClient client = new()"),t.push(2,"{"),t.push(3,"DefaultRequestHeaders ="),t.push(3,"{"),f.forEach(e=>{t.push(4,'{"%s", %s},',e,s.securityOAuth2ExtraCalls?.length?'"Bearer " + accessToken':`"${s.allHeaders[e]}"`)}),t.push(3,"}"),t.push(2,"};")):t.push(2,"System.Net.Http.HttpClient client = new();"),t.blank(),s.basicAuth){const{username:e,password:a}=s.basicAuth;t.push(2,`string base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("${e}:${a}"));`),t.push(2,'client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@"Basic", base64String);'),t.blank()}if(s.postData)switch(m(s.postData.mimeType)){case i.URL_ENCODED:s.postData.params&&(t.blank(),t.push(2,"List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();"),s.postData.params.forEach(e=>{t.push(2,'postData.Add(new KeyValuePair<string, string>("%s", "%s"));',e.name,e.value)}),t.blank());break;case i.MULTIPART:s.postData.params&&(t.blank(),t.push(2,"MultipartFormDataContent postData = new MultipartFormDataContent();"),s.postData.params.forEach(e=>{t.push(2,'postData.Add(new StringContent("%s"), "%s");',e.value,e.name)}));break;case i.JSON:s.postData.jsonObj&&(t.push(2,"string json = JsonSerializer.Serialize(new"),t.push(2,"{"),u(s.postData.jsonObj,3),t.push(2,"});"),t.blank(),t.push(2,'using StringContent postData = new(json, Encoding.UTF8, "%s");',s.postData.mimeType));break;case i.XML:s.postData.text&&(s.postData.text.trim().split(`
|
|
2
2
|
`).forEach((e,a)=>{const n=(a===0?'string xml = @"':"")+e.replace(/"/g,'""');t.push(a===0?2:3,n)}),t.push(2,'";'),t.push(2,'using StringContent postData = new StringContent(xml, Encoding.UTF8, "%s");',s.postData.mimeType));break}else l()&&(t.push(2,"var ms = new MemoryStream();"),t.push(2,"var postData = new StreamContent(ms);"),t.push(2,'postData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");'));return E(s,t,3),t.push(2,"using HttpResponseMessage %s = await client.%sAsync(%s%s);",t.var("request"),b,S(s,t),r.withImports?M(s.method)?m(s.postData&&s.postData.mimeType)===i.URL_ENCODED?", new FormUrlEncodedContent(postData)":s.method==="delete"?"":s.postData&&s.postData.params||l()?", postData":", null":"":", new FormUrlEncodedContent(postData)"),r.withWrapper&&(t.push(2,"string response = await request.Content.ReadAsStringAsync();"),t.blank(),t.push(2,"Console.WriteLine(response);"),t.push(1,"}"),t.push("}")),t.join();function h(e){return s.postData&&m(s.postData.mimeType)===e}function l(){return s.headersObj&&s.headersObj["Content-Type"]===i.OCTET_STREAM}function g(e,a){e.forEach((n,p)=>{const o=!H(e,p);Array.isArray(n)?g(n,a+1):d(n)?(t.push(a+1,"new {"),u(n,a+2),t.push(a+1,"}%s",o?",":"")):t.push(a+1,'"%s"%s',n,o?",":"")}),t.push(a,"},")}function u(e,a){for(const[n,p]of Object.entries(e)){const o=!j(e,n);if(Array.isArray(p))t.push(a,"%s = new[] {",n),g(p,a);else if(d(p)){const y=A(p);t.push(a,"%s = new %s",n,y?"{},":"{"),y||(u(p,a+1),t.push(a,"}%s",o?",":""))}else t.push(a,'%s = "%s"%s',n,p,o?",":"")}}},V={key:"httpclient",title:"HttpClient",link:"https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",description:".NET Standard HTTP Client"};var B=x;function P(s){s.push("// Requires >= .NET 5"),s.blank()}function L(s){return O(s.toLowerCase())}function M(s){return s&&["POST","PUT","DELETE","PATCH"].includes(s.toUpperCase())}export{B as default,V as info};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LayoutVariant as d
|
|
1
|
+
import{LayoutVariant as d}from"@redocly/config";import{isUndefined as m,addTrailingSlash as r}from"@redocly/theme/core/openapi";import{WindowReferenceOptions as i}from"../../constants.js";import{argValueToBoolean as o,argValueToExpandLevel as a,argValueToInt as p,argValueToNumber as c,getWindowReferenceOptions as t,normalizePath as h}from"../../utils/index.js";import{normalizeShowExtensions as u,normalizeScrollYOffset as f}from"./helpers.js";import{Languages as S}from"../code-samples/constants.js";function v(e,s){e={...s,...e,markdocOptions:{...e?.markdocOptions,components:{...s?.markdocOptions?.components,...e?.markdocOptions?.components},tags:{...s?.markdocOptions?.tags,...e?.markdocOptions?.tags},nodes:{...s?.markdocOptions?.nodes,...e?.markdocOptions?.nodes,heading:s?.markdocOptions?.nodes?.heading||e?.markdocOptions?.nodes.heading}}};const l=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:e.ignoreNamedSchemas?.split(",").map(n=>n.trim());return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&r(e.corsProxyUrl),hideSidebar:o(e.hideSidebar,!1),jsonSamplesExpandLevel:a(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:p(e.generatedSamplesMaxDepth,8),hideDownloadButtons:o(e.hideDownloadButtons,!1),hideInfoMetadata:o(e.hideInfoMetadata,!1),hideLoading:o(e.hideLoading,!1),hideSchemaTitles:o(e.hideSchemaTitles,!1),maxDisplayedEnumValues:c(e.maxDisplayedEnumValues),mockServer:e.mockServer?.url?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:o(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:o(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||t(i.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||t(i.REQUEST_INTERCEPTOR),routingBasePath:m(e.disableRouter)?"":e.routingBasePath&&h(e.routingBasePath)||"",schemasExpansionLevel:a(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:o(e.sortRequiredPropsFirst,!1),scrollYOffset:f(e.scrollYOffset),showExtensions:u(e.showExtensions),sanitize:o(e.sanitize,!1),skipBundle:o(e.skipBundle,!1),ignoreNamedSchemas:new Set(l),markdocOptions:e?.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(S).map(n=>({lang:n}))},layout:e.layout||d.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||t(i.HOOKS)||{},unstable_skipSamples:o(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:o(e?.hidePropertiesPrefix,!1)}}export{v as normalizeOptions};
|
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import type { ComponentType } from 'react';
|
|
2
|
-
import type { Schema, ConfigFunction } from '@markdoc/markdoc/dist/src/types';
|
|
3
1
|
import type { CodeSamplesConfig } from '../code-samples/index.js';
|
|
4
2
|
import type { HooksConfig, Unstable_ExternalCodeSample } from '../types.js';
|
|
5
3
|
import type { Events } from '../../events/index.js';
|
|
6
|
-
import type { LayoutVariant } from '@redocly/
|
|
4
|
+
import type { LayoutVariant } from '@redocly/config';
|
|
7
5
|
import type { OperationModel } from '../../models/types.js';
|
|
8
6
|
import type { DownloadUrlsConfig } from '../../components/Download/types.js';
|
|
7
|
+
import type { MarkdocOptions } from '../../components/Markdown/types.js';
|
|
9
8
|
export interface Options {
|
|
10
9
|
scrollYOffset: () => number;
|
|
11
10
|
hideLoading: boolean;
|
|
12
|
-
markdocOptions?:
|
|
13
|
-
tags: Record<string, Schema>;
|
|
14
|
-
nodes: Record<string, Schema>;
|
|
15
|
-
components: Record<string, ComponentType>;
|
|
16
|
-
variables?: Record<string, any>;
|
|
17
|
-
partials?: Record<string, any>;
|
|
18
|
-
functions?: Record<string, ConfigFunction>;
|
|
19
|
-
};
|
|
11
|
+
markdocOptions?: MarkdocOptions;
|
|
20
12
|
hideSidebar: boolean;
|
|
21
13
|
feedback: Record<string, any>;
|
|
22
14
|
unstable_hooks: HooksConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import y from"@markdoc/markdoc";import{isString as A}from"@redocly/theme";import{getTagOrGroup as S}from"../../models/index.js";import{safeSlugify as h,unescapeHTMLChars as T}from"../../utils/index.js";import{simplifyAstStructure as d}from"../../utils/simplifyAstStructure.js";function O(e,u,f){const i=A(e)?d(y.parse(e)):y.Ast.fromJSON(JSON.stringify(e?.result)),s=[];let o;const l=(t,n,g=s,r,p)=>{t=T(t);let a;r.attributes.id?a=r.attributes.id:(a=p?`${p}/${h(t)}`:`section/${h(t)}`,r.attributes.id=a);const b={id:a.toLowerCase(),name:t,level:n,items:[],ast:[r]};return g.push(b),b},c=(t,n)=>{t[t.length-1]?.ast?.push(n)},m=t=>{const n=C(t)||"",r=u&&u.type==="tag"?u.id:void 0;t.type==="heading"&&t.attributes.level===1?o=l(n,t.attributes.level,void 0,t,r):t.attributes.level?l(n,t.attributes.level,o?.items,t,o?.id??r):o?.items?.length?c(o?.items,t):s?.length&&c(s,t)};if(Array.isArray(i))for(const t of i)m(t);else m(i);return v(u,s,f)}function v(e,u,f=1){return u.map(i=>{const s=S("section",i,e);return s.depth=f,i.items&&(s.items=v(s,i.items,f+1)),s})}function C(e){if(typeof e?.attributes?.content=="string")return e.attributes?.content;if(e?.children)return C(e.children[0])}export{O as addMarkdownItems};
|
|
1
|
+
import y from"@markdoc/markdoc";import{isString as A}from"@redocly/theme/core/openapi";import{getTagOrGroup as S}from"../../models/index.js";import{safeSlugify as h,unescapeHTMLChars as T}from"../../utils/index.js";import{simplifyAstStructure as d}from"../../utils/simplifyAstStructure.js";function O(e,u,f){const i=A(e)?d(y.parse(e)):y.Ast.fromJSON(JSON.stringify(e?.result)),s=[];let o;const l=(t,n,g=s,r,p)=>{t=T(t);let a;r.attributes.id?a=r.attributes.id:(a=p?`${p}/${h(t)}`:`section/${h(t)}`,r.attributes.id=a);const b={id:a.toLowerCase(),name:t,level:n,items:[],ast:[r]};return g.push(b),b},c=(t,n)=>{t[t.length-1]?.ast?.push(n)},m=t=>{const n=C(t)||"",r=u&&u.type==="tag"?u.id:void 0;t.type==="heading"&&t.attributes.level===1?o=l(n,t.attributes.level,void 0,t,r):t.attributes.level?l(n,t.attributes.level,o?.items,t,o?.id??r):o?.items?.length?c(o?.items,t):s?.length&&c(s,t)};if(Array.isArray(i))for(const t of i)m(t);else m(i);return v(u,s,f)}function v(e,u,f=1){return u.map(i=>{const s=S("section",i,e);return s.depth=f,i.items&&(s.items=v(s,i.items,f+1)),s})}function C(e){if(typeof e?.attributes?.content=="string")return e.attributes?.content;if(e?.children)return C(e.children[0])}export{O as addMarkdownItems};
|
package/lib/services/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"deepmerge";import{isObject as i}from"@redocly/theme";import{isMergeableObject as u}from"../utils/index.js";function b(e,r){return!e||!r?!1:s(e)===s(r)}function s(e){if(!e)return;const r=e.split(";")[0].toLowerCase(),[t,n]=r.split("/");if(n===void 0)return t;const p=n.split("+").pop();return`${t}/${p}`}function m(e){const r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//").replace("./",".")}function a(e,r){if(!(e.length&&f(e)))return r;const t=e.filter(n=>Object.keys(n).length>0);return r.forEach(function(n,o){u(n)?t[o]=c(e[o],n,{arrayMerge:a}):Array.isArray(n)?t.push(n):t[o]=n}),t}const f=e=>e.some(r=>i(r)&&Object.keys(r).length>0);function w(e){return!!e&&Object.keys(e).length===0}const x=typeof window<"u"&&(window.crypto||window.msCrypto)||void 0;function l(e){if(typeof e!="object"||e===null)return e;const r=Array.isArray(e)?[]:{};for(const t in e){const n=e[t];r[t]=l(n)}return r}export{a as arrayMergeStrategy,x as cryptoLib,l as deepClone,w as isEmptyObject,b as isSameMime,s as normalizeMimeType,m as unescapeServerVariables};
|
|
1
|
+
import c from"deepmerge";import{isObject as i}from"@redocly/theme/core/openapi";import{isMergeableObject as u}from"../utils/index.js";function b(e,r){return!e||!r?!1:s(e)===s(r)}function s(e){if(!e)return;const r=e.split(";")[0].toLowerCase(),[t,n]=r.split("/");if(n===void 0)return t;const p=n.split("+").pop();return`${t}/${p}`}function m(e){const r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//").replace("./",".")}function a(e,r){if(!(e.length&&f(e)))return r;const t=e.filter(n=>Object.keys(n).length>0);return r.forEach(function(n,o){u(n)?t[o]=c(e[o],n,{arrayMerge:a}):Array.isArray(n)?t.push(n):t[o]=n}),t}const f=e=>e.some(r=>i(r)&&Object.keys(r).length>0);function w(e){return!!e&&Object.keys(e).length===0}const x=typeof window<"u"&&(window.crypto||window.msCrypto)||void 0;function l(e){if(typeof e!="object"||e===null)return e;const r=Array.isArray(e)?[]:{};for(const t in e){const n=e[t];r[t]=l(n)}return r}export{a as arrayMergeStrategy,x as cryptoLib,l as deepClone,w as isEmptyObject,b as isSameMime,s as normalizeMimeType,m as unescapeServerVariables};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -222,9 +222,10 @@ export interface OpenAPIEncoding {
|
|
|
222
222
|
export type OpenAPIParameterLocation = 'query' | 'header' | 'path' | 'cookie';
|
|
223
223
|
export type OpenAPIParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
|
|
224
224
|
export interface OpenAPIRequestBody extends ParsedDescription {
|
|
225
|
+
$ref?: string;
|
|
225
226
|
description?: string;
|
|
226
227
|
required?: boolean;
|
|
227
|
-
content
|
|
228
|
+
content?: {
|
|
228
229
|
[mime: string]: OpenAPIMediaType;
|
|
229
230
|
};
|
|
230
231
|
'x-examples'?: {
|
|
@@ -250,6 +251,7 @@ export interface OpenAPIResponse extends ParsedDescription {
|
|
|
250
251
|
links?: {
|
|
251
252
|
[name: string]: Referenced<OpenAPILink>;
|
|
252
253
|
};
|
|
254
|
+
$ref?: string;
|
|
253
255
|
'x-examples'?: {
|
|
254
256
|
[mime: string]: {
|
|
255
257
|
[name: string]: Referenced<OpenAPIExample>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OperationModel, SecurityCredentials, FieldModel } from '../models/types.js';
|
|
2
|
-
import type { ConfigureRequestValues, ConfigureServerRequestValues, SecurityDetails } from '@redocly/theme';
|
|
2
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues, SecurityDetails } from '@redocly/theme/ext/configure';
|
|
3
3
|
export declare function updateOperationWithRequestValues(operation: OperationModel, userDefinedRequestValues: ConfigureRequestValues | ConfigureServerRequestValues): void;
|
|
4
4
|
export declare function updateParametersWithUserValues(param: FieldModel, userDefinedRequestValues?: ConfigureRequestValues | ConfigureServerRequestValues): void;
|
|
5
5
|
export declare function updateRequestBodyWithUserValues(operation: OperationModel, userDefinedRequestValues: ConfigureRequestValues, serverUrl?: string): OperationModel | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as p}from"@redocly/theme";function v(e,t){Object.keys(t).length!==0&&(d(t)?(b(e,t),h(e,t.security),y(e,t.envVariables)):x(e,t))}function j(e,t){if(!t)return;const{in:r,name:s}=e;if(d(t)){const c=t,n={header:c.headers,query:c.query,path:c.path,cookie:c.cookie};r&&n[r]?.[s]&&(e.example=n[r][s])}else Object.entries(t).forEach(([c,n])=>{const f=n;if(!f)return;const o={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};r&&o[r]?.[s]&&(e.serverValues||(e.serverValues={}),e.serverValues[c]={example:o[r][s]})})}function b(e,t,r){if(!e.requestBody||!t?.body)return;const s=e.requestBody.content;if(!s?.mediaTypes)return;const c=(n,f)=>{n[f]&&Object.keys(n[f]).forEach(o=>{const i=n[f]?.[o]?.value;let a;if(p(i)?a=l(i,t.body):a=t.body,!!a)if(r){const u=n[f][o];u.serverValues||(u.serverValues={}),u.serverValues[r]={value:a,rawValue:a},n[f][o]={...u,mime:n.name}}else n[f][o]={value:a,rawValue:a,mime:n.name}})};for(const n of s.mediaTypes)c(n,"examples"),c(n,"formExamples");return e}function h(e,t,r){!t||!e.security.length||e.security.forEach(s=>{r?s.schemes.forEach(c=>{c.serverValues||(c.serverValues={});const n=k(c,t);c.serverValues[r]=n}):s.schemes.forEach(c=>{const n=k(c,t);Object.assign(c,n)})})}function x(e,t){e.servers.forEach(r=>{if(t[r.url]){const s=t[r.url];s&&(b(e,s,r.url),h(e,s.security,r.url),y(e,s.envVariables,r.url))}})}function y(e,t,r){!t||Object.keys(t).length===0||(e.envVariables||(e.envVariables={}),r?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[r]={...e.envVariables.serverValues[r],...t}):e.envVariables.values={...e.envVariables.values,...t})}function d(e){return!e||typeof e!="object"?!1:"headers"in e||"body"in e||"query"in e||"path"in e||"cookie"in e||"security"in e||"envVariables"in e}function l(e,t){if(!e||typeof e!="object")return t;if(Array.isArray(e)&&Array.isArray(t)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const s=Object.keys(e[0]),c=t.filter(n=>typeof n!="object"||n===null?!1:s.some(f=>f in n)&&Object.keys(n).every(f=>s.includes(f)));return c.length>0?c:e}return t}const r=Array.isArray(e)?[...e]:{...e};for(const[s,c]of Object.entries(t))s in e&&(Array.isArray(e[s])||typeof c=="object"&&c!==null&&typeof e[s]=="object"?r[s]=l(e[s],c):r[s]=c);return r}function k(e,t){const r={"x-defaultAccessToken":t.token?.access_token,"x-defaultTokenType":t.token?.token_type||"Bearer","x-defaultClientId":t.client_id,"x-defaultClientSecret":t.client_secret,scopes:t.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(r["x-defaultUsername"]=t.username,r["x-defaultPassword"]=t.password,delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]):e.type==="oauth2"&&!t.token?.access_token&&(delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]),r}export{k as createSecurityUpdates,d as isDirectRequestValues,y as updateEnvVariablesWithUserValues,l as updateObjectProperties,v as updateOperationWithRequestValues,x as updateOperationWithServerUserValues,j as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,h as updateSecurityWithUserValues};
|
|
1
|
+
import{isObject as p}from"@redocly/theme/core/openapi";function v(e,t){Object.keys(t).length!==0&&(d(t)?(b(e,t),h(e,t.security),y(e,t.envVariables)):x(e,t))}function j(e,t){if(!t)return;const{in:r,name:s}=e;if(d(t)){const c=t,n={header:c.headers,query:c.query,path:c.path,cookie:c.cookie};r&&n[r]?.[s]&&(e.example=n[r][s])}else Object.entries(t).forEach(([c,n])=>{const f=n;if(!f)return;const o={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};r&&o[r]?.[s]&&(e.serverValues||(e.serverValues={}),e.serverValues[c]={example:o[r][s]})})}function b(e,t,r){if(!e.requestBody||!t?.body)return;const s=e.requestBody.content;if(!s?.mediaTypes)return;const c=(n,f)=>{n[f]&&Object.keys(n[f]).forEach(o=>{const i=n[f]?.[o]?.value;let a;if(p(i)?a=l(i,t.body):a=t.body,!!a)if(r){const u=n[f][o];u.serverValues||(u.serverValues={}),u.serverValues[r]={value:a,rawValue:a},n[f][o]={...u,mime:n.name}}else n[f][o]={value:a,rawValue:a,mime:n.name}})};for(const n of s.mediaTypes)c(n,"examples"),c(n,"formExamples");return e}function h(e,t,r){!t||!e.security.length||e.security.forEach(s=>{r?s.schemes.forEach(c=>{c.serverValues||(c.serverValues={});const n=k(c,t);c.serverValues[r]=n}):s.schemes.forEach(c=>{const n=k(c,t);Object.assign(c,n)})})}function x(e,t){e.servers.forEach(r=>{if(t[r.url]){const s=t[r.url];s&&(b(e,s,r.url),h(e,s.security,r.url),y(e,s.envVariables,r.url))}})}function y(e,t,r){!t||Object.keys(t).length===0||(e.envVariables||(e.envVariables={}),r?(e.envVariables.serverValues||(e.envVariables.serverValues={}),e.envVariables.serverValues[r]={...e.envVariables.serverValues[r],...t}):e.envVariables.values={...e.envVariables.values,...t})}function d(e){return!e||typeof e!="object"?!1:"headers"in e||"body"in e||"query"in e||"path"in e||"cookie"in e||"security"in e||"envVariables"in e}function l(e,t){if(!e||typeof e!="object")return t;if(Array.isArray(e)&&Array.isArray(t)){if(e.length>0&&typeof e[0]=="object"&&e[0]!==null){const s=Object.keys(e[0]),c=t.filter(n=>typeof n!="object"||n===null?!1:s.some(f=>f in n)&&Object.keys(n).every(f=>s.includes(f)));return c.length>0?c:e}return t}const r=Array.isArray(e)?[...e]:{...e};for(const[s,c]of Object.entries(t))s in e&&(Array.isArray(e[s])||typeof c=="object"&&c!==null&&typeof e[s]=="object"?r[s]=l(e[s],c):r[s]=c);return r}function k(e,t){const r={"x-defaultAccessToken":t.token?.access_token,"x-defaultTokenType":t.token?.token_type||"Bearer","x-defaultClientId":t.client_id,"x-defaultClientSecret":t.client_secret,scopes:t.scopes||e.scopes};return e.type==="http"&&e.scheme==="basic"?(r["x-defaultUsername"]=t.username,r["x-defaultPassword"]=t.password,delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]):e.type==="oauth2"&&!t.token?.access_token&&(delete r["x-defaultAccessToken"],delete r["x-defaultTokenType"]),r}export{k as createSecurityUpdates,d as isDirectRequestValues,y as updateEnvVariablesWithUserValues,l as updateObjectProperties,v as updateOperationWithRequestValues,x as updateOperationWithServerUserValues,j as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,h as updateSecurityWithUserValues};
|
package/lib/utils/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isObject as i,isString as a,IS_BROWSER as u}from"@redocly/theme/core/openapi";import{isNamedDefinition as f}from"./openapi.js";import{JsonPointer as l}from"./JsonPointer.js";import{urlParse as c}from"./url.js";function w(r,e){const t=[];for(let n=0;n<r.length-1;n++)t.push(e(r[n],!1));return r.length!==0&&t.push(e(r[r.length-1],!0)),t}function O(r,e){const t={};for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=e(r[n],n,r));return t}function y(r,e){const t=[],n=o=>{for(const s of o)t.push(s),s[e]&&n(s[e])};return n(r),t}function p(r){return r.endsWith("/")?r.substring(0,r.length-1):r}function A(r){return!isNaN(parseFloat(r))&&isFinite(r)}function b(r,e,t){const n=new RegExp(`(^|\\n)#\\s?${e}\\s*\\n`,"i"),o=new RegExp(`((\\n|^)#\\s*${e}\\s*(\\n|$)(?:.|\\n)*?)(\\n#|$)`,"i");if(n.test(r))return r.replace(o,`$1
|
|
2
2
|
|
|
3
3
|
${t}
|
|
4
4
|
$4`);{const s=r===""||r.endsWith(`
|
|
@@ -9,4 +9,4 @@ $4`);{const s=r===""||r.endsWith(`
|
|
|
9
9
|
|
|
10
10
|
`;return`${r}${s}# ${e}
|
|
11
11
|
|
|
12
|
-
${t}`}}const E=r=>Array.isArray(r)&&r.some(e=>
|
|
12
|
+
${t}`}}const E=r=>Array.isArray(r)&&r.some(e=>i(e)),R=r=>r.filter(e=>!!e),W=r=>i(r)&&!Array.isArray(r);function d(r){return/(?:^[a-z][a-z0-9+.-]*:|\/\/)/i.test(r)}function C(r,e){let t;if(e.startsWith("//"))t=`${c(r,!0)?.protocol||"https:"}${e}`;else if(d(e))t=e;else if(!e.startsWith("/"))t=p(r)+"/"+e;else{const n=c(r);n?(n.pathname=e,t=n.toString()):t=e}return p(t)}function I(r){return r.charAt(0).toUpperCase()+r.slice(1)}function L(r){try{if(!r)return"";const e=new URL(r);return e.search="",e.hash="",e.toString()}catch{return r}}function M(r){return r.replace(/["\\]/g,"\\$&")}function N(r){return r.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,10))).replace(/&/g,"&").replace(/"/g,'"')}function P(r){return r&&r.replace(/#/g,"_").toLowerCase()}function T(r,e){return e||f(r)&&l.baseName(r)||""}function j(r={},e,t){return typeof e=="string"&&(e=e.split(".")),e.reduce((n,o)=>n&&n[o]?n[o]:t,r)}function x(r){return(...e)=>e.filter(Boolean).join(r)}const z=x(".");function D(r){return u?window?.REFERENCE_DOCS_OPTIONS?.[r]:null}function F(){if(!u)return"";const r=+new Date+Math.random();try{return(!document.currentScript||!(document.currentScript.async||document.currentScript.defer))&&document.write(`<script id="dummy${r}"></script>`),(document.getElementById("dummy"+r)?.previousSibling).src}catch{return""}}const _=r=>a(r)?r:r?.raw,B=(r,e)=>{const t=r?.[`x-parsed-md-${e}`]||r?.[e];if(!t)return;if(!r?.[`x-parsed-md-${e}`]&&e!=="x-enumDescriptions")return r?.[e];if(e!=="x-enumDescriptions")return g(r,e);let n={};for(const o in t)o.startsWith("x-parsed-md")||(n[o]=t?.[`x-parsed-md-${o}`]||t?.[o]);return Object.keys(n).length?n:t};function g(r,e){const t=r?.[`x-parsed-md-${e}`]||r?.[e];return t?.raw?t:{result:t?.result||r?.[e]?.result||r?.[e],raw:r?.[e]}}function H(r,e){return e===r.length-1}function U(r,e){const t=Object.keys(r);return t.indexOf(e)===t.length-1}export{b as appendToMdHeading,R as deleteEmptyArrayItem,z as dottedString,M as escapeHTMLAttrChars,y as flattenByProp,j as get,F as getJsUrl,B as getValueFromMdParsedExtension,D as getWindowReferenceOptions,d as isAbsoluteUrl,E as isArrayOfObjects,H as isLastInArray,U as isLastProperty,W as isMergeableObject,A as isNumeric,x as joinStringFactory,O as mapValues,w as mapWithLast,_ as normalizeText,L as removeQueryStringAndHash,C as resolveUrl,P as sanitizeItemId,p as stripTrailingSlash,I as titleize,N as unescapeHTMLChars,T as useSchemaTitle};
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./JsonPointer.js";export*from"./openapi.js";export*from"./helpers.js";export*from"./dom.js";export*from"./debug.js";export*from"./sort.js";export*from"./argValuesHelpers.js";export*from"./theme-helpers.js";export*from"./debounce.js";export*from"./security-details.js";export*from"./session-storage.js";export*from"./local-storage.js";export*from"./parameters.js";export*from"./string.js";export*from"./test-utils.js";export*from"./compose.js";export*from"./saveTextBeforeHeading.js";export*from"./path.js";export*from"./queryString.js";export*from"./isMobile.js";export*from"./replaceVariables.js";export*from"./areArraysEqual.js";export*from"./configure-helpers.js";
|
|
1
|
+
export*from"./JsonPointer.js";export*from"./openapi.js";export*from"./helpers.js";export*from"./dom.js";export*from"./debug.js";export*from"./sort.js";export*from"./argValuesHelpers.js";export*from"./theme-helpers.js";export*from"./debounce.js";export*from"./security-details.js";export*from"./session-storage.js";export*from"./local-storage.js";export*from"./parameters.js";export*from"./string.js";export*from"./test-utils.js";export*from"./compose.js";export*from"./saveTextBeforeHeading.js";export*from"./path.js";export*from"./queryString.js";export*from"./isMobile.js";export*from"./replaceVariables.js";export*from"./areArraysEqual.js";export*from"./configure-helpers.js";export*from"./telemetry.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bundle as s,Config as
|
|
1
|
+
import{bundle as s,Config as r}from"@redocly/openapi-core";import{IS_BROWSER as i}from"@redocly/theme/core/openapi";import{convertSwagger2OpenAPI as f}from"./convertSwagger2OpenAPI.js";async function l(o){const t=new r({}),e={config:t,base:i?window.location.origin:typeof globalThis.process<"u"?globalThis.process.cwd():""};i&&(t.resolve.http.customFetch=globalThis.fetch),typeof o=="object"&&o!==null?e.doc=a(o):e.ref=o;const{bundle:{parsed:n}}=await s(e);return n.swagger!==void 0?f(n):n}function a(o){return{source:{absoluteRef:""},parsed:o}}export{l as loadAndBundleDefinition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as t}from"@redocly/theme";function a(o,r){t&&window.localStorage.setItem("redoc."+o,r)}function c(o){return t&&window.localStorage.getItem("redoc."+o)||""}export{c as fromLocalStorage,a as toLocalStorage};
|
|
1
|
+
import{IS_BROWSER as t}from"@redocly/theme/core/openapi";function a(o,r){t&&window.localStorage.setItem("redoc."+o,r)}function c(o){return t&&window.localStorage.getItem("redoc."+o)||""}export{c as fromLocalStorage,a as toLocalStorage};
|
package/lib/utils/openapi.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname as y}from"path";import f from"url-template";import{IS_BROWSER as M}from"@redocly/theme";import{deleteEmptyArrayItem as E,isArrayOfObjects as T,isNumeric as S,removeQueryStringAndHash as z,resolveUrl as D,sanitizeItemId as m,normalizeText as b,getValueFromMdParsedExtension as g,isAbsoluteUrl as N}from"./helpers.js";import{DEFAULT_TAG_SLUG as R,MediaTypes as j}from"../constants.js";import{JsonPointer as $}from"./JsonPointer.js";import{joinWithSeparator as _}from"../services/index.js";import{tryDecodeURIComponent as F}from"./string.js";import{getUrlDirname as U}from"./url.js";function P(e){return typeof e=="string"&&/\dxx/i.test(e)}function ne(e){return e==="default"||S(e)||P(e)}function ie(e,r=!1){if(e==="default")return r?"error":"success";let t=typeof e=="string"?parseInt(e,10):e;if(P(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let n="success";return t>=300&&t<400?n="redirect":t>=400?n="error":t<200&&(n="info"),n}const L={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};function oe(e){return e in L}function ue(e){const{operationId:r,pathName:t}=e,n=b(g(e,"description"));return b(g(e,"summary"))||r||n&&n.substring(0,50)||t||"<no summary>"}function se(e,r){return r?.id?_(r.id,m(e.operationId?e.operationId:d(e.pointer))).toLowerCase():e.tags?.length?m(e.operationId?e.operationId:d(e.pointer)):m(e.operationId?_(R,e.operationId):d(e.pointer))}function d(e){return e?.startsWith("/")?e.slice(1,e.length):e}const h={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"};function ae(e){if(e.type!==void 0&&!Array.isArray(e.type))return e.type;const r=Object.keys(h);for(const t of r){const n=h[t];if(e[t]!==void 0)return n}return"any"}function k(e,r=e.type){if(e["x-circular-ref"]||e["x-complex"])return!0;if(e.oneOf!==void 0||e.anyOf!==void 0||e.if&&e.then||e.if&&e.else)return!1;let t=!0;const n=Array.isArray(r);return(r==="object"||n&&r?.includes("object"))&&(t=e.properties!==void 0?Object.keys(e.properties).length===0:e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&e.patternProperties===void 0),Array.isArray(e.items)||Array.isArray(e.prefixItems)?!1:(e.items!==void 0&&typeof e.items!="boolean"&&(r==="array"||n&&r?.includes("array"))&&(t=k(e.items,e.items.type)),t)}function q(e){return e.search(/json/i)!==-1}function ce(e){return e?.search(/xml/i)!==-1}function pe(e){return e===j.URL_ENCODED}function fe(e){return e===j.MULTIPART}function c(e,r,t){return Array.isArray(e)?e.map(n=>n.toString()).join(t):typeof e=="object"?Object.keys(e).map(n=>`${n}${t}${e[n]}`).join(t):r+"="+e.toString()}function w(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):typeof e=="object"?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 a(e,r,t){const n="__redoc_param_name__",i=r?"*":"";return f.parse(`{?${n}${i}}`).expand({[n]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function O(e,r){const t=e?"*":"",n="__redoc_param_name__",i=f.parse(`{${n}${t}}`);return F(i.expand({[n]:r}))}function me(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map(t=>{const n=e[t],{style:i="form",explode:o=!0}=r[t]||{};switch(i){case"form":return a(t,o,n);case"spaceDelimited":return c(n,t,"%20");case"pipeDelimited":return c(n,t,"|");case"deepObject":return w(n,t);default:return console.warn("Incorrect or unsupported encoding style: "+i),""}}).join("&")}function W(e,r,t,n){const i=t?"*":"";let o="";r==="label"?o=".":r==="matrix"&&(o=";");const s="__redoc_param_name__";return f.parse(`{${o}${s}${i}}`).expand({[s]:n}).replace(/__redoc_param_name__/g,e)}function H(e,r,t,n){const i=o=>{switch(r){case"form":return a(e,t,o);case"spaceDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style spaceDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"%20");case"pipeDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style pipeDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"|");case"deepObject":return!t||Array.isArray(o)||typeof o!="object"?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):w(o,e);case"simple":return O(t,n);default:return console.warn("Unexpected style for query: "+r),""}};return T(n)&&(n=E(n).map(o=>i(o))),i(n)}function C(e,r,t){switch(e){case"simple":return O(r,t);default:return console.warn("Unexpected style for header: "+e),""}}function B(e,r,t,n){switch(r){case"form":return a(e,t,n);default:return console.warn("Unexpected style for cookie: "+r),""}}function A(e,r){return q(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}function de(e,r){const{name:t,style:n,explode:i=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return A(r,o);case"cookie":case"query":return`${t}=${A(r,o)}`;default:return console.warn("Unexpected parameter location: "+e.in),""}if(!n)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return W(t,n,i,r);case"query":return H(t,n,i,r);case"header":return C(n,i,r);case"cookie":return B(t,n,i,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function le(e){return e.search(/xml/i)!==-1?"xml":"clike"}const I=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function xe(e){return I.test(e||"")}function ye(e){return e?.match(I)?.pop()}function G(e){if(e===void 0)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function l(e,r,t){let n;return r!==void 0&&t!==void 0?r===t?n=`= ${r} ${e}`:n=`[ ${r} .. ${t} ] ${e}`:t!==void 0?n=`<= ${t} ${e}`:r!==void 0&&(r===1?n="non-empty":n=`>= ${r} ${e}`),n}function J(e){const r=typeof e.exclusiveMinimum=="number"?Math.min(e.exclusiveMinimum,e.minimum??1/0):e.minimum,t=typeof e.exclusiveMaximum=="number"?Math.max(e.exclusiveMaximum,e.maximum??-1/0):e.maximum,n=typeof e.exclusiveMinimum=="number"||e.exclusiveMinimum,i=typeof e.exclusiveMaximum=="number"||e.exclusiveMaximum;if(r!==void 0&&t!==void 0)return`${n?"( ":"[ "}${r} .. ${t}${i?" )":" ]"}`;if(t!==void 0)return`${i?"< ":"<= "}${t}`;if(r!==void 0)return`${n?"> ":">= "}${r}`}function be(e){const r=[],t=l("characters",e.minLength,e.maxLength);t!==void 0&&r.push(t);const n=l("items",e.minItems,e.maxItems);n!==void 0&&r.push(n);const i=l(e.minProperties===1&&e.maxProperties===1?"property":"properties",e.minProperties,e.maxProperties);i!==void 0&&r.push(i);const o=G(e.multipleOf);o!==void 0&&r.push(o);const s=J(e);return s!==void 0&&r.push(s),e.uniqueItems&&r.push("unique"),r}function ge(e,r=[]){const t=[],n=[],i=[];return e.forEach(o=>{o.required?r.includes(o.name)?n.push(o):i.push(o):t.push(o)}),n.sort((o,s)=>r.indexOf(o.name)-r.indexOf(s.name)),[...n,...i,...t]}function je(e){return e.sort((r,t)=>Number(r.deprecated)-Number(t.deprecated))}function $e(e,r=[],t=[],{pathPointer:n,operationPointer:i}){const o={};t.forEach(u=>{({resolved:u}=e.deref(u)),o[u.name+"_"+u.in]=!0});const s=r.map((u,p)=>({paramOrRef:u,pointer:$.join(n,["parameters",String(p)])})).filter(({paramOrRef:u})=>({resolved:u}=e.deref(u),!o[u.name+"_"+u.in])),x=t.map((u,p)=>({paramOrRef:u,pointer:$.join(i,["parameters",String(p)])}));return[...s,...x]}function _e(e,r){const n=e===void 0?z((()=>{if(!M)return globalThis.SSR_HOSTNAME||"";const i=window.location.href;return i.endsWith(".html")?y(i):i})()):N(e)?U(e):y(e);return r.length===0&&(r=[{url:"/"}]),r.map(i=>({...i,url:n?D(n,i.url):i.url,description:i.description||""}))}const Pe=e=>({delete:"del",options:"opts"})[e]||e;function Q(e){return e in{"x-circular-ref":!0,"x-complex":!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-feedback":!0,"x-badges":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}function he(e,r){return Object.keys(e).filter(t=>r===!0?t.startsWith("x-")&&!Q(t):t.startsWith("x-")&&r.indexOf(t)>-1).reduce((t,n)=>(t[n]=e[n],t),{})}function we(e){return e.split(" or ").map(r=>r.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")).join(" or ")}function Oe(e){let r=e.content;const t=e["x-examples"],n=e["x-example"];if(t){r={...r};for(const i of Object.keys(t)){const o=t[i];r[i]={...r[i],examples:o}}}else if(n){r={...r};for(const i of Object.keys(n)){const o=n[i];r[i]={...r[i],example:o}}}return r}export{ae as detectType,he as extractExtensions,Oe as getContentWithLegacyExamples,ye as getDefinitionName,se as getOperationId,ue as getOperationName,ie as getStatusCodeType,be as humanizeConstraints,J as humanizeNumberRange,pe as isFormUrlEncoded,q as isJsonLike,fe as isMultipartFormData,xe as isNamedDefinition,oe as isOperationName,k as isPrimitiveType,Q as isRedocExtension,ne as isStatusCode,ce as isXmlLike,le as langFromMime,$e as mergeParams,_e as normalizeServers,we as pluralizeType,de as serializeParameterValue,A as serializeParameterValueWithMime,H as serializeQueryParameter,Pe as shortenHTTPVerb,je as sortByDeprecated,ge as sortByRequired,me as urlFormEncodePayload};
|
|
1
|
+
import{dirname as y}from"path";import f from"url-template";import{IS_BROWSER as M}from"@redocly/theme/core/openapi";import{deleteEmptyArrayItem as E,isArrayOfObjects as T,isNumeric as S,removeQueryStringAndHash as z,resolveUrl as D,sanitizeItemId as m,normalizeText as b,getValueFromMdParsedExtension as g,isAbsoluteUrl as N}from"./helpers.js";import{DEFAULT_TAG_SLUG as R,MediaTypes as j}from"../constants.js";import{JsonPointer as $}from"./JsonPointer.js";import{joinWithSeparator as _}from"../services/index.js";import{tryDecodeURIComponent as F}from"./string.js";import{getUrlDirname as U}from"./url.js";function P(e){return typeof e=="string"&&/\dxx/i.test(e)}function ne(e){return e==="default"||S(e)||P(e)}function ie(e,r=!1){if(e==="default")return r?"error":"success";let t=typeof e=="string"?parseInt(e,10):e;if(P(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let n="success";return t>=300&&t<400?n="redirect":t>=400?n="error":t<200&&(n="info"),n}const L={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};function oe(e){return e in L}function ue(e){const{operationId:r,pathName:t}=e,n=b(g(e,"description"));return b(g(e,"summary"))||r||n&&n.substring(0,50)||t||"<no summary>"}function se(e,r){return r?.id?_(r.id,m(e.operationId?e.operationId:d(e.pointer))).toLowerCase():e.tags?.length?m(e.operationId?e.operationId:d(e.pointer)):m(e.operationId?_(R,e.operationId):d(e.pointer))}function d(e){return e?.startsWith("/")?e.slice(1,e.length):e}const h={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"};function ae(e){if(e.type!==void 0&&!Array.isArray(e.type))return e.type;const r=Object.keys(h);for(const t of r){const n=h[t];if(e[t]!==void 0)return n}return"any"}function k(e,r=e.type){if(e["x-circular-ref"]||e["x-complex"])return!0;if(e.oneOf!==void 0||e.anyOf!==void 0||e.if&&e.then||e.if&&e.else)return!1;let t=!0;const n=Array.isArray(r);return(r==="object"||n&&r?.includes("object"))&&(t=e.properties!==void 0?Object.keys(e.properties).length===0:e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&e.patternProperties===void 0),Array.isArray(e.items)||Array.isArray(e.prefixItems)?!1:(e.items!==void 0&&typeof e.items!="boolean"&&(r==="array"||n&&r?.includes("array"))&&(t=k(e.items,e.items.type)),t)}function q(e){return e.search(/json/i)!==-1}function ce(e){return e?.search(/xml/i)!==-1}function pe(e){return e===j.URL_ENCODED}function fe(e){return e===j.MULTIPART}function c(e,r,t){return Array.isArray(e)?e.map(n=>n.toString()).join(t):typeof e=="object"?Object.keys(e).map(n=>`${n}${t}${e[n]}`).join(t):r+"="+e.toString()}function w(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):typeof e=="object"?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 a(e,r,t){const n="__redoc_param_name__",i=r?"*":"";return f.parse(`{?${n}${i}}`).expand({[n]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function O(e,r){const t=e?"*":"",n="__redoc_param_name__",i=f.parse(`{${n}${t}}`);return F(i.expand({[n]:r}))}function me(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map(t=>{const n=e[t],{style:i="form",explode:o=!0}=r[t]||{};switch(i){case"form":return a(t,o,n);case"spaceDelimited":return c(n,t,"%20");case"pipeDelimited":return c(n,t,"|");case"deepObject":return w(n,t);default:return console.warn("Incorrect or unsupported encoding style: "+i),""}}).join("&")}function W(e,r,t,n){const i=t?"*":"";let o="";r==="label"?o=".":r==="matrix"&&(o=";");const s="__redoc_param_name__";return f.parse(`{${o}${s}${i}}`).expand({[s]:n}).replace(/__redoc_param_name__/g,e)}function H(e,r,t,n){const i=o=>{switch(r){case"form":return a(e,t,o);case"spaceDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style spaceDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"%20");case"pipeDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style pipeDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"|");case"deepObject":return!t||Array.isArray(o)||typeof o!="object"?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):w(o,e);case"simple":return O(t,n);default:return console.warn("Unexpected style for query: "+r),""}};return T(n)&&(n=E(n).map(o=>i(o))),i(n)}function C(e,r,t){switch(e){case"simple":return O(r,t);default:return console.warn("Unexpected style for header: "+e),""}}function B(e,r,t,n){switch(r){case"form":return a(e,t,n);default:return console.warn("Unexpected style for cookie: "+r),""}}function A(e,r){return q(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}function de(e,r){const{name:t,style:n,explode:i=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return A(r,o);case"cookie":case"query":return`${t}=${A(r,o)}`;default:return console.warn("Unexpected parameter location: "+e.in),""}if(!n)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return W(t,n,i,r);case"query":return H(t,n,i,r);case"header":return C(n,i,r);case"cookie":return B(t,n,i,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function le(e){return e.search(/xml/i)!==-1?"xml":"clike"}const I=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function xe(e){return I.test(e||"")}function ye(e){return e?.match(I)?.pop()}function G(e){if(e===void 0)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function l(e,r,t){let n;return r!==void 0&&t!==void 0?r===t?n=`= ${r} ${e}`:n=`[ ${r} .. ${t} ] ${e}`:t!==void 0?n=`<= ${t} ${e}`:r!==void 0&&(r===1?n="non-empty":n=`>= ${r} ${e}`),n}function J(e){const r=typeof e.exclusiveMinimum=="number"?Math.min(e.exclusiveMinimum,e.minimum??1/0):e.minimum,t=typeof e.exclusiveMaximum=="number"?Math.max(e.exclusiveMaximum,e.maximum??-1/0):e.maximum,n=typeof e.exclusiveMinimum=="number"||e.exclusiveMinimum,i=typeof e.exclusiveMaximum=="number"||e.exclusiveMaximum;if(r!==void 0&&t!==void 0)return`${n?"( ":"[ "}${r} .. ${t}${i?" )":" ]"}`;if(t!==void 0)return`${i?"< ":"<= "}${t}`;if(r!==void 0)return`${n?"> ":">= "}${r}`}function be(e){const r=[],t=l("characters",e.minLength,e.maxLength);t!==void 0&&r.push(t);const n=l("items",e.minItems,e.maxItems);n!==void 0&&r.push(n);const i=l(e.minProperties===1&&e.maxProperties===1?"property":"properties",e.minProperties,e.maxProperties);i!==void 0&&r.push(i);const o=G(e.multipleOf);o!==void 0&&r.push(o);const s=J(e);return s!==void 0&&r.push(s),e.uniqueItems&&r.push("unique"),r}function ge(e,r=[]){const t=[],n=[],i=[];return e.forEach(o=>{o.required?r.includes(o.name)?n.push(o):i.push(o):t.push(o)}),n.sort((o,s)=>r.indexOf(o.name)-r.indexOf(s.name)),[...n,...i,...t]}function je(e){return e.sort((r,t)=>Number(r.deprecated)-Number(t.deprecated))}function $e(e,r=[],t=[],{pathPointer:n,operationPointer:i}){const o={};t.forEach(u=>{({resolved:u}=e.deref(u)),o[u.name+"_"+u.in]=!0});const s=r.map((u,p)=>({paramOrRef:u,pointer:$.join(n,["parameters",String(p)])})).filter(({paramOrRef:u})=>({resolved:u}=e.deref(u),!o[u.name+"_"+u.in])),x=t.map((u,p)=>({paramOrRef:u,pointer:$.join(i,["parameters",String(p)])}));return[...s,...x]}function _e(e,r){const n=e===void 0?z((()=>{if(!M)return globalThis.SSR_HOSTNAME||"";const i=window.location.href;return i.endsWith(".html")?y(i):i})()):N(e)?U(e):y(e);return r.length===0&&(r=[{url:"/"}]),r.map(i=>({...i,url:n?D(n,i.url):i.url,description:i.description||""}))}const Pe=e=>({delete:"del",options:"opts"})[e]||e;function Q(e){return e in{"x-circular-ref":!0,"x-complex":!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-feedback":!0,"x-badges":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}function he(e,r){return Object.keys(e).filter(t=>r===!0?t.startsWith("x-")&&!Q(t):t.startsWith("x-")&&r.indexOf(t)>-1).reduce((t,n)=>(t[n]=e[n],t),{})}function we(e){return e.split(" or ").map(r=>r.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")).join(" or ")}function Oe(e){let r=e.content;const t=e["x-examples"],n=e["x-example"];if(t){r={...r};for(const i of Object.keys(t)){const o=t[i];r[i]={...r[i],examples:o}}}else if(n){r={...r};for(const i of Object.keys(n)){const o=n[i];r[i]={...r[i],example:o}}}return r}export{ae as detectType,he as extractExtensions,Oe as getContentWithLegacyExamples,ye as getDefinitionName,se as getOperationId,ue as getOperationName,ie as getStatusCodeType,be as humanizeConstraints,J as humanizeNumberRange,pe as isFormUrlEncoded,q as isJsonLike,fe as isMultipartFormData,xe as isNamedDefinition,oe as isOperationName,k as isPrimitiveType,Q as isRedocExtension,ne as isStatusCode,ce as isXmlLike,le as langFromMime,$e as mergeParams,_e as normalizeServers,we as pluralizeType,de as serializeParameterValue,A as serializeParameterValueWithMime,H as serializeQueryParameter,Pe as shortenHTTPVerb,je as sortByDeprecated,ge as sortByRequired,me as urlFormEncodePayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"@markdoc/markdoc";import{isString as d}from"@redocly/theme";function u(r){if(!r)return"";if(!d(r))return r?.result?{result:g(f.Ast.fromJSON(JSON.stringify(r.result)))||"",raw:u(r.raw)}:r;const n=new RegExp("^#{1,6}?\\s+","m"),e=r.search(n);return e>-1?r.substring(0,e):r}function g(r){if(Array.isArray(r)){const e=r.findIndex(i=>i.type==="heading");return e===-1?r:r.slice(0,e)}if(!r.children||!Array.isArray(r.children))return;const n=r.children.findIndex(e=>e.type==="heading");return n===-1||(r.children=r.children.slice(0,n)),r}export{u as saveTextBeforeHeading};
|
|
1
|
+
import f from"@markdoc/markdoc";import{isString as d}from"@redocly/theme/core/openapi";function u(r){if(!r)return"";if(!d(r))return r?.result?{result:g(f.Ast.fromJSON(JSON.stringify(r.result)))||"",raw:u(r.raw)}:r;const n=new RegExp("^#{1,6}?\\s+","m"),e=r.search(n);return e>-1?r.substring(0,e):r}function g(r){if(Array.isArray(r)){const e=r.findIndex(i=>i.type==="heading");return e===-1?r:r.slice(0,e)}if(!r.children||!Array.isArray(r.children))return;const n=r.children.findIndex(e=>e.type==="heading");return n===-1||(r.children=r.children.slice(0,n)),r}export{u as saveTextBeforeHeading};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SecurityVariablesEnvSuffix as o}from"@redocly/theme";import{escapeFormId as c}from"./string.js";import{fromSessionStorage as e,toSessionStorage as r}from"./session-storage.js";function p(t,s){t=c(t),r(`auth.${t}.variants`,JSON.stringify(s))}function S(t,s={}){return{raw:s[t+o.APIKey],password:s[t+o.Password],username:s[t+o.Username],token:s[t+o.Token]?{access_token:s[t+o.Token]}:void 0,client_id:s[t+o.ClientId],client_secret:s[t+o.ClientSecret],scopes:e(`auth.${t}.scopes`)}}function h(t,s){t=c(t),typeof s=="string"?r("auth."+t,s):s&&(r(`auth.${t}.password`,s.password||""),r(`auth.${t}.username`,s.username||""),r(`auth.${t}.token`,s.token&&JSON.stringify(s.token)||""),r(`auth.${t}.client_id`,s.client_id||""),r(`auth.${t}.client_secret`,s.client_secret||""),r(`auth.${t}.scopes`,s.scopes&&JSON.stringify(s.scopes)||""))}export{S as getSecurityDetails,h as setSecurityDetails,p as setSecurityDetailsVariants};
|
|
1
|
+
import{SecurityVariablesEnvSuffix as o}from"@redocly/theme/core/openapi";import{escapeFormId as c}from"./string.js";import{fromSessionStorage as e,toSessionStorage as r}from"./session-storage.js";function p(t,s){t=c(t),r(`auth.${t}.variants`,JSON.stringify(s))}function S(t,s={}){return{raw:s[t+o.APIKey],password:s[t+o.Password],username:s[t+o.Username],token:s[t+o.Token]?{access_token:s[t+o.Token]}:void 0,client_id:s[t+o.ClientId],client_secret:s[t+o.ClientSecret],scopes:e(`auth.${t}.scopes`)}}function h(t,s){t=c(t),typeof s=="string"?r("auth."+t,s):s&&(r(`auth.${t}.password`,s.password||""),r(`auth.${t}.username`,s.username||""),r(`auth.${t}.token`,s.token&&JSON.stringify(s.token)||""),r(`auth.${t}.client_id`,s.client_id||""),r(`auth.${t}.client_secret`,s.client_secret||""),r(`auth.${t}.scopes`,s.scopes&&JSON.stringify(s.scopes)||""))}export{S as getSecurityDetails,h as setSecurityDetails,p as setSecurityDetailsVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as e}from"@redocly/theme";function n(o,t){e&&window.sessionStorage.setItem("redoc."+o,t)}function i(o){return e&&window.sessionStorage.getItem("redoc."+o)||""}export{i as fromSessionStorage,n as toSessionStorage};
|
|
1
|
+
import{IS_BROWSER as e}from"@redocly/theme/core/openapi";function n(o,t){e&&window.sessionStorage.setItem("redoc."+o,t)}function i(o){return e&&window.sessionStorage.getItem("redoc."+o)||""}export{i as fromSessionStorage,n as toSessionStorage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDefaultCollectorUrl(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withPathPrefix as o}from"@redocly/theme/core/openapi";function e(){return process.env.NODE_ENV==="development"?"http://localhost:4318":window.location.origin+o("/_otel")}export{e as getDefaultCollectorUrl};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.12.0-next.
|
|
3
|
+
"version": "3.12.0-next.20",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"styled-components": "^4.1.1 || ^5.3.11 || ^6.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@markdoc/markdoc": "0.5.
|
|
24
|
-
"@redocly/openapi-core": "
|
|
23
|
+
"@markdoc/markdoc": "0.5.2",
|
|
24
|
+
"@redocly/openapi-core": "2.0.2",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.2.6",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"url-template": "^2.0.8",
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
|
-
"@redocly/config": "0.
|
|
40
|
-
"@redocly/replay": "0.15.0-next.
|
|
39
|
+
"@redocly/config": "0.27.0",
|
|
40
|
+
"@redocly/replay": "0.15.0-next.14"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typescript": "5.6.2",
|
|
75
75
|
"url": "~0.11.0",
|
|
76
76
|
"vite": "^6.3.5",
|
|
77
|
-
"@redocly/theme": "0.56.0-next.
|
|
77
|
+
"@redocly/theme": "0.56.0-next.11"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"start": "npm run copy-highlight-hook && vite",
|