@redocly/openapi-docs 3.12.0-next.17 → 3.12.0-next.19
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 +1481 -1469
- 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 +4 -4
|
@@ -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.19",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -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.13"
|
|
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.10"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"start": "npm run copy-highlight-hook && vite",
|