fumadocs-openapi 10.6.3 → 10.6.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.
Files changed (228) hide show
  1. package/css/generated/shared.css +8 -17
  2. package/dist/_openapi/types.d.ts +1 -2
  3. package/dist/generate-file.d.ts +3 -4
  4. package/dist/generate-file.js +0 -2
  5. package/dist/i18n.d.ts +1 -2
  6. package/dist/i18n.js +0 -2
  7. package/dist/playground/client.d.ts +12 -22
  8. package/dist/playground/client.js +37 -18
  9. package/dist/playground/components/inputs.js +0 -2
  10. package/dist/playground/components/oauth-dialog.js +0 -2
  11. package/dist/playground/components/server-select.js +0 -2
  12. package/dist/playground/fetcher.d.ts +1 -2
  13. package/dist/playground/fetcher.js +0 -2
  14. package/dist/playground/schema.d.ts +1 -2
  15. package/dist/playground/schema.js +25 -37
  16. package/dist/playground/status-info.js +0 -2
  17. package/dist/requests/generators/all.d.ts +1 -2
  18. package/dist/requests/generators/all.js +0 -2
  19. package/dist/requests/generators/csharp.d.ts +1 -2
  20. package/dist/requests/generators/csharp.js +0 -2
  21. package/dist/requests/generators/curl.d.ts +1 -2
  22. package/dist/requests/generators/curl.js +0 -2
  23. package/dist/requests/generators/go.d.ts +1 -2
  24. package/dist/requests/generators/go.js +0 -2
  25. package/dist/requests/generators/index.d.ts +1 -2
  26. package/dist/requests/generators/index.js +0 -2
  27. package/dist/requests/generators/java.d.ts +1 -2
  28. package/dist/requests/generators/java.js +0 -2
  29. package/dist/requests/generators/javascript.d.ts +1 -2
  30. package/dist/requests/generators/javascript.js +0 -2
  31. package/dist/requests/generators/python.d.ts +1 -2
  32. package/dist/requests/generators/python.js +0 -2
  33. package/dist/requests/media/adapter.d.ts +1 -2
  34. package/dist/requests/media/adapter.js +0 -2
  35. package/dist/requests/media/encode.d.ts +1 -2
  36. package/dist/requests/media/encode.js +0 -2
  37. package/dist/requests/media/resolve-adapter.js +0 -2
  38. package/dist/requests/string-utils.js +0 -2
  39. package/dist/requests/types.d.ts +1 -2
  40. package/dist/scalar/client.js +0 -2
  41. package/dist/scalar/index.d.ts +1 -2
  42. package/dist/scalar/index.js +0 -2
  43. package/dist/server/create.d.ts +2 -3
  44. package/dist/server/create.js +1 -3
  45. package/dist/server/proxy.d.ts +1 -2
  46. package/dist/server/proxy.js +0 -2
  47. package/dist/server/source-api.d.ts +3 -4
  48. package/dist/server/source-api.js +0 -2
  49. package/dist/types.d.ts +5 -6
  50. package/dist/ui/api-page.d.ts +1 -2
  51. package/dist/ui/api-page.js +0 -2
  52. package/dist/ui/base.d.ts +10 -10
  53. package/dist/ui/base.js +22 -2
  54. package/dist/ui/client/boundary.d.ts +1 -2
  55. package/dist/ui/client/boundary.js +0 -2
  56. package/dist/ui/client/boundary.lazy.js +0 -2
  57. package/dist/ui/client/full.js +0 -2
  58. package/dist/ui/client/i18n.js +0 -2
  59. package/dist/ui/client/index.d.ts +1 -2
  60. package/dist/ui/client/index.js +0 -2
  61. package/dist/ui/client/storage-key.js +0 -2
  62. package/dist/ui/components/accordion.js +0 -2
  63. package/dist/ui/components/codeblock.d.ts +1 -2
  64. package/dist/ui/components/codeblock.js +0 -2
  65. package/dist/ui/components/dialog.js +0 -2
  66. package/dist/ui/components/input.js +0 -2
  67. package/dist/ui/components/method-label.js +0 -2
  68. package/dist/ui/components/select-tab.js +0 -2
  69. package/dist/ui/components/select.js +0 -2
  70. package/dist/ui/contexts/api.d.ts +1 -2
  71. package/dist/ui/contexts/api.js +0 -2
  72. package/dist/ui/create-client.d.ts +1 -2
  73. package/dist/ui/create-client.js +18 -15
  74. package/dist/ui/index.d.ts +1 -2
  75. package/dist/ui/index.js +0 -2
  76. package/dist/ui/operation/client.js +0 -2
  77. package/dist/ui/operation/get-example-requests.d.ts +1 -2
  78. package/dist/ui/operation/get-example-requests.js +2 -4
  79. package/dist/ui/operation/index.js +5 -8
  80. package/dist/ui/operation/request-tabs.js +0 -2
  81. package/dist/ui/operation/response-tabs.d.ts +2 -3
  82. package/dist/ui/operation/response-tabs.js +0 -2
  83. package/dist/ui/operation/usage-tabs/client.d.ts +1 -2
  84. package/dist/ui/operation/usage-tabs/client.js +0 -2
  85. package/dist/ui/operation/usage-tabs/index.js +0 -2
  86. package/dist/ui/schema/client.d.ts +1 -2
  87. package/dist/ui/schema/client.js +0 -2
  88. package/dist/ui/schema/index.d.ts +3 -4
  89. package/dist/ui/schema/index.js +1 -3
  90. package/dist/utils/deep-equal.js +8 -6
  91. package/dist/utils/document/dereference.d.ts +17 -0
  92. package/dist/utils/document/dereference.js +19 -0
  93. package/dist/utils/document/process.d.ts +6 -0
  94. package/dist/utils/{process-document.js → document/process.js} +4 -19
  95. package/dist/utils/id-to-title.js +0 -2
  96. package/dist/utils/is-plain-object.js +8 -0
  97. package/dist/utils/pages/builder.d.ts +5 -6
  98. package/dist/utils/pages/builder.js +0 -2
  99. package/dist/utils/pages/preset-auto.d.ts +3 -4
  100. package/dist/utils/pages/preset-auto.js +0 -2
  101. package/dist/utils/pages/to-static-data.js +0 -2
  102. package/dist/utils/pages/to-text.d.ts +1 -2
  103. package/dist/utils/pages/to-text.js +0 -2
  104. package/dist/utils/remove-undefined.js +10 -10
  105. package/dist/utils/schema/dereference.js +22 -14
  106. package/dist/utils/schema/index.d.ts +7 -7
  107. package/dist/utils/schema/index.js +21 -4
  108. package/dist/utils/{merge-schema.js → schema/merge.js} +2 -4
  109. package/dist/utils/schema/pick.js +44 -0
  110. package/dist/utils/schema/ref.js +35 -0
  111. package/dist/utils/schema/resolve-ref.js +4 -14
  112. package/dist/utils/schema/to-string.js +4 -7
  113. package/dist/utils/url.js +0 -2
  114. package/dist/utils/use-query.js +0 -2
  115. package/package.json +3 -4
  116. package/dist/_openapi/types.d.ts.map +0 -1
  117. package/dist/generate-file.d.ts.map +0 -1
  118. package/dist/generate-file.js.map +0 -1
  119. package/dist/i18n.d.ts.map +0 -1
  120. package/dist/i18n.js.map +0 -1
  121. package/dist/playground/client.d.ts.map +0 -1
  122. package/dist/playground/client.js.map +0 -1
  123. package/dist/playground/components/inputs.js.map +0 -1
  124. package/dist/playground/components/oauth-dialog.js.map +0 -1
  125. package/dist/playground/components/server-select.js.map +0 -1
  126. package/dist/playground/fetcher.d.ts.map +0 -1
  127. package/dist/playground/fetcher.js.map +0 -1
  128. package/dist/playground/index.d.ts +0 -22
  129. package/dist/playground/index.d.ts.map +0 -1
  130. package/dist/playground/index.js +0 -118
  131. package/dist/playground/index.js.map +0 -1
  132. package/dist/playground/schema.d.ts.map +0 -1
  133. package/dist/playground/schema.js.map +0 -1
  134. package/dist/playground/status-info.js.map +0 -1
  135. package/dist/requests/generators/all.d.ts.map +0 -1
  136. package/dist/requests/generators/all.js.map +0 -1
  137. package/dist/requests/generators/csharp.d.ts.map +0 -1
  138. package/dist/requests/generators/csharp.js.map +0 -1
  139. package/dist/requests/generators/curl.d.ts.map +0 -1
  140. package/dist/requests/generators/curl.js.map +0 -1
  141. package/dist/requests/generators/go.d.ts.map +0 -1
  142. package/dist/requests/generators/go.js.map +0 -1
  143. package/dist/requests/generators/index.d.ts.map +0 -1
  144. package/dist/requests/generators/index.js.map +0 -1
  145. package/dist/requests/generators/java.d.ts.map +0 -1
  146. package/dist/requests/generators/java.js.map +0 -1
  147. package/dist/requests/generators/javascript.d.ts.map +0 -1
  148. package/dist/requests/generators/javascript.js.map +0 -1
  149. package/dist/requests/generators/python.d.ts.map +0 -1
  150. package/dist/requests/generators/python.js.map +0 -1
  151. package/dist/requests/media/adapter.d.ts.map +0 -1
  152. package/dist/requests/media/adapter.js.map +0 -1
  153. package/dist/requests/media/encode.d.ts.map +0 -1
  154. package/dist/requests/media/encode.js.map +0 -1
  155. package/dist/requests/media/resolve-adapter.js.map +0 -1
  156. package/dist/requests/string-utils.js.map +0 -1
  157. package/dist/requests/types.d.ts.map +0 -1
  158. package/dist/scalar/client.js.map +0 -1
  159. package/dist/scalar/index.d.ts.map +0 -1
  160. package/dist/scalar/index.js.map +0 -1
  161. package/dist/server/create.d.ts.map +0 -1
  162. package/dist/server/create.js.map +0 -1
  163. package/dist/server/proxy.d.ts.map +0 -1
  164. package/dist/server/proxy.js.map +0 -1
  165. package/dist/server/source-api.d.ts.map +0 -1
  166. package/dist/server/source-api.js.map +0 -1
  167. package/dist/types.d.ts.map +0 -1
  168. package/dist/ui/api-page.d.ts.map +0 -1
  169. package/dist/ui/api-page.js.map +0 -1
  170. package/dist/ui/base.d.ts.map +0 -1
  171. package/dist/ui/base.js.map +0 -1
  172. package/dist/ui/client/boundary.d.ts.map +0 -1
  173. package/dist/ui/client/boundary.js.map +0 -1
  174. package/dist/ui/client/boundary.lazy.js.map +0 -1
  175. package/dist/ui/client/full.js.map +0 -1
  176. package/dist/ui/client/i18n.js.map +0 -1
  177. package/dist/ui/client/index.d.ts.map +0 -1
  178. package/dist/ui/client/index.js.map +0 -1
  179. package/dist/ui/client/storage-key.js.map +0 -1
  180. package/dist/ui/components/accordion.js.map +0 -1
  181. package/dist/ui/components/codeblock.d.ts.map +0 -1
  182. package/dist/ui/components/codeblock.js.map +0 -1
  183. package/dist/ui/components/dialog.js.map +0 -1
  184. package/dist/ui/components/input.js.map +0 -1
  185. package/dist/ui/components/method-label.js.map +0 -1
  186. package/dist/ui/components/select-tab.js.map +0 -1
  187. package/dist/ui/components/select.js.map +0 -1
  188. package/dist/ui/contexts/api.d.ts.map +0 -1
  189. package/dist/ui/contexts/api.js.map +0 -1
  190. package/dist/ui/create-client.d.ts.map +0 -1
  191. package/dist/ui/create-client.js.map +0 -1
  192. package/dist/ui/index.d.ts.map +0 -1
  193. package/dist/ui/index.js.map +0 -1
  194. package/dist/ui/operation/client.js.map +0 -1
  195. package/dist/ui/operation/get-example-requests.d.ts.map +0 -1
  196. package/dist/ui/operation/get-example-requests.js.map +0 -1
  197. package/dist/ui/operation/index.js.map +0 -1
  198. package/dist/ui/operation/request-tabs.js.map +0 -1
  199. package/dist/ui/operation/response-tabs.d.ts.map +0 -1
  200. package/dist/ui/operation/response-tabs.js.map +0 -1
  201. package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
  202. package/dist/ui/operation/usage-tabs/client.js.map +0 -1
  203. package/dist/ui/operation/usage-tabs/index.js.map +0 -1
  204. package/dist/ui/schema/client.d.ts.map +0 -1
  205. package/dist/ui/schema/client.js.map +0 -1
  206. package/dist/ui/schema/index.d.ts.map +0 -1
  207. package/dist/ui/schema/index.js.map +0 -1
  208. package/dist/utils/deep-equal.js.map +0 -1
  209. package/dist/utils/id-to-title.js.map +0 -1
  210. package/dist/utils/merge-schema.js.map +0 -1
  211. package/dist/utils/pages/builder.d.ts.map +0 -1
  212. package/dist/utils/pages/builder.js.map +0 -1
  213. package/dist/utils/pages/preset-auto.d.ts.map +0 -1
  214. package/dist/utils/pages/preset-auto.js.map +0 -1
  215. package/dist/utils/pages/to-static-data.js.map +0 -1
  216. package/dist/utils/pages/to-text.d.ts.map +0 -1
  217. package/dist/utils/pages/to-text.js.map +0 -1
  218. package/dist/utils/process-document.d.ts +0 -18
  219. package/dist/utils/process-document.d.ts.map +0 -1
  220. package/dist/utils/process-document.js.map +0 -1
  221. package/dist/utils/remove-undefined.js.map +0 -1
  222. package/dist/utils/schema/dereference.js.map +0 -1
  223. package/dist/utils/schema/index.d.ts.map +0 -1
  224. package/dist/utils/schema/index.js.map +0 -1
  225. package/dist/utils/schema/resolve-ref.js.map +0 -1
  226. package/dist/utils/schema/to-string.js.map +0 -1
  227. package/dist/utils/url.js.map +0 -1
  228. package/dist/utils/use-query.js.map +0 -1
@@ -97,7 +97,6 @@
97
97
  @source inline("binary");
98
98
  @source inline("blue");
99
99
  @source inline("body");
100
- @source inline("bodyContent");
101
100
  @source inline("bodyMediaType");
102
101
  @source inline("bodyNode");
103
102
  @source inline("bodyOfType");
@@ -171,7 +170,6 @@
171
170
  @source inline("cookies");
172
171
  @source inline("core");
173
172
  @source inline("could");
174
- @source inline("count");
175
173
  @source inline("createAutoPreset");
176
174
  @source inline("createContext");
177
175
  @source inline("createMethod");
@@ -220,8 +218,9 @@
220
218
  @source inline("definitions");
221
219
  @source inline("deprecated");
222
220
  @source inline("depth");
223
- @source inline("dereferenceMap");
224
- @source inline("dereferenceSync");
221
+ @source inline("dereference");
222
+ @source inline("dereferenceDocument");
223
+ @source inline("dereferenceSwallow");
225
224
  @source inline("dereferenced");
226
225
  @source inline("description");
227
226
  @source inline("descriptionNode");
@@ -237,6 +236,7 @@
237
236
  @source inline("div");
238
237
  @source inline("divide-fd-border");
239
238
  @source inline("divide-y");
239
+ @source inline("doc");
240
240
  @source inline("document");
241
241
  @source inline("doesn");
242
242
  @source inline("domain");
@@ -250,6 +250,7 @@
250
250
  @source inline("empty");
251
251
  @source inline("empty:hidden");
252
252
  @source inline("enabled");
253
+ @source inline("encodeInternalRef");
253
254
  @source inline("encodeRequestData");
254
255
  @source inline("encoded");
255
256
  @source inline("end-2");
@@ -354,6 +355,7 @@
354
355
  @source inline("generated");
355
356
  @source inline("generated/defined");
356
357
  @source inline("generators");
358
+ @source inline("get");
357
359
  @source inline("getAPIPageProps");
358
360
  @source inline("getClientAPIPageProps");
359
361
  @source inline("getExampleRequests");
@@ -449,10 +451,8 @@
449
451
  @source inline("j");
450
452
  @source inline("json");
451
453
  @source inline("json-schema-typed");
452
- @source inline("json-schema-typed/draft-2020-12");
453
454
  @source inline("justify-between");
454
455
  @source inline("justify-center");
455
- @source inline("k");
456
456
  @source inline("key");
457
457
  @source inline("keyof");
458
458
  @source inline("kind");
@@ -500,7 +500,6 @@
500
500
  @source inline("mediaType");
501
501
  @source inline("merge");
502
502
  @source inline("mergeAllOf");
503
- @source inline("merged");
504
503
  @source inline("message");
505
504
  @source inline("meta");
506
505
  @source inline("metaData");
@@ -588,7 +587,6 @@
588
587
  @source inline("out");
589
588
  @source inline("outline");
590
589
  @source inline("outline-none");
591
- @source inline("output");
592
590
  @source inline("overflow-auto");
593
591
  @source inline("overflow-hidden");
594
592
  @source inline("overrides");
@@ -609,11 +607,11 @@
609
607
  @source inline("parameters");
610
608
  @source inline("params");
611
609
  @source inline("parent");
610
+ @source inline("parseSecurities");
612
611
  @source inline("parsed");
613
612
  @source inline("parsedState");
614
613
  @source inline("parts");
615
614
  @source inline("pass");
616
- @source inline("passed");
617
615
  @source inline("password");
618
616
  @source inline("path");
619
617
  @source inline("pathItem");
@@ -633,6 +631,7 @@
633
631
  @source inline("persist");
634
632
  @source inline("persistent");
635
633
  @source inline("pickExample");
634
+ @source inline("pickSchema");
636
635
  @source inline("place");
637
636
  @source inline("placeholder");
638
637
  @source inline("placeholder:text-fd-muted-foreground");
@@ -681,7 +680,6 @@
681
680
  @source inline("query");
682
681
  @source inline("queryParameters");
683
682
  @source inline("quiet");
684
- @source inline("r");
685
683
  @source inline("race");
686
684
  @source inline("range");
687
685
  @source inline("raw");
@@ -698,10 +696,8 @@
698
696
  @source inline("ref");
699
697
  @source inline("refCallback");
700
698
  @source inline("reference");
701
- @source inline("references");
702
699
  @source inline("refs");
703
700
  @source inline("registerDefault");
704
- @source inline("registered");
705
701
  @source inline("registry");
706
702
  @source inline("rehype-react");
707
703
  @source inline("relativePath");
@@ -743,9 +739,7 @@
743
739
  @source inline("res");
744
740
  @source inline("reset");
745
741
  @source inline("resize-none");
746
- @source inline("resolve");
747
742
  @source inline("resolveMediaAdapter");
748
- @source inline("resolveRefSync");
749
743
  @source inline("resolveRequestData");
750
744
  @source inline("resolved");
751
745
  @source inline("resolvedTheme");
@@ -874,7 +868,6 @@
874
868
  @source inline("so");
875
869
  @source inline("spec");
876
870
  @source inline("specify");
877
- @source inline("stack");
878
871
  @source inline("state");
879
872
  @source inline("status");
880
873
  @source inline("statusBadRequest");
@@ -909,7 +902,6 @@
909
902
  @source inline("tab");
910
903
  @source inline("tabs");
911
904
  @source inline("tag");
912
- @source inline("takenIds");
913
905
  @source inline("testQuery");
914
906
  @source inline("text");
915
907
  @source inline("text-[0.8125rem]");
@@ -1031,7 +1023,6 @@
1031
1023
  @source inline("variables");
1032
1024
  @source inline("variant");
1033
1025
  @source inline("variants");
1034
- @source inline("ve");
1035
1026
  @source inline("via");
1036
1027
  @source inline("virtual");
1037
1028
  @source inline("vite-rsc");
@@ -877,5 +877,4 @@ type IJsonSchema = {
877
877
  $ref?: string;
878
878
  };
879
879
  //#endregion
880
- export { OpenAPIV3, OpenAPIV3_2 };
881
- //# sourceMappingURL=types.d.ts.map
880
+ export { OpenAPIV3, OpenAPIV3_2 };
@@ -2,7 +2,7 @@ import { OpenAPIServer } from "./server/create.js";
2
2
  import { OutputEntry } from "./utils/pages/builder.js";
3
3
  import { SchemaToPagesOptions } from "./utils/pages/preset-auto.js";
4
4
  import { DistributiveOmit } from "./types.js";
5
- import { ProcessedDocument } from "./utils/process-document.js";
5
+ import { DereferencedDocument } from "./utils/document/dereference.js";
6
6
  import { PagesToTextOptions } from "./utils/pages/to-text.js";
7
7
 
8
8
  //#region src/generate-file.d.ts
@@ -73,10 +73,9 @@ type Config = SchemaToPagesOptions & GenerateFilesConfig & {
73
73
  interface BeforeWriteContext {
74
74
  readonly generated: Record<string, OutputFile[]>;
75
75
  readonly generatedEntries: Record<string, OutputEntry[]>;
76
- readonly documents: Record<string, ProcessedDocument>;
76
+ readonly documents: Record<string, DereferencedDocument>;
77
77
  }
78
78
  declare function generateFiles(options: Config): Promise<void>;
79
79
  declare function generateFilesOnly(options: DistributiveOmit<Config, 'output'>): Promise<OutputFile[]>;
80
80
  //#endregion
81
- export { Config, OutputFile, generateFiles, generateFilesOnly };
82
- //# sourceMappingURL=generate-file.d.ts.map
81
+ export { Config, OutputFile, generateFiles, generateFilesOnly };
@@ -133,5 +133,3 @@ function writeIndexFiles(context, options) {
133
133
  }
134
134
  //#endregion
135
135
  export { generateFiles, generateFilesOnly };
136
-
137
- //# sourceMappingURL=generate-file.js.map
package/dist/i18n.d.ts CHANGED
@@ -96,5 +96,4 @@ declare const defaultTranslations: {
96
96
  type Translations = typeof defaultTranslations;
97
97
  declare function defineI18nOpenAPI<Languages extends string>(config: I18nUIConfig<Languages>, translations: Partial<Record<NoInfer<Languages>, Partial<Translations>>>): I18nUIConfig<Languages>;
98
98
  //#endregion
99
- export { Translations, defaultTranslations, defineI18nOpenAPI };
100
- //# sourceMappingURL=i18n.d.ts.map
99
+ export { Translations, defaultTranslations, defineI18nOpenAPI };
package/dist/i18n.js CHANGED
@@ -109,5 +109,3 @@ function defineI18nOpenAPI(config, translations) {
109
109
  }
110
110
  //#endregion
111
111
  export { defaultTranslations, defineI18nOpenAPI };
112
-
113
- //# sourceMappingURL=i18n.js.map
@@ -1,8 +1,7 @@
1
1
  import { BrowserFetcherOptions, FetchResult } from "./fetcher.js";
2
- import { SecurityEntry } from "./index.js";
3
- import { ParsedSchema } from "../utils/schema/index.js";
4
2
  import { SchemaScope } from "./schema.js";
5
- import { ParameterObject } from "../types.js";
3
+ import { Document, HttpMethods, ParameterObject } from "../types.js";
4
+ import { ParsedSchema, SecurityEntry } from "../utils/schema/index.js";
6
5
  import { ComponentProps, FC, ReactNode } from "react";
7
6
  import * as _$react_jsx_runtime0 from "react/jsx-runtime";
8
7
  import { Collapsible } from "fumadocs-ui/components/ui/collapsible";
@@ -18,17 +17,10 @@ interface FormValues extends Record<string, unknown> {
18
17
  }
19
18
  interface PlaygroundClientProps extends ComponentProps<'form'>, SchemaScope {
20
19
  route: string;
21
- method: string;
22
- parameters?: ParameterObject[];
20
+ method: HttpMethods;
23
21
  securities: SecurityEntry[][];
24
- body?: {
25
- schema: ParsedSchema;
26
- mediaType: string;
27
- };
28
- /**
29
- * Resolver for $ref schemas you've passed
30
- */
31
- references: Record<string, ParsedSchema>;
22
+ /** the OpenAPI document (not dereferenced) */
23
+ doc: Document;
32
24
  proxyUrl?: string;
33
25
  }
34
26
  interface ResultDisplayProps extends ComponentProps<'div'> {
@@ -68,18 +60,17 @@ interface PlaygroundClientOptions {
68
60
  *
69
61
  * @see renderParameterField for customisation tips
70
62
  */
71
- renderBodyField?: (fieldName: 'body', info: {
72
- schema: ParsedSchema;
73
- mediaType: string;
74
- }) => ReactNode;
63
+ renderBodyField?: (fieldName: 'body', info: RequestBodyInfo) => ReactNode;
64
+ }
65
+ interface RequestBodyInfo {
66
+ schema: ParsedSchema;
67
+ mediaType: string;
75
68
  }
76
69
  declare function PlaygroundClient({
77
70
  route,
78
71
  method,
79
72
  securities,
80
- parameters,
81
- body,
82
- references,
73
+ doc,
83
74
  proxyUrl,
84
75
  writeOnly,
85
76
  readOnly,
@@ -113,5 +104,4 @@ declare const Custom: {
113
104
  };
114
105
  };
115
106
  //#endregion
116
- export { AuthField, CollapsiblePanelProps, Custom, DefaultCollapsiblePanel, DefaultResultDisplay, FormValues, PlaygroundClientOptions, PlaygroundClientProps, ResultDisplayProps, PlaygroundClient as default };
117
- //# sourceMappingURL=client.d.ts.map
107
+ export { AuthField, CollapsiblePanelProps, Custom, DefaultCollapsiblePanel, DefaultResultDisplay, FormValues, PlaygroundClientOptions, PlaygroundClientProps, ResultDisplayProps, PlaygroundClient as default };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { joinURL, resolveRequestData, resolveServerUrl, withBase } from "../utils/url.js";
3
+ import { getPreferredType } from "../utils/schema/index.js";
3
4
  import { useStorageKey } from "../ui/client/storage-key.js";
4
5
  import { useApiContext, useServerContext } from "../ui/contexts/api.js";
5
6
  import { getStatusInfo } from "./status-info.js";
@@ -7,6 +8,7 @@ import { cn } from "../utils/cn.js";
7
8
  import { MethodLabel } from "../ui/components/method-label.js";
8
9
  import { useQuery } from "../utils/use-query.js";
9
10
  import { encodeRequestData } from "../requests/media/encode.js";
11
+ import { dereferenceSwallow } from "../utils/schema/dereference.js";
10
12
  import { SchemaProvider, anyFields, useResolvedSchema } from "./schema.js";
11
13
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/components/select.js";
12
14
  import { labelVariants } from "../ui/components/input.js";
@@ -24,12 +26,33 @@ import { buttonVariants } from "fumadocs-ui/components/ui/button";
24
26
  import { StfProvider, useDataEngine, useFieldValue, useListener, useStf } from "@fumari/stf";
25
27
  import { objectGet, objectSet, stringifyFieldKey } from "@fumari/stf/lib/utils";
26
28
  //#region src/playground/client.tsx
27
- function PlaygroundClient({ route, method = "GET", securities, parameters = [], body, references, proxyUrl, writeOnly, readOnly, ...rest }) {
29
+ function PlaygroundClient({ route, method, securities, doc, proxyUrl, writeOnly, readOnly, ...rest }) {
28
30
  const t = useTranslations();
31
+ const { parameters, body } = useMemo(() => {
32
+ const operation = doc.paths[route][method];
33
+ const parameters = operation.parameters?.map((param) => dereferenceSwallow(param, doc)) ?? [];
34
+ let body;
35
+ if (operation.requestBody) {
36
+ const content = dereferenceSwallow(operation.requestBody, doc).content;
37
+ const mediaType = content ? getPreferredType(content) : void 0;
38
+ if (content && mediaType) body = {
39
+ mediaType,
40
+ schema: dereferenceSwallow(content[mediaType], doc).schema ?? true
41
+ };
42
+ }
43
+ return {
44
+ body,
45
+ parameters
46
+ };
47
+ }, [
48
+ doc,
49
+ route,
50
+ method
51
+ ]);
29
52
  const { example: exampleId, examples, setExampleData } = useOperationContext();
30
53
  const { server } = useServerContext();
31
54
  const storageKeys = useStorageKey();
32
- const { mediaAdapters, client: { playground: { components: { ResultDisplay = DefaultResultDisplay } = {}, requestTimeout, fetchOptions = { requestTimeout }, transformAuthInputs } = {} } } = useApiContext();
55
+ const { mediaAdapters, client: { playground: { components: { ResultDisplay = DefaultResultDisplay, CollapsiblePanel = DefaultCollapsiblePanel } = {}, requestTimeout, fetchOptions = { requestTimeout }, transformAuthInputs, renderBodyField } = {} } } = useApiContext();
33
56
  const [securityId, setSecurityId] = useState(() => {
34
57
  const idx = securities.findIndex((s) => s.every((entry) => !entry.deprecated));
35
58
  return idx === -1 ? 0 : idx;
@@ -88,7 +111,7 @@ function PlaygroundClient({ route, method = "GET", securities, parameters = [],
88
111
  return /* @__PURE__ */ jsx(StfProvider, {
89
112
  value: stf,
90
113
  children: /* @__PURE__ */ jsx(SchemaProvider, {
91
- references,
114
+ doc,
92
115
  writeOnly,
93
116
  readOnly,
94
117
  children: /* @__PURE__ */ jsxs("form", {
@@ -129,9 +152,11 @@ function PlaygroundClient({ route, method = "GET", securities, parameters = [],
129
152
  setSecurityId,
130
153
  children: inputs.map((input) => /* @__PURE__ */ jsx(Fragment, { children: input.children }, stringifyFieldKey(input.fieldName)))
131
154
  }),
132
- /* @__PURE__ */ jsx(FormBody, {
133
- body,
134
- parameters
155
+ /* @__PURE__ */ jsx(ParametersForm, { parameters }),
156
+ body && /* @__PURE__ */ jsx(CollapsiblePanel, {
157
+ "data-type": "body",
158
+ title: t.body,
159
+ children: renderBodyField ? renderBodyField("body", body) : /* @__PURE__ */ jsx(BodyInput, { field: body.schema })
135
160
  })
136
161
  ]
137
162
  })
@@ -189,7 +214,7 @@ const ParamTypes = [
189
214
  "cookie",
190
215
  "query"
191
216
  ];
192
- function FormBodyItem({ type, parameters }) {
217
+ function ParameterItem({ type, parameters }) {
193
218
  const { renderParameterField } = useApiContext().client.playground ?? {};
194
219
  return parameters.map((field) => {
195
220
  const fieldName = [type, field.name];
@@ -204,8 +229,8 @@ function FormBodyItem({ type, parameters }) {
204
229
  }, stringifyFieldKey(fieldName));
205
230
  });
206
231
  }
207
- function FormBody({ parameters = [], body }) {
208
- const { renderBodyField, components: { CollapsiblePanel = DefaultCollapsiblePanel } = {} } = useApiContext().client.playground ?? {};
232
+ function ParametersForm({ parameters }) {
233
+ const { components: { CollapsiblePanel = DefaultCollapsiblePanel } = {} } = useApiContext().client.playground ?? {};
209
234
  const t = useTranslations();
210
235
  const displayNames = {
211
236
  header: t.header,
@@ -213,22 +238,18 @@ function FormBody({ parameters = [], body }) {
213
238
  query: t.query,
214
239
  path: t.path
215
240
  };
216
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [ParamTypes.map((type) => {
241
+ return ParamTypes.map((type) => {
217
242
  const items = parameters.filter((v) => v.in === type);
218
243
  if (items.length === 0) return;
219
244
  return /* @__PURE__ */ jsx(CollapsiblePanel, {
220
245
  "data-type": type,
221
246
  title: displayNames[type],
222
- children: /* @__PURE__ */ jsx(FormBodyItem, {
247
+ children: /* @__PURE__ */ jsx(ParameterItem, {
223
248
  parameters: items,
224
249
  type
225
250
  })
226
251
  }, type);
227
- }), body && /* @__PURE__ */ jsx(CollapsiblePanel, {
228
- "data-type": "body",
229
- title: t.body,
230
- children: renderBodyField ? renderBodyField("body", body) : /* @__PURE__ */ jsx(BodyInput, { field: body.schema })
231
- })] });
252
+ });
232
253
  }
233
254
  function BodyInput({ field: _field }) {
234
255
  const field = useResolvedSchema(_field);
@@ -476,5 +497,3 @@ const Custom = { useController(fieldName, options) {
476
497
  } };
477
498
  //#endregion
478
499
  export { Custom, DefaultCollapsiblePanel, DefaultResultDisplay, PlaygroundClient as default };
479
-
480
- //# sourceMappingURL=client.js.map
@@ -418,5 +418,3 @@ function ArrayInput({ fieldName, items: itemSchema, ...props }) {
418
418
  }
419
419
  //#endregion
420
420
  export { FieldInput, FieldSet, JsonInput, ObjectInput };
421
-
422
- //# sourceMappingURL=inputs.js.map
@@ -281,5 +281,3 @@ function OauthDialog({ scheme, scopes, setToken, children, open, setOpen }) {
281
281
  const OauthDialogTrigger = DialogTrigger;
282
282
  //#endregion
283
283
  export { OauthDialog, OauthDialogTrigger };
284
-
285
- //# sourceMappingURL=oauth-dialog.js.map
@@ -124,5 +124,3 @@ function Field({ fieldName, variable }) {
124
124
  }
125
125
  //#endregion
126
126
  export { ServerSelect as default };
127
-
128
- //# sourceMappingURL=server-select.js.map
@@ -24,5 +24,4 @@ interface BrowserFetcherOptions {
24
24
  onRequestInit?: (requestInit: RequestInit) => Awaitable<RequestInit>;
25
25
  }
26
26
  //#endregion
27
- export { BrowserFetcherOptions, FetchResult };
28
- //# sourceMappingURL=fetcher.d.ts.map
27
+ export { BrowserFetcherOptions, FetchResult };
@@ -67,5 +67,3 @@ function createBrowserFetcher(adapters, { proxyUrl, proxyForwardCookie = true, r
67
67
  }
68
68
  //#endregion
69
69
  export { createBrowserFetcher };
70
-
71
- //# sourceMappingURL=fetcher.js.map
@@ -14,5 +14,4 @@ interface SchemaScope {
14
14
  readOnly: boolean;
15
15
  }
16
16
  //#endregion
17
- export { SchemaScope };
18
- //# sourceMappingURL=schema.d.ts.map
17
+ export { SchemaScope };
@@ -1,6 +1,6 @@
1
- import { mergeAllOf } from "../utils/merge-schema.js";
1
+ import { mergeAllOf } from "../utils/schema/merge.js";
2
2
  import { schemaToString } from "../utils/schema/to-string.js";
3
- import { resolveRefSync } from "../utils/schema/resolve-ref.js";
3
+ import { dereferenceSwallow } from "../utils/schema/dereference.js";
4
4
  import { createContext, use, useMemo } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  import { Ajv2020 } from "ajv/dist/2020.js";
@@ -20,7 +20,7 @@ const anyFields = {
20
20
  items: true,
21
21
  additionalProperties: true
22
22
  };
23
- function SchemaProvider({ references, readOnly, writeOnly, children }) {
23
+ function SchemaProvider({ doc, readOnly, writeOnly, children }) {
24
24
  const ajv = useMemo(() => new Ajv2020({
25
25
  strict: false,
26
26
  validateSchema: false,
@@ -28,12 +28,12 @@ function SchemaProvider({ references, readOnly, writeOnly, children }) {
28
28
  }), []);
29
29
  return /* @__PURE__ */ jsx(SchemaContext.Provider, {
30
30
  value: useMemo(() => ({
31
- references,
31
+ doc,
32
32
  ajv,
33
33
  readOnly,
34
34
  writeOnly
35
35
  }), [
36
- references,
36
+ doc,
37
37
  ajv,
38
38
  readOnly,
39
39
  writeOnly
@@ -52,7 +52,7 @@ function useSchemaScope() {
52
52
  * @param depth - The depth to avoid duplicated field name with same schema (e.g. nested `oneOf`).
53
53
  */
54
54
  function useFieldInfo(fieldName, schema, depth = 0) {
55
- const { ajv, references } = use(SchemaContext);
55
+ const { ajv, doc } = use(SchemaContext);
56
56
  const engine = useDataEngine();
57
57
  const { generateDefault } = useSchemaUtils();
58
58
  const [info, setInfo] = useFieldValue([], { stf: useNamespace({
@@ -63,10 +63,10 @@ function useFieldInfo(fieldName, schema, depth = 0) {
63
63
  const union = getUnion(schema);
64
64
  if (union) {
65
65
  const [members, field] = union;
66
- out.oneOf = members.findIndex((item) => ajv.validate(typeof item === "object" ? {
67
- ...item,
68
- ...references
69
- } : item, value));
66
+ out.oneOf = members.findIndex((item) => typeof item === "object" && ajv.validate({
67
+ ...doc,
68
+ ...item
69
+ }, value));
70
70
  if (out.oneOf === -1) out.oneOf = 0;
71
71
  out.unionField = field;
72
72
  }
@@ -74,8 +74,8 @@ function useFieldInfo(fieldName, schema, depth = 0) {
74
74
  const types = schema.type;
75
75
  out.selectedType = types.find((type) => {
76
76
  return ajv.validate({
77
+ ...doc,
77
78
  ...schema,
78
- ...references,
79
79
  type
80
80
  }, value);
81
81
  }) ?? types[0];
@@ -105,45 +105,35 @@ function useFieldInfo(fieldName, schema, depth = 0) {
105
105
  };
106
106
  }
107
107
  function useSchemaUtils() {
108
- const { references } = use(SchemaContext);
108
+ const { doc, readOnly } = use(SchemaContext);
109
109
  return {
110
110
  generateDefault(schema) {
111
111
  return sample(schema, {
112
112
  skipNonRequired: true,
113
- skipReadOnly: true,
113
+ skipReadOnly: !readOnly,
114
114
  quiet: true
115
- }, references);
115
+ }, doc);
116
116
  },
117
117
  schemaToString(value, flags) {
118
- return schemaToString(value, (s) => ({
119
- dereferenced: dereference(s, references),
120
- raw: s
118
+ return schemaToString(value, (raw) => ({
119
+ raw,
120
+ dereferenced: dereferenceSwallow(raw, doc)
121
121
  }), flags);
122
122
  }
123
123
  };
124
124
  }
125
125
  /**
126
- * resolve $ref & merge `allOf`.
126
+ * dereference & merge `allOf`.
127
127
  */
128
128
  function useResolvedSchema(raw) {
129
- const { references } = use(SchemaContext);
129
+ const { doc } = use(SchemaContext);
130
130
  return useMemo(() => {
131
- const schema = dereference(raw, references);
132
- if (typeof schema === "boolean") return anyFields;
133
- if (schema.allOf) {
134
- const merged = mergeAllOf(schema, { dereference(schema) {
135
- return dereference(schema, references);
136
- } });
137
- if (typeof merged === "boolean") return anyFields;
138
- return merged;
139
- }
140
- return schema;
141
- }, [raw, references]);
142
- }
143
- function dereference(schema, references) {
144
- if (typeof schema === "boolean") return schema;
145
- if (schema.$ref) return resolveRefSync(schema.$ref, references);
146
- return schema;
131
+ let out = dereferenceSwallow(raw, doc);
132
+ if (typeof out === "object" && out.allOf) out = mergeAllOf(out, { dereference(schema) {
133
+ return dereferenceSwallow(schema, doc);
134
+ } });
135
+ return typeof out === "boolean" ? anyFields : out;
136
+ }, [doc, raw]);
147
137
  }
148
138
  function getUnion(schema) {
149
139
  if (schema.anyOf) return [schema.anyOf, "anyOf"];
@@ -151,5 +141,3 @@ function getUnion(schema) {
151
141
  }
152
142
  //#endregion
153
143
  export { SchemaProvider, anyFields, useFieldInfo, useResolvedSchema, useSchemaScope, useSchemaUtils };
154
-
155
- //# sourceMappingURL=schema.js.map
@@ -54,5 +54,3 @@ function getStatusInfo(status, t) {
54
54
  }
55
55
  //#endregion
56
56
  export { getStatusInfo };
57
-
58
- //# sourceMappingURL=status-info.js.map
@@ -3,5 +3,4 @@ import { CodeUsageGeneratorRegistry } from "./index.js";
3
3
  //#region src/requests/generators/all.d.ts
4
4
  declare function registerDefault(registry: CodeUsageGeneratorRegistry): void;
5
5
  //#endregion
6
- export { registerDefault };
7
- //# sourceMappingURL=all.d.ts.map
6
+ export { registerDefault };
@@ -15,5 +15,3 @@ function registerDefault(registry) {
15
15
  }
16
16
  //#endregion
17
17
  export { registerDefault };
18
-
19
- //# sourceMappingURL=all.js.map
@@ -3,5 +3,4 @@ import { CodeUsageGenerator } from "./index.js";
3
3
  //#region src/requests/generators/csharp.d.ts
4
4
  declare const csharp: CodeUsageGenerator;
5
5
  //#endregion
6
- export { csharp };
7
- //# sourceMappingURL=csharp.d.ts.map
6
+ export { csharp };
@@ -39,5 +39,3 @@ const csharp = {
39
39
  };
40
40
  //#endregion
41
41
  export { csharp };
42
-
43
- //# sourceMappingURL=csharp.js.map
@@ -3,5 +3,4 @@ import { CodeUsageGenerator } from "./index.js";
3
3
  //#region src/requests/generators/curl.d.ts
4
4
  declare const curl: CodeUsageGenerator;
5
5
  //#endregion
6
- export { curl };
7
- //# sourceMappingURL=curl.d.ts.map
6
+ export { curl };
@@ -27,5 +27,3 @@ const curl = {
27
27
  };
28
28
  //#endregion
29
29
  export { curl };
30
-
31
- //# sourceMappingURL=curl.js.map
@@ -3,5 +3,4 @@ import { CodeUsageGenerator } from "./index.js";
3
3
  //#region src/requests/generators/go.d.ts
4
4
  declare const go: CodeUsageGenerator;
5
5
  //#endregion
6
- export { go };
7
- //# sourceMappingURL=go.d.ts.map
6
+ export { go };
@@ -50,5 +50,3 @@ ${indent(Array.from(headers.entries()).map(([key, value]) => `req.Header.Add("${
50
50
  };
51
51
  //#endregion
52
52
  export { go };
53
-
54
- //# sourceMappingURL=go.js.map
@@ -52,5 +52,4 @@ type CodeUsageGeneratorFn<ServerContext = unknown> = (url: string, data: Request
52
52
  server: ServerContext;
53
53
  }) => string;
54
54
  //#endregion
55
- export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry };
56
- //# sourceMappingURL=index.d.ts.map
55
+ export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry };
@@ -37,5 +37,3 @@ function createCodeUsageGeneratorRegistry(inherit) {
37
37
  }
38
38
  //#endregion
39
39
  export { createCodeUsageGeneratorRegistry };
40
-
41
- //# sourceMappingURL=index.js.map
@@ -3,5 +3,4 @@ import { CodeUsageGenerator } from "./index.js";
3
3
  //#region src/requests/generators/java.d.ts
4
4
  declare const java: CodeUsageGenerator;
5
5
  //#endregion
6
- export { java };
7
- //# sourceMappingURL=java.d.ts.map
6
+ export { java };
@@ -55,5 +55,3 @@ const java = {
55
55
  };
56
56
  //#endregion
57
57
  export { java };
58
-
59
- //# sourceMappingURL=java.js.map