@redocly/openapi-docs 3.14.0-next.1 → 3.14.0-next.2
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 +1417 -1417
- package/lib/components/Replay/Replay.js +1 -1
- package/lib/components/Replay/utils.d.ts +3 -2
- package/lib/components/Replay/utils.js +1 -1
- package/lib/models/operation.d.ts +2 -1
- package/lib/models/operation.js +1 -1
- package/lib/utils/configure-helpers.d.ts +1 -0
- package/lib/utils/configure-helpers.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,Fragment as M,jsxs as z}from"react/jsx-runtime";import{lazy as J,memo as K,Suspense as w,useCallback as m,useRef as H,useState as Q}from"react";import{useAtom as u,useAtomValue as p}from"jotai";import W from"deepmerge";const X=J(async()=>import("@redocly/replay").then(e=>({default:e.ReplayOverlay})));import{Button as Y}from"@redocly/theme/components/Button/Button";import{useFocusTrap as Z,useModalScrollLock as $}from"@redocly/theme/core/openapi";import{RocketIcon as ee}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{CircleDashIcon as te}from"@redocly/theme/icons/CircleDashIcon/CircleDashIcon";import{Portal as oe}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as re}from"@redocly/theme/ext/useConfigureReplay";import{globalOptionsAtom as ne,globalStoreAtom as ae}from"../../jotai/store.js";import{allOperationsAtom as se,replayStateAtom as ie}from"../../jotai/replay.js";import{allOperations as le,getDefaultOperationStore as me}from"../../jotai/operation.js";import{LOADING_STATE as n}from"../../constants.js";import{environmentAtom as pe,userClaimsAtom as ce}from"../../jotai/app.js";import{convertOperationToReplayValueForRedoc as fe}from"./utils.js";import{useTranslate as ue,useTelemetry as de}from"../../hooks/index.js";import{JsonPointer as ye}from"../../utils/index.js";import{getDefaultCollectorUrl as he}from"../../utils/telemetry.js";import{createTryItOpenEvent as Oe,createTryItSentEvent as Ie}from"../../events/index.js";function Re({operation:e,corsProxyUrl:b,fullOpenApi:d}){const y=ue(),L=de(),h=H(null),{mockServer:P,oAuth2RedirectURI:q,routingBasePath:c}=p(ne),O=p(se),{parser:N,options:{events:a}}=p(ae),I=p(ce),[s,V]=Q(!1),[l,R]=u(ie),[g,v]=u(le),[[,E],A]=u(pe),{config:x,refresh:S}=re({userClaims:I,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers},s);Z(h),$(s);const j=m(()=>S(),[S]),k=m(({operations:t,environment:i,environments:f})=>{const _=t.reduce((D,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:F,method:B}=r.apiPath,C=ye.compile(["paths",F,B]);return D[C]=W(me(C),r),D},{});v({...g,..._}),A({environment:i,environments:f})},[g,v,A]),T=()=>{if(l!==n.LOADING){if(!s&&(L.sendOpenapiDocsTryItOpenedMessage(),a?.tryItOpen&&e)){const t=Oe({operation:e});a.tryItOpen(t)}V(!s)}l===n.NOT_LOADED&&R(n.LOADING)},G=m(t=>{if(a?.tryItSent&&e){const i=Ie({operation:e,isSuccess:t});a.tryItSent(i)}},[a,e]),U=m(t=>{if(!t)return;const i=O.find(f=>f.operationId===t);return c+i?.href},[O,c]);return d?z(M,{children:[o(Y,{onClick:T,variant:"primary",iconPosition:"left",icon:l===n.LOADING?o(te,{}):o(ee,{}),children:l===n.LOADING?y("openapi.loading","Loading..."):y("openapi.tryIt","Try it")}),s&&o(w,{children:o(oe,{mountId:"api-content",children:o("div",{ref:h,children:o(X,{activeOperationId:e.operationId||e.pointer,api:d,onRequestChange:k,onClose:T,onLoad:()=>R(n.LOADED),settings:{corsProxyUrl:b,mockServer:P,environment:E,apiId:N?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:q,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},convertOperationToReplayValue:fe(I,x),getOperationUrl:U,onRequestReset:j},onRequestSent:G})})})})]}):null}const Fe=K(Re);export{Fe as Replay};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { OpenAPIDefinition } from '../../types/index.js';
|
|
2
2
|
import type { OperationStore } from '../../jotai/operation.js';
|
|
3
3
|
import type { AppStore } from '../../jotai/app.js';
|
|
4
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '@redocly/theme/ext/configure';
|
|
4
5
|
import { type UserClaims } from '@redocly/theme/core/openapi';
|
|
5
6
|
import { type SecurityRequirement } from '../../models/index.js';
|
|
6
|
-
export declare function convertOperationToReplayValue(path: string, method: string, openAPI: OpenAPIDefinition, userClaims?: UserClaims, operationState?: OperationStore, appState?: AppStore): {
|
|
7
|
+
export declare function convertOperationToReplayValue(path: string, method: string, openAPI: OpenAPIDefinition, userClaims?: UserClaims, operationState?: OperationStore, appState?: AppStore, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): {
|
|
7
8
|
id: string;
|
|
8
9
|
name: string;
|
|
9
10
|
method: string;
|
|
@@ -22,7 +23,7 @@ export declare function convertOperationToReplayValue(path: string, method: stri
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
} | undefined;
|
|
25
|
-
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
26
|
+
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
26
27
|
operationId: string;
|
|
27
28
|
id: string;
|
|
28
29
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPrimitive as
|
|
1
|
+
import{isPrimitive as h}from"@redocly/theme/core/openapi";import{getOperation as v}from"../../models/index.js";import{normalizeOptions as b,OpenAPIParser as E}from"../../services/index.js";import{JsonPointer as V}from"../../utils/index.js";function y(t,a,n,r,e,m,s){if(!n)return;const u=new E(n),o=u.definition.paths?.[t],f=o?.[a],i=v(u,{...f,pathName:t,httpVerb:a,pathParameters:o.parameters||[],pathServers:o.servers||[]},void 0,b({}),"",{isCallback:!1},r,s);if(!i)return;const x=m?.activeMimeName||i.requestBody?.content?.mediaTypes[0]?.name||"application/json";return{id:i.id,name:i.name,method:i.httpVerb,operationId:i.operationId,parameters:O(i.parameters,e?.requestValues),body:w(i.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[x]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:i.path,href:i.href,servers:i.servers,security:q(i.security),responses:Object.fromEntries(i.responses.map(c=>[c.code,{code:c.code,description:c.description,mediaTypes:c.content?.mediaTypes.reduce((d,l)=>(d[l.name]={name:l.name,schema:p(l.schema?.rawSchema,n)},d),{})}]))}}function T(t,a){return function(n,r,e){const m=y(n,r,e,t,void 0,void 0,a);if(m)return{...m,operationId:m.operationId||V.compile(["paths",m.path,m.method])}}}function O(t,a){const n=new Set,r=t.map(e=>(n.add(e.in+":"+e.name),{name:e.name,in:e.in,required:e.required,description:e.description,example:a?.[String(e.in)]?.[e.name]||e.example,schema:e.schema}));for(const[e,m]of Object.entries(a||{}))for(const[s,u]of Object.entries(m||{}))n.has(e+":"+s)||r.push({name:s,in:e,required:!1,description:"",example:String(u),schema:void 0});return r}function N({type:t,format:a,enum:n}){return t==="string"&&(a==="binary"||a==="base64")?"file":t==="object"?"multiline":n.length>0?"select":"text"}function g(t,a){const n=t[0]?.example||t[0]?.examples;if(n)return n;if(t.schema?.example)return t.schema.example;const r=a?.default?.value||a?.default?.rawValue;return r?.[t.name]?h(r?.[t.name])?String(r?.[t.name]):JSON.stringify(r?.[t.name]):""}function w(t,a,n){if(!t||!t.content?.mediaTypes){if(!n)return;const{activeExampleName:r,...e}=n;return{activeExampleName:r,mediaTypes:Object.fromEntries(Object.entries(e).map(([m,s])=>[m,{name:m,examples:{default:{value:s}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((r,e)=>{const m=e.schema,s=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples;return r[e.name]={name:e.name,examples:s,schema:p(e.schema?.rawSchema,a),parameters:m?.fields?.map(u=>({inputType:N(u.schema),name:u.name,example:g(u,s)}))},r},{})}}function p(t,a){if(!(!t||!a))return{...t,components:a?.components||{}}}function q(t){if(t)return t.map(({schemes:a})=>a.map(n=>{const r={id:n.id,type:n.type,in:n.in,openIdConnectUrl:n.openIdConnectUrl,scopes:n.scopes,scheme:n.scheme,name:n.name,flows:n.flows,serverValues:n.serverValues,"x-defaultAccessToken":n["x-defaultAccessToken"],"x-defaultTokenType":n["x-defaultTokenType"],"x-defaultClientId":n["x-defaultClientId"],"x-defaultClientSecret":n["x-defaultClientSecret"],"x-defaultUsername":n["x-defaultUsername"],"x-defaultPassword":n["x-defaultPassword"]};return Object.keys(r).forEach(e=>r[e]===void 0&&delete r[e]),r}))}export{y as convertOperationToReplayValue,T as convertOperationToReplayValueForRedoc,q as convertRequestSecurity};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ExtendedOpenAPIOperation, Unstable_ExternalCodeSample, OpenAPIParser, Options } from '../services/index.js';
|
|
2
2
|
import type { OpenAPIServer, OpenAPIXCodeSample } from '../types/index.js';
|
|
3
3
|
import type { MediaContentModel, OperationModel, GroupModel } from './types.js';
|
|
4
|
+
import type { ConfigureRequestValues, ConfigureServerRequestValues } from '@redocly/theme/ext/configure';
|
|
4
5
|
import { type UserClaims } from '@redocly/theme/core/openapi';
|
|
5
6
|
export interface Sample {
|
|
6
7
|
lang: string;
|
|
@@ -16,5 +17,5 @@ export interface Callback {
|
|
|
16
17
|
id?: string;
|
|
17
18
|
}
|
|
18
19
|
export declare function isPayloadSample(sample: XPayloadSample | OpenAPIXCodeSample | Unstable_ExternalCodeSample): sample is XPayloadSample;
|
|
19
|
-
export declare function getOperation(parser: OpenAPIParser, operationDefinition: ExtendedOpenAPIOperation, parent: GroupModel | undefined, options: Options, href: string, callback?: Callback, userClaims?: UserClaims): OperationModel;
|
|
20
|
+
export declare function getOperation(parser: OpenAPIParser, operationDefinition: ExtendedOpenAPIOperation, parent: GroupModel | undefined, options: Options, href: string, callback?: Callback, userClaims?: UserClaims, dynamicRequestValues?: ConfigureRequestValues | ConfigureServerRequestValues | null): OperationModel;
|
|
20
21
|
export declare function mergeInMockServer(servers: OpenAPIServer[], mockServerOptions: Options['mockServer']): OpenAPIServer[];
|
package/lib/models/operation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC as
|
|
1
|
+
import{REDOCLY_TEAMS_RBAC as g}from"@redocly/config";import{removeLeadingSlash as x}from"@redocly/theme/core/openapi";import{configure as q}from"@redocly/theme/ext/configure";import{extractExtensions as R,getOperationId as P,getOperationName as B,getStatusCodeType as E,getValueFromMdParsedExtension as C,isStatusCode as k,JsonPointer as V,mergeParams as I,normalizeServers as f,sortByDeprecated as O,sortByRequired as N,updateOperationWithRequestValues as W,updateParametersWithUserValues as w}from"../utils/index.js";import{getCallback as A}from"./callback.js";import{getField as F}from"./field.js";import{getRequestBody as M}from"./request.js";import{getSecurity as n}from"./security.js";import{getResponse as j}from"./response.js";import{getHref as L}from"../services/menu/operation.js";function $(s){return s.lang==="Payload"&&"requestBodyContent"in s}function i(s,e,t,a,m,d,h,p){const c=e.isWebhook,r={operationDefinition:e,parent:t,pointer:e.pointer,description:C(e,"description"),externalDocs:e.externalDocs,deprecated:!!e.deprecated,httpVerb:e.httpVerb,operationId:e.operationId,path:e.pathName,isWebhook:c,isCallback:!!d?.isCallback,isEvent:d?.isCallback||c,name:B(e),defaultExampleName:e.defaultSampleName,[g]:e[g]||t?.[g],type:"operation",callbackId:d?.id,href:m,get callbacks(){return Object.keys(e.callbacks||[]).map(u=>A(s,u,e.callbacks?.[u],r.pointer,a,m,t,h))},get responses(){let u=!1;return Object.keys(e.responses||[]).filter(l=>l==="default"?!0:(E(l)==="success"&&(u=!0),k(l))).map(l=>j({parser:s,code:l,defaultAsError:u,infoOrRef:e.responses[l],options:a,isEvent:r.isEvent,operation:r}))},get parameters(){return T(s,e,r,a,o)}};if(d?.isCallback)r.security=n(e.security,s),r.servers=f("",e.servers||e.pathServers||[]),r.id=x(m);else{r.id=P(e,t),r.href=r.href||L(r),r.security=n(e.security||s.definition.security,s);const u=e.servers||(e.pathServers?.length?e.pathServers:null)||s.definition.servers||[];r.servers=f(s.definitionUrl,U(u,a.mockServer))}a.showExtensions&&(r.extensions=R(e,a.showExtensions)),r.requestBody=e.requestBody?M({parser:s,infoOrRef:e.requestBody,options:a,operation:r,isEvent:r.isEvent}):void 0;const y=r.requestBody?.content;r.payload={lang:"Payload",source:"",requestBodyContent:y?.hasSample?y:void 0},r.definitionSamples=e["x-codeSamples"]||[],r.badges=e["x-badges"]?.map(({name:u,color:l,position:v})=>({name:u,color:l||"var(--color-info-base)",position:v||"after"}))||[],r.hasSamples=y?.hasSample||r.definitionSamples.length>0,r.hideReplay=e["x-hideReplay"]===!0;const S={userClaims:h,info:s.definition.info||{},operation:{operationId:r.operationId,name:r.name,path:r.path,href:r.href,method:r.httpVerb},servers:r.servers},b=q(S)||{},o=p||b.requestValues||{};return W(r,o),r}function T(s,e,t,a,m){let d=I(s,e.pathParameters,e.parameters,{pathPointer:V.dirName(t.pointer),operationPointer:t.pointer}).map(({paramOrRef:h,pointer:p})=>{const c=F(s,h,p,a,{operation:t,type:"request"});return w(c,m),c});return a.sortRequiredPropsFirst&&(d=N(d)),O(d)}function U(s,e){if(!e)return s;const t={url:e.url,description:e.description};switch(e.position){case"first":return[t,...s];case"last":return[...s,t];case"replace":return[t];default:return s}}export{i as getOperation,$ as isPayloadSample,U as mergeInMockServer};
|
|
@@ -6,6 +6,7 @@ export declare function updateRequestBodyWithUserValues(operation: OperationMode
|
|
|
6
6
|
export declare function updateSecurityWithUserValues(operation: OperationModel, securityValues?: SecurityDetails, serverUrl?: string): void;
|
|
7
7
|
export declare function updateOperationWithServerUserValues(operation: OperationModel, serverRequestValues: ConfigureServerRequestValues): void;
|
|
8
8
|
export declare function updateEnvVariablesWithUserValues(operation: OperationModel, environmentValues?: Record<string, string>, serverUrl?: string): void;
|
|
9
|
+
export declare function updateServerVariablesWithUserValues(operation: OperationModel, serverVariables?: Record<string, string>, serverUrl?: string): void;
|
|
9
10
|
export declare function isDirectRequestValues(value: any): value is ConfigureRequestValues;
|
|
10
11
|
export declare function updateObjectProperties(original: any, updates: any): any;
|
|
11
12
|
export declare function createSecurityUpdates(scheme: any, securityValues: SecurityDetails): SecurityCredentials;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as V}from"@redocly/theme/core/openapi";function p(e,t){Object.keys(t).length!==0&&(y(t)?(b(e,t),h(e,t.security),d(e,t.envVariables),v(e,t.serverVariables)):j(e,t))}function O(e,t){if(!t)return;const{in:r,name:s}=e;if(y(t)){const a=t,c={header:a.headers,query:a.query,path:a.path,cookie:a.cookie};r&&c[r]?.[s]&&(e.example=c[r][s])}else Object.entries(t).forEach(([a,c])=>{const f=c;if(!f)return;const n={header:f.headers,query:f.query,path:f.path,cookie:f.cookie};r&&n[r]?.[s]&&(e.serverValues||(e.serverValues={}),e.serverValues[a]={example:n[r][s]})})}function b(e,t,r){if(!e.requestBody||!t?.body)return;const s=e.requestBody.content;if(!s?.mediaTypes)return;const a=(c,f)=>{c[f]&&Object.keys(c[f]).forEach(n=>{const u=c[f]?.[n]?.value;let l;if(V(u)?l=o(u,t.body):l=t.body,!!l)if(r){const i=c[f][n];i.serverValues||(i.serverValues={}),i.serverValues[r]={value:l,rawValue:l},c[f][n]={...i,mime:c.name}}else c[f][n]={value:l,rawValue:l,mime:c.name}})};for(const c of s.mediaTypes)a(c,"examples"),a(c,"formExamples");return e}function h(e,t,r){!t||!e.security.length||e.security.forEach(s=>{r?s.schemes.forEach(a=>{a.serverValues||(a.serverValues={});const c=k(a,t);a.serverValues[r]=c}):s.schemes.forEach(a=>{const c=k(a,t);Object.assign(a,c)})})}function j(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),d(e,s.envVariables,r.url),v(e,s.serverVariables,r.url))}})}function d(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 v(e,t,r){if(!(!t||Object.keys(t).length===0))if(r){const s=e.servers.find(a=>a.url===r);if(s){s.variables||(s.variables={});for(const[a,c]of Object.entries(t))s.variables[a]&&(s.variables[a].default=c)}}else e.servers.forEach(s=>{s.variables||(s.variables={});for(const[a,c]of Object.entries(t))s.variables[a]&&(s.variables[a].default=c)})}function y(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||"serverVariables"in e}function o(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]),a=t.filter(c=>typeof c!="object"||c===null?!1:s.some(f=>f in c)&&Object.keys(c).every(f=>s.includes(f)));return a.length>0?a:e}return t}const r=Array.isArray(e)?[...e]:{...e};for(const[s,a]of Object.entries(t))s in e&&(Array.isArray(e[s])||typeof a=="object"&&a!==null&&typeof e[s]=="object"?r[s]=o(e[s],a):r[s]=a);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,y as isDirectRequestValues,d as updateEnvVariablesWithUserValues,o as updateObjectProperties,p as updateOperationWithRequestValues,j as updateOperationWithServerUserValues,O as updateParametersWithUserValues,b as updateRequestBodyWithUserValues,h as updateSecurityWithUserValues,v as updateServerVariablesWithUserValues};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.14.0-next.
|
|
3
|
+
"version": "3.14.0-next.2",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"util": "~0.12.5",
|
|
38
38
|
"web-vitals": "3.3.1",
|
|
39
39
|
"@redocly/config": "0.29.1",
|
|
40
|
-
"@redocly/replay": "0.17.0-next.
|
|
40
|
+
"@redocly/replay": "0.17.0-next.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@jest/globals": "29.5.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"typescript": "5.6.2",
|
|
76
76
|
"url": "~0.11.0",
|
|
77
77
|
"vite": "^6.3.5",
|
|
78
|
-
"@redocly/theme": "0.58.0-next.
|
|
78
|
+
"@redocly/theme": "0.58.0-next.1"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"start": "npm run copy-highlight-hook && vite",
|