@redocly/openapi-docs 3.19.0-next.4 → 3.19.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.
- package/dist/redocly-openapi-docs.min.js +1829 -1829
- package/lib/components/Discriminator/Discriminator.d.ts +0 -1
- package/lib/components/Discriminator/Discriminator.js +2 -2
- package/lib/components/Schema/ObjectSchema.js +1 -1
- package/lib/components/Schema/Schema.js +2 -2
- package/lib/components/Schema/types.d.ts +1 -3
- package/lib/services/OpenAPIParser.js +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,6 @@ import type { SchemaModel } from '../../models/index.js';
|
|
|
3
3
|
interface DiscriminatorDropdownProps {
|
|
4
4
|
activeOneOfIdx: number;
|
|
5
5
|
parent: SchemaModel;
|
|
6
|
-
onChange?: (idx: number) => void;
|
|
7
6
|
translate: TFunction;
|
|
8
7
|
}
|
|
9
8
|
export declare const Discriminator: import("react").NamedExoticComponent<DiscriminatorDropdownProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as n,jsxs as
|
|
1
|
+
import{jsx as n,jsxs as l}from"react/jsx-runtime";import{memo as s,useMemo as c}from"react";import{strikethroughText as d}from"../../utils/index.js";import{SchemaSelection as f}from"../common/SchemaSelection/SchemaSelection.js";import{SelectionTitle as g}from"../common/index.js";import{styled as t}from"../../styled-components.js";import{DefaultMappingOption as u}from"./DefaultMappingOption.js";function x({activeOneOfIdx:a,parent:e,translate:i}){const p=c(()=>(e.oneOf||[]).map((o,r)=>{const m=o.schema.deprecated?`${d(o.title)} (${i("openapi.badges.deprecated","deprecated").toLowerCase()})`:o.title;return o.isDefaultMapping?{label:i("openapi.discriminator.defaultMapping","Default mapping"),value:r,element:n(u,{label:i("openapi.discriminator.defaultMapping","Default mapping")}),...e.oneOf&&e.oneOf.length>1?{divider:n(v,{})}:{}}:{label:m,value:r}}),[e.oneOf,i]);return e.oneOf===void 0?null:l(D,{children:[n(g,{children:i("openapi.discriminator","Discriminator")}),n(f,{options:p,pointer:e.operationPointer,schema:e,defaultOneOfIdx:a})]})}const k=s(x),D=t.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: flex-start;
|
|
@@ -16,4 +16,4 @@ import{jsx as n,jsxs as s}from"react/jsx-runtime";import{memo as c,useMemo as d}
|
|
|
16
16
|
width: 1px;
|
|
17
17
|
margin: var(--spacing-xxs) calc(var(--spacing-xxs) / 2);
|
|
18
18
|
}
|
|
19
|
-
`;export{
|
|
19
|
+
`;export{k as Discriminator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,Fragment as P,jsxs as p}from"react/jsx-runtime";import{memo as C}from"react";import{useAtomValue as F}from"jotai";import{PropertiesTableCaption as N}from"../common/index.js";import{Discriminator as v}from"../Discriminator/index.js";import{globalOptionsAtom as A}from"../../jotai/store.js";import{PropertyDetails as B}from"../PropertyDetails/index.js";import{SubSchema as _}from"./SubSchema.js";import{getExpandByDefault as w}from"./helpers.js";import{useTranslate as E}from"../../hooks/index.js";import{ArrayClosingLabel as I,LabelValue as T}from"../common/styled.js";function V({schema:m,showTitle:i,discriminator:t,level:a,skipWriteOnly:n,skipReadOnly:o,fieldParentsName:c,expandable:f,deepLink:d,required:h,disableDeepLinks:u,shouldCloseArray:x,oneOfLevel:b,slug:g,onOneOfChange:O}){const{fields:s=[],title:y}=m,D=E(),{schemasExpansionLevel:L}=F(A),l=o||n?s.filter(e=>!(o&&e.schema.readOnly||n&&e.schema.writeOnly)):s,S=w({required:h,level:a,schemasExpansionLevel:L});return p(_,{expandable:f,expandByDefault:S,level:a,propertyLength:l.length,deepLink:d,operationPointer:m.operationPointer,children:[p(P,{children:[i&&r(N,{children:y}),l.map((e,j)=>r(B,{isFirst:j===0,field:e,fieldParentsName:Number(a)>1?c:[],renderDiscriminatorSwitch:t?.fieldName===e.name&&t?.parentSchema?()=>r(v,{parent:t.parentSchema,activeOneOfIdx:t.activeOneOfIdx,translate:D}):void 0,skipReadOnly:o,skipWriteOnly:n,showTitle:i,level:a,disableDeepLinks:u,oneOfLevel:b,slug:g,onOneOfChange:O},e.name))]}),x&&r(I,{className:"array-closing-label",children:r(T,{children:"]"})})]})}const Y=C(V);export{Y as ObjectSchema};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{memo as
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{memo as y}from"react";import{useAtomValue as S}from"jotai";import{useLocation as g}from"react-router-dom";import{ArraySchema as I}from"./ArraySchema.js";import{ObjectSchema as p}from"./ObjectSchema.js";import{OneOfSchema as b}from"./OneOfSchema.js";import{RecursiveSchema as s}from"./RecursiveSchema.js";import{operationStore as j}from"../../jotai/operation.js";import{FieldDetails as A}from"../PropertyDetails/index.js";import{pathIncludesLink as C}from"../../utils/index.js";import{styled as L}from"../../styled-components.js";function P({schema:e,onOneOfChange:n,...i}){const{activeOneOf:d}=S(j(e?.operationPointer||"")),u=g();if(!e)return null;const{type:t,oneOf:o,discriminatorProp:f,isCircular:O}=e;if(O)return r(s,{schema:e});if(f!==void 0){if(!o||!o.length)return console.warn(`Looks like you are using discriminator wrong: you don't have any definition inherited from the ${e.title}`),null;const m=o.findIndex((w,x)=>C(u,`d=${x}`)),l=m===-1?0:m,v=d[e.pointer]!==void 0?d[e.pointer]:l,a=o[v];return a?.isCircular?r(s,{schema:a}):r(p,{...i,schema:a,discriminator:{fieldName:f,parentSchema:e,activeOneOfIdx:l},onOneOfChange:n})}if(o!==void 0&&o.length>=1)return r(b,{...i,schema:e,onChange:n});const c=Array.isArray(t)?t:[t];if(c.includes("object")){if(e.fields?.length)return r(p,{...i,schema:e,onOneOfChange:n})}else if(c.includes("array"))return r(I,{...i,schema:e,onOneOfChange:n});const h={schema:e,name:"",description:i.oneOfLevel?"":e.description,required:!1,deprecated:!1};return r(k,{children:r(A,{field:h,fieldParentsName:i.fieldParentsName})})}const G=y(P),k=L.div`
|
|
2
2
|
width: 100%;
|
|
3
3
|
padding: var(--spacing-xxs) 0;
|
|
4
4
|
border-bottom: 1px solid var(--border-color-primary);
|
|
5
|
-
`;export{
|
|
5
|
+
`;export{G as Schema};
|
|
@@ -12,7 +12,6 @@ export interface SchemaOptions {
|
|
|
12
12
|
export interface SchemaProps extends SchemaOptions {
|
|
13
13
|
schema: SchemaModel;
|
|
14
14
|
parentType?: string[] | string;
|
|
15
|
-
onDiscriminatorChange?: (idx: number) => void;
|
|
16
15
|
onOneOfChange?: (params: OneOfChangeParams) => void;
|
|
17
16
|
fieldParentsName?: string[];
|
|
18
17
|
expandable?: boolean;
|
|
@@ -23,12 +22,11 @@ export interface SchemaProps extends SchemaOptions {
|
|
|
23
22
|
oneOfLevel?: number;
|
|
24
23
|
shouldCloseArray?: boolean;
|
|
25
24
|
}
|
|
26
|
-
export interface ObjectSchemaProps extends
|
|
25
|
+
export interface ObjectSchemaProps extends SchemaProps {
|
|
27
26
|
discriminator?: {
|
|
28
27
|
fieldName: string;
|
|
29
28
|
parentSchema: SchemaModel;
|
|
30
29
|
activeOneOfIdx: number;
|
|
31
|
-
onChange?: (idx: number) => void;
|
|
32
30
|
};
|
|
33
31
|
fieldParentsName?: string[];
|
|
34
32
|
expandable?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as W,getDefinitionName as I}from"../utils/index.js";import{JsonPointer as g}from"../utils/JsonPointer.js";import{normalizeOptions as z}from"./config-options/normalizeOptions.js";function w(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function $(m,e){return e?m.concat(e):m}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,f=z({})){this.options=f,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(o(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}byRef=e=>{let t;if(this.definition){e.charAt(0)!=="#"&&(e="#"+e),e=W(e);try{t=g.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],f=!1,n=0){const i=e?.["x-refsStack"];if(t=$(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=I(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?s=Object.assign({},s,{"x-circular-ref":!0}):this.isRef(s)&&(s=this.deref(s,t,f,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,f)),{resolved:s,refsStack:w(t,e.$ref)}}return{resolved:e,refsStack:$(t,i)}}mergeRefs(e,t,f){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return t;if(f&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:u,readOnly:y,writeOnly:a,...O}=i;return{allOf:[{description:s,title:u,readOnly:y,writeOnly:a},t,O]}}else return{...t,...i}}mergeAllOf(e,t,f,n="",i=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:n,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||I(t):e.title};!o(r.properties)&&R(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&R(r.items)&&(r.items={...r.items});const s=e.allOf.map((u,y)=>{const{resolved:a,refsStack:O}=this.deref(u,f,!0,i),c=u.$ref,p=c||g.join(n,[String(y)]);if(a["x-complex"])return{$ref:c,refsStack:w(O,c),schema:{"x-complex":!0},absolutePointer:p};const d=this.mergeAllOf(a,c,O,p,i+1);if(!(d["x-circular-ref"]&&d.allOf))return c&&r["x-parentRefs"]?.push(...d["x-parentRefs"]||[],c),{$ref:c,refsStack:w(O,c),schema:d,absolutePointer:p}}).filter(Boolean);for(const[u,{$ref:y,schema:a,refsStack:O,absolutePointer:c}]of s.entries()){const{type:p,enum:d,properties:h,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=a||{};if(!(r.type!==p&&!o(r.type)&&!o(p)&&!i)){if(o(p)||(Array.isArray(p)&&Array.isArray(r.type)?r.type=[...p,...r.type]:r.type=p),o(d)||(Array.isArray(d)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...d,...r.enum])):r.enum=d),!o(h)&&R(h)){r.properties=r.properties||{};for(const l in h){const x=$(O,h[l]?.["x-refsStack"]);if(!r.properties[l])r.properties[l]={...h[l],absolutePointer:g.join(c,["properties",l]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[l],h[l]],"x-refsStack":x},t+"/properties/"+l,x,g.join(c,["allOf",String(u),"properties",l]),i+1);r.properties[l]=q}}}if(!o(D)&&!A&&!b){const l=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof a.items=="boolean"?{}:Object.assign({},a.items);r.items=this.mergeAllOf({allOf:[l,x]},t+"/items",O,"",i+1)}o(P)||(r.oneOf=P),o(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:y&&S?S:r.title||S,description:r.description||C,readOnly:o(r.readOnly)?M:r.readOnly,writeOnly:o(r.writeOnly)?N:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||A,"x-complex":r["x-complex"]||b,...U}}}return r}findDerived(e){const t={},f=this.definition.components&&this.definition.components.schemas||{};for(const n in f){const{resolved:i}=this.deref(f[n]);!o(i.allOf)&&i.allOf.find(r=>!o(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(o(e.allOf))return e;const{allOf:t,...f}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)){const s=t.slice(0,n),u=t.slice(n+1),y=Object.keys(r).length>0?[r]:[];return{...f,oneOf:i.map(a=>({allOf:[...s,...y,a,...u]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,w as pushRef};
|
|
1
|
+
import{IS_BROWSER as E,isObject as R,isString as B,isUndefined as o}from"@redocly/theme/core/openapi";import{tryDecodeURIComponent as W,getDefinitionName as I}from"../utils/index.js";import{JsonPointer as g}from"../utils/JsonPointer.js";import{normalizeOptions as z}from"./config-options/normalizeOptions.js";function w(m,e){return e&&m[m.length-1]!==e?[...m,e]:m}function $(m,e){return e?m.concat(e):m}class _{options;definitionUrl;definition;allowMergeRefs=!1;constructor(e,t,f=z({})){this.options=f,this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const n=E?window.location.href:"";B(t)&&(this.definitionUrl=new URL(t,n).href)}validate(e){if(o(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}byRef=e=>{let t;if(this.definition){e.charAt(0)!=="#"&&(e="#"+e),e=W(e);try{t=g.get(this.definition,e)}catch{}return t||{}}};isRef(e){return e?(e=e,e.$ref!==void 0&&e.$ref!==null):!1}deref(e,t=[],f=!1,n=0){const i=e?.["x-refsStack"];if(t=$(t,i),n>5)return{resolved:Object.assign({},e,{"x-complex":!0}),refsStack:t};if(this.isRef(e)){const r=I(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let s=this.byRef(e.$ref);if(!s)throw new Error(`Failed to resolve $ref "${e.$ref}"`);return t.includes(e.$ref)?s=Object.assign({},s,{"x-circular-ref":!0}):this.isRef(s)&&(s=this.deref(s,t,f,n).resolved),this.allowMergeRefs&&(s=this.mergeRefs(e,s,f)),{resolved:s,refsStack:w(t,e.$ref)}}return{resolved:e,refsStack:$(t,i)}}mergeRefs(e,t,f){const{$ref:n,...i}=e,r=Object.keys(i);if(r.length===0)return t;if(f&&r.some(s=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly","x-complex"].includes(s))){const{description:s,title:u,readOnly:y,writeOnly:a,...O}=i;return{allOf:[{description:s,title:u,readOnly:y,writeOnly:a},t,O]}}else return{...t,...i}}mergeAllOf(e,t,f,n="",i=0){if(e["x-circular-ref"])return e;if(e=this.hoistOneOfs(e),e.allOf===void 0)return{absolutePointer:n,...e};let r={...e,"x-parentRefs":[],absolutePointer:g.join(n,["allOf"]),allOf:void 0,title:i===0?e.title||I(t):e.title};!o(r.properties)&&R(r.properties)&&(r.properties={...r.properties}),!o(r.items)&&R(r.items)&&(r.items={...r.items});const s=e.allOf.map((u,y)=>{const{resolved:a,refsStack:O}=this.deref(u,f,!0,i),c=u.$ref,p=c||g.join(n,[String(y)]);if(a["x-complex"])return{$ref:c,refsStack:w(O,c),schema:{"x-complex":!0},absolutePointer:p};const d=this.mergeAllOf(a,c,O,p,i+1);if(!(d["x-circular-ref"]&&d.allOf))return c&&r["x-parentRefs"]?.push(...d["x-parentRefs"]||[],c),{$ref:c,refsStack:w(O,c),schema:d,absolutePointer:p}}).filter(Boolean);for(const[u,{$ref:y,schema:a,refsStack:O,absolutePointer:c}]of s.entries()){const{type:p,enum:d,properties:h,items:D,required:k,title:S,description:C,readOnly:M,writeOnly:N,oneOf:P,anyOf:v,"x-circular-ref":A,"x-complex":b,...U}=a||{};if(!(r.type!==p&&!o(r.type)&&!o(p)&&!i)){if(o(p)||(Array.isArray(p)&&Array.isArray(r.type)?r.type=[...p,...r.type]:r.type=p),o(d)||(Array.isArray(d)&&Array.isArray(r.enum)?r.enum=Array.from(new Set([...d,...r.enum])):r.enum=d),!o(h)&&R(h)){r.properties=r.properties||{};for(const l in h){const x=$(O,h[l]?.["x-refsStack"]);if(!r.properties[l])r.properties[l]={...h[l],absolutePointer:g.join(c,["properties",l]),"x-refsStack":x};else if(!A){const q=this.mergeAllOf({allOf:[r.properties[l],h[l]],"x-refsStack":x},t+"/properties/"+l,x,g.join(c,["allOf",String(u),"properties",l]),i+1);r.properties[l]=q}}}if(!o(D)&&!A&&!b){const l=typeof r.items=="boolean"?{}:Object.assign({},r.items),x=typeof a.items=="boolean"?{}:Object.assign({},a.items);r.items=this.mergeAllOf({allOf:[l,x]},t+"/items",O,"",i+1)}o(P)||(r.oneOf=P),o(v)||(r.anyOf=v),Array.isArray(k)&&(r.required=[...r.required||[],...k]),r={...r,title:e.title||(y&&S?S:r.title||S),description:r.description||C,readOnly:o(r.readOnly)?M:r.readOnly,writeOnly:o(r.writeOnly)?N:r.writeOnly,"x-circular-ref":r["x-circular-ref"]||A,"x-complex":r["x-complex"]||b,...U}}}return r}findDerived(e){const t={},f=this.definition.components&&this.definition.components.schemas||{};for(const n in f){const{resolved:i}=this.deref(f[n]);!o(i.allOf)&&i.allOf.find(r=>!o(r.$ref)&&e.indexOf(r.$ref)>-1)&&(t["#/components/schemas/"+n]=[i["x-discriminator-value"]||n])}return t}hoistOneOfs(e){if(o(e.allOf))return e;const{allOf:t,...f}=e;for(let n=0;n<t.length;n++){const{oneOf:i,...r}=t[n];if(i&&Array.isArray(i)){const s=t.slice(0,n),u=t.slice(n+1),y=Object.keys(r).length>0?[r]:[];return{...f,oneOf:i.map(a=>({allOf:[...s,...y,a,...u]}))}}}return e}}export{_ as OpenAPIParser,$ as concatRefStacks,w as pushRef};
|