@redocly/openapi-docs 3.21.0-next.3 → 3.21.0-next.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,Fragment as B,jsxs as M}from"react/jsx-runtime";import{lazy as z,memo as H,Suspense as J,useCallback as m,useRef as K,useState as W}from"react";import{useAtom as
|
|
1
|
+
import{jsx as o,Fragment as B,jsxs as M}from"react/jsx-runtime";import{lazy as z,memo as H,Suspense as J,useCallback as m,useRef as K,useState as W}from"react";import{useAtom as u,useAtomValue as p}from"jotai";import Q from"deepmerge";const X=z(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/use-configure-replay";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 de,useTelemetry as ue}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";import{joinWithSeparator as Re}from"../../services/history/helpers.js";import{HTTPSnippet as ge}from"../../services/code-samples/httpsnippet/index.js";function ve({operation:e,corsProxyUrl:V,fullOpenApi:y}){const h=de(),q=ue(),O=K(null),I=p(ne),{oAuth2RedirectURI:E,routingBasePath:c}=I,R=p(se),{parser:g,options:{events:a}}=p(ae),v=p(ce),[s,N]=W(!1),[l,A]=u(ie),[f,S]=u(le),[[,j],T]=u(pe),{config:D,refresh:b}=re({userClaims:v,info:g?.definition.info,operation:{name:e.name,path:e.path,operationId:e.operationId||"",href:e.href,method:e.httpVerb},servers:e.servers},s);Z(O),$(s);const x=m(()=>b(),[b]),_=m(({operations:t,environment:i,environments:d})=>{const k=t.reduce((L,r)=>{r.requestValues.body=r.requestValues.body instanceof URLSearchParams?Object.fromEntries(r.requestValues.body.entries()):r.requestValues.body;const{path:w,method:F}=r.apiPath,P=ye.compile(["paths",w,F]);return L[P]=Q(me(P),r),L},{});S({...f,...k}),T({environment:i,environments:d})},[f,S,T]),C=()=>{if(l!==n.LOADING){if(!s&&(q.sendTryItOpenedMessage([{id:"try-it-opened",object:"try_it",uri:typeof window<"u"?window.location.href:""}]),a?.tryItOpen&&e)){const t=Oe({operation:e});a.tryItOpen(t)}N(!s)}l===n.NOT_LOADED&&A(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=R.find(d=>d.operationId===t);return Re(c,i?.href)},[R,c]);return y?M(B,{children:[o(Y,{onClick:C,variant:"primary",iconPosition:"left",icon:l===n.LOADING?o(te,{}):o(ee,{}),children:l===n.LOADING?h("openapi.loading","Loading..."):h("openapi.tryIt","Try it")}),s&&o(J,{children:o(oe,{mountId:"api-content",children:o("div",{ref:O,children:o(X,{activeOperationId:e.operationId||e.pointer,api:y,onRequestChange:_,onClose:C,onLoad:()=>A(n.LOADED),settings:{corsProxyUrl:V,selectedEnvironment:j,apiId:g?.definition.info?.["x-metadata"]?.apiId,oAuth2RedirectURI:E,disableCollectionsTab:!0,storageKey:c,telemetry:{tracerName:"try-it",collectorUrl:he()},HTTPSnippet:ge,convertOperationToReplayValue:fe(v,D,I,f),dynamicReplayValues:D,getOperationUrl:U,onRequestReset:x},onRequestSent:G})})})})]}):null}const ze=H(ve);export{ze as Replay};
|
|
@@ -24,7 +24,7 @@ export declare function convertOperationToReplayValue(path: string, method: stri
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
} | undefined;
|
|
27
|
-
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null, options?: Options): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
27
|
+
export declare function convertOperationToReplayValueForRedoc(userClaims?: UserClaims, dynamicReplayValues?: ConfigureRequestValues | ConfigureServerRequestValues | null, options?: Options, operationStateByPointer?: Record<string, OperationStore>): (path: string, method: string, openAPI: OpenAPIDefinition) => {
|
|
28
28
|
operationId: string;
|
|
29
29
|
id: string;
|
|
30
30
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isPrimitive as
|
|
1
|
+
import{isPrimitive as O}from"@redocly/theme/core/openapi";import{getOperation as b}from"../../models/index.js";import{normalizeOptions as E,OpenAPIParser as w}from"../../services/index.js";import{JsonPointer as x}from"../../utils/index.js";function V(t,r,n,a,e,s,o,c){if(!n)return;const u=new w(n),m=u.definition.paths?.[t];let d=m?.[r];!d&&m?.additionalOperations&&(d=m.additionalOperations[r]);const i=b(u,{...d,pathName:t,httpVerb:r,pathParameters:m.parameters||[],pathServers:m.servers||[]},void 0,c??E({}),"",{isCallback:!1},a,o);if(!i)return;const v=s?.activeMimeName||i.requestBody?.content?.mediaTypes[0]?.name||"application/json";return{id:i.id,name:i.name,method:i.httpVerb,operationId:i.operationId,parameters:y(i.parameters,e?.requestValues),body:q(i.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[v]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:i.path,href:i.href,servers:i.servers,security:I(i.security),responses:Object.fromEntries(i.responses.map(l=>[l.code,{code:l.code,description:l.description,mediaTypes:l.content?.mediaTypes.reduce((p,f)=>(p[f.name]={name:f.name,schema:h(f.schema?.rawSchema,n)},p),{})}]))}}function k(t,r,n,a){return function(e,s,o){const c=x.compile(["paths",e,s]),u=a?.[c],m=V(e,s,o,t,u,void 0,r,n);if(m)return{...m,operationId:m.operationId||x.compile(["paths",m.path,m.method])}}}function y(t,r){const n=new Set,a=t.map(e=>(n.add(e.in+":"+e.name),{name:e.name,in:e.in,required:e.required,description:e.description,example:r?.[String(e.in)]?.[e.name]||e.example,schema:e.schema,...e.allowReserved&&{allowReserved:e.allowReserved}}));for(const[e,s]of Object.entries(r||{}))for(const[o,c]of Object.entries(s||{}))n.has(e+":"+o)||a.push({name:o,in:e,required:!1,description:"",example:String(c),schema:void 0});return a}function g({type:t,format:r,enum:n}){return t==="string"&&(r==="binary"||r==="base64")?"file":t==="object"?"multiline":n.length>0?"select":"text"}function N(t,r){const n=t[0]?.example||t[0]?.examples;if(n)return n;if(t.schema?.example)return t.schema.example;const a=r?.default?.value||r?.default?.rawValue;return a?.[t.name]?O(a?.[t.name])?String(a?.[t.name]):JSON.stringify(a?.[t.name]):""}function S(t){if(t?.fields)return t.fields;if(t?.oneOf){for(const r of t.oneOf)if(r?.fields)return r.fields}}function q(t,r,n){if(!t||!t.content?.mediaTypes){if(!n)return;const{activeExampleName:a,...e}=n;return{activeExampleName:a,mediaTypes:Object.fromEntries(Object.entries(e).map(([s,o])=>[s,{name:s,examples:{default:{value:o}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((a,e)=>{const s=e.schema,o=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples,c=S(s);return a[e.name]={name:e.name,examples:o,schema:h(e.schema?.rawSchema,r),parameters:c?.map(u=>({inputType:g(u.schema),name:u.name,example:N(u,o)}))},a},{})}}function h(t,r){if(!(!t||!r))return{...t,components:r?.components||{}}}function I(t){if(t)return t.map(({schemes:r})=>r.map(n=>{const a={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(a).forEach(e=>a[e]===void 0&&delete a[e]),a}))}export{V as convertOperationToReplayValue,k as convertOperationToReplayValueForRedoc,I as convertRequestSecurity};
|
package/lib/types/open-api.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export interface OpenAPIOperation extends ParsedDescriptionWithSummary {
|
|
|
116
116
|
'x-codeSamples'?: OpenAPIXCodeSample[];
|
|
117
117
|
'x-badges'?: OpenAPIXBadges[];
|
|
118
118
|
'x-hideReplay'?: boolean;
|
|
119
|
-
'x-
|
|
119
|
+
'x-catalogRelations'?: {
|
|
120
120
|
type: (typeof ENTITY_RELATION_TYPES)[number];
|
|
121
121
|
key: string;
|
|
122
122
|
}[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-docs",
|
|
3
|
-
"version": "3.21.0-next.
|
|
3
|
+
"version": "3.21.0-next.5",
|
|
4
4
|
"description": "Redocly OpenAPI Docs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@markdoc/markdoc": "0.5.2",
|
|
24
|
-
"@redocly/openapi-core": "2.30.
|
|
24
|
+
"@redocly/openapi-core": "2.30.3",
|
|
25
25
|
"deepmerge": "^4.2.2",
|
|
26
26
|
"dompurify": "3.4.0",
|
|
27
27
|
"fast-deep-equal": "^3.1.3",
|
|
28
|
-
"fast-xml-parser": "5.7.
|
|
28
|
+
"fast-xml-parser": "5.7.3",
|
|
29
29
|
"jotai": "^2.12.5",
|
|
30
30
|
"jotai-family": "1.0.1",
|
|
31
31
|
"json-pointer": "^0.6.2",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"web-vitals": "3.3.1",
|
|
41
41
|
"@redocly/config": "0.48.1",
|
|
42
42
|
"@redocly/redoc-opentelemetry": "0.1.0",
|
|
43
|
-
"@redocly/replay": "0.24.0-next.
|
|
43
|
+
"@redocly/replay": "0.24.0-next.5"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@shikijs/transformers": "3.21.0",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"url": "~0.11.0",
|
|
73
73
|
"vite": "7.2.6",
|
|
74
74
|
"vitest": "4.0.10",
|
|
75
|
-
"@redocly/theme": "0.65.0-next.
|
|
75
|
+
"@redocly/theme": "0.65.0-next.5"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"start": "pnpm run copy-highlight-hook && vite",
|