fumadocs-openapi 5.11.3 → 5.11.4
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/index.d.ts +6 -1
- package/dist/server/index.d.ts +5 -1
- package/dist/server/index.js +60 -44
- package/dist/ui/index.d.ts +4 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -179,6 +179,7 @@ type ReferenceObject = OpenAPIV3_1.ReferenceObject;
|
|
|
179
179
|
type PathItemObject = OpenAPIV3_1.PathItemObject;
|
|
180
180
|
type TagObject = OpenAPIV3_1.TagObject;
|
|
181
181
|
type ServerObject = NoReference<OpenAPIV3_1.ServerObject>;
|
|
182
|
+
type CallbackObject = NoReference<OpenAPIV3_1.CallbackObject>;
|
|
182
183
|
type MethodInformation = NoReference<OperationObject> & {
|
|
183
184
|
method: string;
|
|
184
185
|
};
|
|
@@ -215,6 +216,10 @@ interface RenderContext {
|
|
|
215
216
|
*/
|
|
216
217
|
generateCodeSamples?: (endpoint: EndpointSample) => Awaitable<CodeSample[]>;
|
|
217
218
|
shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
|
|
219
|
+
/**
|
|
220
|
+
* Show full response schema instead of only example response & Typescript definitions
|
|
221
|
+
*/
|
|
222
|
+
showResponseSchema?: boolean;
|
|
218
223
|
}
|
|
219
224
|
|
|
220
225
|
type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
@@ -317,4 +322,4 @@ interface Config extends GenerateOptions {
|
|
|
317
322
|
}
|
|
318
323
|
declare function generateFiles(options: Config): Promise<void>;
|
|
319
324
|
|
|
320
|
-
export { type Config, type DereferenceMap, type Document, type GenerateOptions, type GeneratePageOutput, type GenerateTagOutput, type MethodInformation, type OperationObject, type ParameterObject, type PathItemObject, type ReferenceObject, type RenderContext, type SecurityRequirementObject, type SecuritySchemeObject, type ServerObject, type TagObject, generateAll, generateFiles, generatePages, generateTags };
|
|
325
|
+
export { type CallbackObject, type Config, type DereferenceMap, type Document, type GenerateOptions, type GeneratePageOutput, type GenerateTagOutput, type MethodInformation, type OperationObject, type ParameterObject, type PathItemObject, type ReferenceObject, type RenderContext, type SecurityRequirementObject, type SecuritySchemeObject, type ServerObject, type TagObject, generateAll, generateFiles, generatePages, generateTags };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -208,11 +208,15 @@ interface RenderContext {
|
|
|
208
208
|
*/
|
|
209
209
|
generateCodeSamples?: (endpoint: EndpointSample) => Awaitable<CodeSample[]>;
|
|
210
210
|
shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
|
|
211
|
+
/**
|
|
212
|
+
* Show full response schema instead of only example response & Typescript definitions
|
|
213
|
+
*/
|
|
214
|
+
showResponseSchema?: boolean;
|
|
211
215
|
}
|
|
212
216
|
|
|
213
217
|
type DocumentInput = string | OpenAPIV3_1.Document | OpenAPIV3.Document;
|
|
214
218
|
|
|
215
|
-
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl'>;
|
|
219
|
+
type ApiPageContextProps = Pick<Partial<RenderContext>, 'shikiOptions' | 'generateTypeScriptSchema' | 'generateCodeSamples' | 'proxyUrl' | 'showResponseSchema'>;
|
|
216
220
|
interface ApiPageProps extends ApiPageContextProps {
|
|
217
221
|
document: DocumentInput;
|
|
218
222
|
hasHead: boolean;
|
package/dist/server/index.js
CHANGED
|
@@ -796,6 +796,7 @@ function Operation({ type = 'operation', path, method, ctx, hasHead, headingLeve
|
|
|
796
796
|
const security = method.security ?? ctx.document.security;
|
|
797
797
|
let headNode = null;
|
|
798
798
|
let bodyNode = null;
|
|
799
|
+
let responseNode = null;
|
|
799
800
|
let callbacksNode = null;
|
|
800
801
|
if (hasHead) {
|
|
801
802
|
const title = method.summary ?? (method.operationId ? idToTitle(method.operationId) : path);
|
|
@@ -843,6 +844,38 @@ function Operation({ type = 'operation', path, method, ctx, hasHead, headingLeve
|
|
|
843
844
|
]
|
|
844
845
|
});
|
|
845
846
|
}
|
|
847
|
+
if (method.responses && ctx.showResponseSchema) {
|
|
848
|
+
responseNode = /*#__PURE__*/ jsxs(Fragment, {
|
|
849
|
+
children: [
|
|
850
|
+
heading(headingLevel, 'Response Body', ctx),
|
|
851
|
+
Object.entries(method.responses).map(([status, response])=>{
|
|
852
|
+
if (!response.content) return;
|
|
853
|
+
const mediaType = getPreferredType(response.content);
|
|
854
|
+
if (!mediaType) return null;
|
|
855
|
+
const content = response.content[mediaType];
|
|
856
|
+
if (!content.schema) return null;
|
|
857
|
+
return /*#__PURE__*/ jsxs(Fragment$1, {
|
|
858
|
+
children: [
|
|
859
|
+
heading(headingLevel + 1, status, ctx),
|
|
860
|
+
/*#__PURE__*/ jsx(Markdown, {
|
|
861
|
+
text: response.description
|
|
862
|
+
}),
|
|
863
|
+
/*#__PURE__*/ jsx(Schema, {
|
|
864
|
+
name: "response",
|
|
865
|
+
schema: content.schema,
|
|
866
|
+
ctx: {
|
|
867
|
+
render: ctx,
|
|
868
|
+
writeOnly: false,
|
|
869
|
+
readOnly: true,
|
|
870
|
+
required: true
|
|
871
|
+
}
|
|
872
|
+
})
|
|
873
|
+
]
|
|
874
|
+
}, status);
|
|
875
|
+
})
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
}
|
|
846
879
|
const parameterGroups = new Map();
|
|
847
880
|
const endpoint = generateSample(path, method, ctx);
|
|
848
881
|
for (const param of method.parameters ?? []){
|
|
@@ -877,28 +910,11 @@ function Operation({ type = 'operation', path, method, ctx, hasHead, headingLeve
|
|
|
877
910
|
callbacksNode = /*#__PURE__*/ jsxs(Fragment, {
|
|
878
911
|
children: [
|
|
879
912
|
heading(headingLevel, 'Webhooks', ctx),
|
|
880
|
-
Object.entries(method.callbacks).map(([name, callback])
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
return /*#__PURE__*/ jsx(Operation, {
|
|
886
|
-
type: "webhook",
|
|
887
|
-
hasHead: true,
|
|
888
|
-
path: path,
|
|
889
|
-
headingLevel: headingLevel + 1,
|
|
890
|
-
method: createMethod(method, pathItem, operation),
|
|
891
|
-
ctx: ctx
|
|
892
|
-
}, method);
|
|
893
|
-
});
|
|
894
|
-
return /*#__PURE__*/ jsx(Fragment$1, {
|
|
895
|
-
children: pathNodes
|
|
896
|
-
}, path);
|
|
897
|
-
});
|
|
898
|
-
return /*#__PURE__*/ jsx(Fragment$1, {
|
|
899
|
-
children: nodes
|
|
900
|
-
}, name);
|
|
901
|
-
})
|
|
913
|
+
Object.entries(method.callbacks).map(([name, callback])=>/*#__PURE__*/ jsx(WebhookCallback, {
|
|
914
|
+
callback: callback,
|
|
915
|
+
ctx: ctx,
|
|
916
|
+
headingLevel: headingLevel
|
|
917
|
+
}, name))
|
|
902
918
|
]
|
|
903
919
|
});
|
|
904
920
|
}
|
|
@@ -930,6 +946,7 @@ function Operation({ type = 'operation', path, method, ctx, hasHead, headingLeve
|
|
|
930
946
|
]
|
|
931
947
|
}, group);
|
|
932
948
|
}),
|
|
949
|
+
responseNode,
|
|
933
950
|
callbacksNode
|
|
934
951
|
]
|
|
935
952
|
});
|
|
@@ -1005,6 +1022,25 @@ async function APIExample({ method, endpoint, ctx }) {
|
|
|
1005
1022
|
children: children
|
|
1006
1023
|
});
|
|
1007
1024
|
}
|
|
1025
|
+
function WebhookCallback({ callback, ctx, headingLevel }) {
|
|
1026
|
+
return Object.entries(callback).map(([path, pathItem])=>{
|
|
1027
|
+
const pathNodes = methodKeys.map((method)=>{
|
|
1028
|
+
const operation = pathItem[method];
|
|
1029
|
+
if (!operation) return null;
|
|
1030
|
+
return /*#__PURE__*/ jsx(Operation, {
|
|
1031
|
+
type: "webhook",
|
|
1032
|
+
hasHead: true,
|
|
1033
|
+
path: path,
|
|
1034
|
+
headingLevel: headingLevel + 1,
|
|
1035
|
+
method: createMethod(method, pathItem, operation),
|
|
1036
|
+
ctx: ctx
|
|
1037
|
+
}, method);
|
|
1038
|
+
});
|
|
1039
|
+
return /*#__PURE__*/ jsx(Fragment$1, {
|
|
1040
|
+
children: pathNodes
|
|
1041
|
+
}, path);
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1008
1044
|
/**
|
|
1009
1045
|
* Remove duplicated labels
|
|
1010
1046
|
*/ function dedupe(samples) {
|
|
@@ -1031,28 +1067,7 @@ function AuthSection({ ctx: { document, renderer }, requirements }) {
|
|
|
1031
1067
|
})
|
|
1032
1068
|
]
|
|
1033
1069
|
}) : null;
|
|
1034
|
-
if (schema.type === 'http') {
|
|
1035
|
-
info.push(/*#__PURE__*/ jsxs(renderer.Property, {
|
|
1036
|
-
name: "Authorization",
|
|
1037
|
-
type: prefix ? `${prefix} <token>` : '<token>',
|
|
1038
|
-
required: true,
|
|
1039
|
-
children: [
|
|
1040
|
-
schema.description ? /*#__PURE__*/ jsx(Markdown, {
|
|
1041
|
-
text: schema.description
|
|
1042
|
-
}) : null,
|
|
1043
|
-
/*#__PURE__*/ jsxs("p", {
|
|
1044
|
-
children: [
|
|
1045
|
-
"In: ",
|
|
1046
|
-
/*#__PURE__*/ jsx("code", {
|
|
1047
|
-
children: "header"
|
|
1048
|
-
}),
|
|
1049
|
-
scopeElement
|
|
1050
|
-
]
|
|
1051
|
-
})
|
|
1052
|
-
]
|
|
1053
|
-
}, id++));
|
|
1054
|
-
}
|
|
1055
|
-
if (schema.type === 'oauth2') {
|
|
1070
|
+
if (schema.type === 'http' || schema.type === 'oauth2') {
|
|
1056
1071
|
info.push(/*#__PURE__*/ jsxs(renderer.Property, {
|
|
1057
1072
|
name: "Authorization",
|
|
1058
1073
|
type: prefix ? `${prefix} <token>` : '<token>',
|
|
@@ -1312,6 +1327,7 @@ async function getContext({ document, dereferenceMap }, options = {}) {
|
|
|
1312
1327
|
document: document,
|
|
1313
1328
|
dereferenceMap,
|
|
1314
1329
|
proxyUrl: options.proxyUrl,
|
|
1330
|
+
showResponseSchema: options.showResponseSchema,
|
|
1315
1331
|
renderer: {
|
|
1316
1332
|
...createRenders(options.shikiOptions),
|
|
1317
1333
|
...options.renderer
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ interface RenderContext {
|
|
|
82
82
|
*/
|
|
83
83
|
generateCodeSamples?: (endpoint: EndpointSample) => Awaitable<CodeSample[]>;
|
|
84
84
|
shikiOptions?: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BuiltinTheme>;
|
|
85
|
+
/**
|
|
86
|
+
* Show full response schema instead of only example response & Typescript definitions
|
|
87
|
+
*/
|
|
88
|
+
showResponseSchema?: boolean;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
interface BaseRequestField {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-openapi",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.4",
|
|
4
4
|
"description": "Generate MDX docs for your OpenAPI spec",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"remark-rehype": "^11.1.1",
|
|
48
48
|
"shiki": "^1.26.1",
|
|
49
49
|
"xml-js": "^1.6.11",
|
|
50
|
-
"fumadocs-core": "14.7.
|
|
51
|
-
"fumadocs-ui": "14.7.
|
|
50
|
+
"fumadocs-core": "14.7.3",
|
|
51
|
+
"fumadocs-ui": "14.7.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/js-yaml": "^4.0.9",
|