@redocly/openapi-docs 3.12.0-next.16 → 3.12.0-next.18
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 +1169 -1148
- package/lib/components/ExpandAllButton/ExpandAllButton.js +2 -2
- 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/Samples/ExampleSwitch.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/package.json +5 -5
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{jsx as n}from"react/jsx-runtime";import{useAtom as d}from"jotai";import{MaximizeIcon as m}from"@redocly/theme/icons/MaximizeIcon/MaximizeIcon";import{Button as c}from"@redocly/theme/components/Button/Button";import{operationStore as x}from"../../jotai/operation.js";import{useTelemetry as u,useTranslate as f}from"../../hooks/index.js";import{styled as A}from"../../styled-components.js";const
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{useAtom as d}from"jotai";import{MaximizeIcon as m}from"@redocly/theme/icons/MaximizeIcon/MaximizeIcon";import{Button as c}from"@redocly/theme/components/Button/Button";import{operationStore as x}from"../../jotai/operation.js";import{useTelemetry as u,useTranslate as f}from"../../hooks/index.js";import{styled as A}from"../../styled-components.js";const j=({operationPointer:a,type:o,onPanelToggle:r})=>{const t=f(),[l,s]=d(x(a)),p=u(),i=()=>{const e=!l[o].expandedAll;p.send({type:"openapi_docs.expand_collapse_all.clicked",payload:{isExpanded:e}}),s({[o]:{expandedAll:e}}),r?.(e,o==="request"?"request":"responses")};return n(g,{icon:n(m,{}),iconPosition:"right",size:"small",variant:"ghost",onClick:i,children:l[o].expandedAll?t("openapi.collapseAll","Collapse all"):t("openapi.expandAll","Expand all")})},g=A(c)`
|
|
2
2
|
margin-left: auto;
|
|
3
|
-
`;export{
|
|
3
|
+
`;export{j as ExpandAllButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as c,Fragment as f,jsxs as h}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as E}from"jotai";import{ExampleSwitch as g,useExampleKey as
|
|
1
|
+
import{jsx as c,Fragment as f,jsxs as h}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as E}from"jotai";import{ExampleSwitch as g,useExampleKey as d}from"../Samples/index.js";import{useActivateExample as O,useTelemetry as j}from"../../hooks/index.js";import{operationStore as y}from"../../jotai/operation.js";function _({mediaType:o,mediaContent:p,renderSample:n}){const r=j(),m=o.operation.pointer,[l,x]=E(y(m)),a=o.examples||{},e=Object.keys(a),i=O(p),{exampleKey:s}=d(o.operation,a);return!e.length||e.length===1?n():h(f,{children:[c(g,{examples:a,exampleKey:s,onChange:t=>{r.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t,numberOfExamples:e.length}}),x({...l,activeExampleName:t,activeOneOf:{[m]:e.indexOf(t)},requestValues:{body:null}}),i(t)}}),n(s)]})}const N=u(_);export{N as Example};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as T,useCallback as k,useMemo as A}from"react";import{useAtomValue as y,useAtom as M}from"jotai";import{PanelHeader as U}from"@redocly/theme/components/Panel/PanelHeader";import{PayloadSamples as W}from"../PayloadSamples/index.js";import{CodeSample as B}from"./CodeSample.js";import{useCodeSamples as F}from"./useCodeSamples.js";import{isPayloadSample as H}from"../../models/index.js";import{createCodeSampleCopyEvent as O,createLanguageSwitchEvent as V}from"../../events/index.js";import{globalStoreAtom as $}from"../../jotai/store.js";import{ServerListDropdown as z}from"../ServerListDropdown/index.js";import{LanguageDropdown as G}from"../Language/index.js";import{activeMimeNameAtom as J,languageAtom as K}from"../../jotai/app.js";import{Replay as L}from"../Replay/index.js";import{CodeBlockPanel as w}from"../common/index.js";import{useActiveWithFallback as Q,useTelemetry as X}from"../../hooks/index.js";import{operationStore as Y}from"../../jotai/operation.js";import{styled as v}from"../../styled-components.js";function Z({operation:a,disableFooter:P,onPanelToggle:S,...p}){const c=X(),[{activeLanguage:q,languages:m},R]=M(K),{samples:n}=F(a),{parser:d,options:{events:s,corsProxyUrl:g,hideReplay:_}}=y($),i=!P&&!a.isWebhook&&!_&&!a.hideReplay,t=!!m?.length,u=Q(n,q),E=e=>{R(e),c.send({type:"openapi_docs.select_language.clicked",payload:{language:e}});const r=m?.find(l=>l.key===e);if(s?.codeSamplesLanguageSwitch&&r){const l=V({operation:a,sample:{lang:r.lang,label:r.title}});s.codeSamplesLanguageSwitch(l)}},h=y(J),{activeExampleName:x}=y(Y(a.pointer)),f=k(({lang:e,title:r})=>()=>{const l=O({operation:a,label:r,lang:e,type:"request",activeMimeName:h,activeExampleName:x});c.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{snippetType:"request",language:e}}),s?.codeSamplesCopy?.(l)},[a,c,s,h,x]),b=k(e=>{S?.(e,"request-samples")},[S]),C=()=>D(I,{isExpandable:!1,withReplay:!t&&i,children:[o(ee,{operation:a}),t&&o(G,{activeTab:u,samples:n,onChange:E}),!t&&i&&o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})]}),j=A(()=>{if(i&&t)return o(ae,{children:o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})})},[i,t,a,g,d.definition]),N=A(()=>n.map(e=>e.key===u?o("div",{children:H(e)?o(W,{content:e.requestBodyContent,onCopyClick:f(e),onPanelToggle:b,...p}):o(B,{lang:e.lang,source:e.source,externalSample:e,operation:a,onCopyClick:f(e),...p})},e.key+a.id):null),[u,f,b,a,p,n]);return m&&!n.length?o(w,{className:"panel-request-samples",header:C,isExpandable:!1,expanded:!1}):n.length?o(w,{className:"panel-request-samples",header:C,footer:j,isExpandable:!1,children:N}):null}const xe=T(Z),I=v(U)`
|
|
2
2
|
flex-wrap: nowrap;
|
|
3
3
|
${({withReplay:a})=>a&&"padding: var(--spacing-xs) var(--spacing-sm);"}
|
|
4
4
|
`,ee=v(z)`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{memo as b,useCallback as i}from"react";import{useAtomValue as n}from"jotai";import{PayloadSamples as h,StyledCodeBlock as v}from"../PayloadSamples/index.js";import{createCodeSampleCopyEvent as k}from"../../events/index.js";import{globalOptionsAtom as T}from"../../jotai/store.js";import{Summary as g}from"./Summary.js";import{Tabs as x}from"../Tabs/index.js";import{CodeBlockPanel as N}from"../common/index.js";import{useTelemetry as _,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as P}from"../../jotai/operation.js";function R({operation:o,activeResponseTab:d,onTabChange:y,onPanelToggle:a}){const m=_(),{events:p}=n(T),f=A(),u=o.responses.filter(e=>e.content?.hasSample??!1),s=o.responses.map(({code:e})=>({key:e,title:e})),r=s?.find(({key:e})=>e===d)||s?.[0],l=n(E),{activeExampleName:c}=n(P(o.pointer)),C=i(()=>{m.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{memo as b,useCallback as i}from"react";import{useAtomValue as n}from"jotai";import{PayloadSamples as h,StyledCodeBlock as v}from"../PayloadSamples/index.js";import{createCodeSampleCopyEvent as k}from"../../events/index.js";import{globalOptionsAtom as T}from"../../jotai/store.js";import{Summary as g}from"./Summary.js";import{Tabs as x}from"../Tabs/index.js";import{CodeBlockPanel as N}from"../common/index.js";import{useTelemetry as _,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as P}from"../../jotai/operation.js";function R({operation:o,activeResponseTab:d,onTabChange:y,onPanelToggle:a}){const m=_(),{events:p}=n(T),f=A(),u=o.responses.filter(e=>e.content?.hasSample??!1),s=o.responses.map(({code:e})=>({key:e,title:e})),r=s?.find(({key:e})=>e===d)||s?.[0],l=n(E),{activeExampleName:c}=n(P(o.pointer)),C=i(()=>{m.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{snippetType:"response"}});const e=k({operation:o,type:"response",activeMimeName:l,activeExampleName:c});p?.codeSamplesCopy?.(e)},[m,o,p,l,c]),S=i(e=>{a?.(e,"response-samples")},[a]);return u.length?t(N,{className:"panel-response-samples",header:()=>t(g,{tabs:t(x,{tabs:s,activeTab:r,onChange:e=>y(e.key)})}),isExpandable:!1,children:o.responses.map(e=>e.code===r.key?t("div",{children:e?.content?.hasSample?t(h,{content:e.content,onCopyClick:C,onPanelToggle:S}):t(v,{source:f("openapi.noResponseContent","No content")})},e.code):null)}):null}const J=b(R);export{J as ResponseSamples};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as n}from"react/jsx-runtime";import{useState as f,useEffect as h}from"react";import{MimeLabel as x,Container as v,Select as b}from"../common/index.js";import{SelectOrLabel as y}from"../SelectOrLabel/index.js";import{normalizeText as S}from"../../utils/index.js";import{useTelemetry as
|
|
1
|
+
import{jsx as n}from"react/jsx-runtime";import{useState as f,useEffect as h}from"react";import{MimeLabel as x,Container as v,Select as b}from"../common/index.js";import{SelectOrLabel as y}from"../SelectOrLabel/index.js";import{normalizeText as S}from"../../utils/index.js";import{useTelemetry as g}from"../../hooks/index.js";const I=({exampleKey:a,examples:s,onChange:m,className:c})=>{const i=g(),t=Object.keys(s),o=a?t.indexOf(a):0,[p,l]=f(o>-1?o:0);h(()=>l(o>-1?o:0),[a,o]);const r=t.map((e,d)=>({value:S(s[e].summary)||e,idx:d})),u=({idx:e})=>{i.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t[e],numberOfExamples:t.length}}),l(e),m(t[e])};return r.length<2?null:n(v,{"data-testid":"example-switch",className:c,children:n(y,{Select:b,Label:x,variant:"dark",fullWidth:!0,options:r,value:r[p]?.value,onChange:u})})};export{I as ExampleSwitch};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { OpenAPIServerVariable } from '../../../../types/index.js';
|
|
2
2
|
import { VariableType } from './constants.js';
|
|
3
|
+
interface VariableDeclarationOptions {
|
|
4
|
+
hasVariableInterpolation: boolean;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Helper object to format and aggragate lines of code.
|
|
5
8
|
* Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
|
|
@@ -17,7 +20,7 @@ export declare class CodeBuilder {
|
|
|
17
20
|
langOptions: {
|
|
18
21
|
stringLiteral: (t: string) => string;
|
|
19
22
|
variableWrapperFn: (variableName: string, variableValue?: OpenAPIServerVariable | string) => string;
|
|
20
|
-
variableDeclaration: (v: string) => string;
|
|
23
|
+
variableDeclaration: (v: string, options?: VariableDeclarationOptions) => string;
|
|
21
24
|
joinSymbol: string;
|
|
22
25
|
urlFieldName: string;
|
|
23
26
|
rawName: boolean;
|
|
@@ -81,3 +84,4 @@ export declare class CodeBuilder {
|
|
|
81
84
|
*/
|
|
82
85
|
var(name: string, type?: VariableType): string;
|
|
83
86
|
}
|
|
87
|
+
export {};
|
|
@@ -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};
|
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.18",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.0.
|
|
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.12"
|
|
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.9"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"start": "npm run copy-highlight-hook && vite",
|