fumadocs-openapi 10.10.3 → 11.0.0

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 (234) hide show
  1. package/css/generated/shared.css +1 -1159
  2. package/css/preset.css +1 -0
  3. package/dist/.translations/index.d.ts +80 -0
  4. package/dist/.translations/keys.js +80 -0
  5. package/dist/_virtual/_rolldown/runtime.js +1 -10
  6. package/dist/generate-file.d.ts +0 -4
  7. package/dist/generate-file.js +4 -5
  8. package/dist/i18n.d.ts +5 -100
  9. package/dist/i18n.js +8 -108
  10. package/dist/index.d.ts +4 -4
  11. package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +1 -1
  12. package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +1 -1
  13. package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +1 -1
  14. package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +1 -1
  15. package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +1 -1
  16. package/dist/playground/auth.js +4 -4
  17. package/dist/playground/client.d.ts +12 -21
  18. package/dist/playground/client.js +80 -59
  19. package/dist/playground/components/oauth-dialog.js +33 -33
  20. package/dist/playground/components/result-display.d.ts +1 -2
  21. package/dist/playground/components/result-display.js +7 -8
  22. package/dist/playground/components/server-select.js +11 -11
  23. package/dist/playground/status-info.js +29 -37
  24. package/dist/requests/generators/csharp.js +3 -3
  25. package/dist/requests/generators/curl.js +2 -2
  26. package/dist/requests/generators/go.js +2 -2
  27. package/dist/requests/generators/index.d.ts +28 -41
  28. package/dist/requests/generators/index.js +18 -35
  29. package/dist/requests/generators/java.js +2 -2
  30. package/dist/requests/generators/javascript.js +2 -2
  31. package/dist/requests/generators/python.js +2 -2
  32. package/dist/scalar/client.js +3 -2
  33. package/dist/scalar/index.d.ts +2 -2
  34. package/dist/scalar/index.js +10 -9
  35. package/dist/server/index.d.ts +23 -27
  36. package/dist/server/index.js +42 -38
  37. package/dist/server/proxy.d.ts +0 -6
  38. package/dist/server/proxy.js +2 -4
  39. package/dist/{_openapi/types.d.ts → types/openapi.d.ts} +127 -136
  40. package/dist/types.d.ts +14 -18
  41. package/dist/ui/base.d.ts +15 -162
  42. package/dist/ui/base.js +148 -107
  43. package/dist/ui/components/codeblock.js +6 -14
  44. package/dist/ui/components/heading.js +8 -4
  45. package/dist/ui/components/markdown.js +12 -0
  46. package/dist/ui/contexts/api.js +8 -26
  47. package/dist/ui/index.d.ts +204 -7
  48. package/dist/ui/index.js +10 -15
  49. package/dist/ui/operation/context.js +48 -0
  50. package/dist/ui/operation/index.js +168 -126
  51. package/dist/ui/operation/request-tabs.d.ts +10 -5
  52. package/dist/ui/operation/request-tabs.js +35 -22
  53. package/dist/ui/operation/response-tabs.d.ts +5 -2
  54. package/dist/ui/operation/response-tabs.js +22 -15
  55. package/dist/ui/operation/usage-tabs.js +144 -0
  56. package/dist/utils/document/dereference.d.ts +1 -1
  57. package/dist/utils/document/dereference.js +5 -8
  58. package/dist/utils/document/load.js +17 -0
  59. package/dist/utils/get-example-requests.d.ts +13 -0
  60. package/dist/{ui/operation → utils}/get-example-requests.js +31 -20
  61. package/dist/utils/pages/builder.d.ts +38 -10
  62. package/dist/utils/pages/builder.js +12 -10
  63. package/dist/utils/pages/preset-auto.d.ts +1 -2
  64. package/dist/utils/pages/preset-auto.js +15 -15
  65. package/dist/utils/pages/to-static-data.js +5 -4
  66. package/dist/utils/pages/to-text.d.ts +1 -0
  67. package/dist/utils/pages/to-text.js +21 -11
  68. package/dist/utils/remove-undefined.js +14 -9
  69. package/dist/utils/schema.d.ts +2 -0
  70. package/dist/utils/{schema/index.js → schema.js} +3 -30
  71. package/dist/{ui/client → utils}/storage-key.js +3 -3
  72. package/package.json +15 -28
  73. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +0 -239
  74. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
  75. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
  76. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +0 -41
  77. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
  78. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +0 -109
  79. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
  80. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +0 -46
  81. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
  82. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +0 -49
  83. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +0 -242
  84. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +0 -247
  85. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +0 -210
  86. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +0 -100
  87. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +0 -41
  88. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -112
  89. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +0 -8
  90. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +0 -146
  91. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
  92. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +0 -18
  93. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +0 -11
  94. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +0 -99
  95. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +0 -30
  96. package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +0 -315
  97. package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +0 -108
  98. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +0 -110
  99. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +0 -138
  100. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +0 -674
  101. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +0 -141
  102. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +0 -102
  103. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +0 -223
  104. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +0 -28
  105. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +0 -18
  106. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +0 -133
  107. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +0 -61
  108. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +0 -146
  109. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +0 -23
  110. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -48
  111. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +0 -172
  112. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +0 -31
  113. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +0 -433
  114. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +0 -113
  115. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +0 -72
  116. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +0 -583
  117. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +0 -18
  118. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +0 -42
  119. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +0 -50
  120. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +0 -20
  121. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +0 -51
  122. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +0 -16
  123. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +0 -36
  124. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +0 -19
  125. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +0 -85
  126. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +0 -59
  127. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +0 -12
  128. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
  129. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +0 -12
  130. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +0 -16
  131. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -57
  132. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -96
  133. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -29
  134. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -16
  135. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -89
  136. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -87
  137. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +0 -16
  138. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -62
  139. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -60
  140. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -59
  141. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -34
  142. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -31
  143. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -51
  144. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -61
  145. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -17
  146. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -52
  147. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -41
  148. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -17
  149. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +0 -130
  150. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +0 -14
  151. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +0 -22
  152. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +0 -112
  153. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -101
  154. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -14
  155. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +0 -35
  156. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +0 -46
  157. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +0 -45
  158. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +0 -22
  159. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +0 -20
  160. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +0 -15
  161. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
  162. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +0 -10
  163. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +0 -23
  164. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +0 -19
  165. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +0 -13
  166. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +0 -46
  167. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +0 -59
  168. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +0 -27
  169. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +0 -17
  170. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -49
  171. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +0 -48
  172. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +0 -18
  173. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -28
  174. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
  175. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -47
  176. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -28
  177. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -27
  178. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -38
  179. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +0 -72
  180. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -70
  181. package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +0 -33
  182. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -236
  183. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -187
  184. package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -282
  185. package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +0 -78
  186. package/dist/playground/components/inputs.js +0 -419
  187. package/dist/playground/components/spinner.js +0 -15
  188. package/dist/playground/schema.d.ts +0 -15
  189. package/dist/playground/schema.js +0 -144
  190. package/dist/ui/api-page.d.ts +0 -31
  191. package/dist/ui/api-page.js +0 -59
  192. package/dist/ui/client/boundary.d.ts +0 -11
  193. package/dist/ui/client/boundary.js +0 -17
  194. package/dist/ui/client/boundary.lazy.js +0 -19
  195. package/dist/ui/client/full.js +0 -13
  196. package/dist/ui/client/i18n.js +0 -16
  197. package/dist/ui/client/index.d.ts +0 -42
  198. package/dist/ui/client/index.js +0 -7
  199. package/dist/ui/components/accordion.js +0 -67
  200. package/dist/ui/components/codeblock.d.ts +0 -14
  201. package/dist/ui/components/dialog.js +0 -56
  202. package/dist/ui/components/input.js +0 -17
  203. package/dist/ui/components/select-tab.js +0 -56
  204. package/dist/ui/components/select.js +0 -71
  205. package/dist/ui/contexts/api.d.ts +0 -29
  206. package/dist/ui/create-client.d.ts +0 -26
  207. package/dist/ui/create-client.js +0 -125
  208. package/dist/ui/operation/client.js +0 -78
  209. package/dist/ui/operation/get-example-requests.d.ts +0 -11
  210. package/dist/ui/operation/usage-tabs/client.d.ts +0 -14
  211. package/dist/ui/operation/usage-tabs/client.js +0 -91
  212. package/dist/ui/operation/usage-tabs/index.js +0 -54
  213. package/dist/ui/schema/client.d.ts +0 -18
  214. package/dist/ui/schema/client.js +0 -410
  215. package/dist/ui/schema/index.d.ts +0 -61
  216. package/dist/ui/schema/index.js +0 -256
  217. package/dist/utils/auto-anchor.client.js +0 -20
  218. package/dist/utils/auto-anchor.js +0 -17
  219. package/dist/utils/deep-equal.js +0 -21
  220. package/dist/utils/document/process.d.ts +0 -6
  221. package/dist/utils/document/process.js +0 -18
  222. package/dist/utils/id-to-title.js +0 -12
  223. package/dist/utils/is-plain-object.js +0 -8
  224. package/dist/utils/merge-refs.js +0 -11
  225. package/dist/utils/schema/dereference.js +0 -45
  226. package/dist/utils/schema/index.d.ts +0 -18
  227. package/dist/utils/schema/merge.js +0 -156
  228. package/dist/utils/schema/pick.js +0 -44
  229. package/dist/utils/schema/ref.js +0 -35
  230. package/dist/utils/schema/resolve-ref.js +0 -11
  231. package/dist/utils/schema/sample.js +0 -442
  232. package/dist/utils/schema/to-string.d.ts +0 -1
  233. package/dist/utils/schema/to-string.js +0 -53
  234. package/dist/utils/url.js +0 -39
@@ -1,52 +1,44 @@
1
- import { useTranslations } from "../ui/client/i18n.js";
2
1
  import { useMemo } from "react";
3
2
  import { CircleCheck, CircleX } from "lucide-react";
3
+ import { useTranslations } from "@fuma-translate/react";
4
4
  //#region src/playground/status-info.tsx
5
- const statusKeys = {
6
- 400: {
7
- key: "statusBadRequest",
8
- color: "text-red-500",
9
- icon: CircleX
10
- },
11
- 401: {
12
- key: "statusUnauthorized",
13
- color: "text-red-500",
14
- icon: CircleX
15
- },
16
- 403: {
17
- key: "statusForbidden",
18
- color: "text-red-500",
19
- icon: CircleX
20
- },
21
- 404: {
22
- key: "statusNotFound",
23
- color: "text-fd-muted-foreground",
24
- icon: CircleX
25
- },
26
- 500: {
27
- key: "statusInternalServerError",
28
- color: "text-red-500",
29
- icon: CircleX
30
- }
31
- };
32
5
  function useStatusInfo(status) {
33
- const t = useTranslations();
6
+ const t = useTranslations({ note: "playground status info" });
34
7
  return useMemo(() => {
35
- if (status in statusKeys) {
36
- const { key, color, icon } = statusKeys[status];
37
- return {
38
- description: t[key],
39
- color,
40
- icon
8
+ switch (status) {
9
+ case 400: return {
10
+ description: t("Bad Request"),
11
+ color: "text-red-500",
12
+ icon: CircleX
13
+ };
14
+ case 401: return {
15
+ description: t("Unauthorized"),
16
+ color: "text-red-500",
17
+ icon: CircleX
18
+ };
19
+ case 403: return {
20
+ description: t("Forbidden"),
21
+ color: "text-red-500",
22
+ icon: CircleX
23
+ };
24
+ case 404: return {
25
+ description: t("Not Found"),
26
+ color: "text-fd-muted-foreground",
27
+ icon: CircleX
28
+ };
29
+ case 500: return {
30
+ description: t("Internal Server Error"),
31
+ color: "text-red-500",
32
+ icon: CircleX
41
33
  };
42
34
  }
43
35
  if (status >= 200 && status < 300) return {
44
- description: t.statusSuccessful,
36
+ description: t("Successful"),
45
37
  color: "text-green-500",
46
38
  icon: CircleCheck
47
39
  };
48
40
  if (status >= 400) return {
49
- description: t.statusError,
41
+ description: t("Error"),
50
42
  color: "text-red-500",
51
43
  icon: CircleX
52
44
  };
@@ -5,7 +5,7 @@ import "../media/adapter.js";
5
5
  const csharp = {
6
6
  label: "C#",
7
7
  lang: "csharp",
8
- generate(url, data, { mediaAdapters }) {
8
+ generate(data, { mediaAdapters }) {
9
9
  const s = [];
10
10
  const imports = new Set([
11
11
  "System",
@@ -32,8 +32,8 @@ const csharp = {
32
32
  if (Object.keys(data.cookie).length > 0) addHeader("cookie", Object.entries(data.cookie).map(([key, param]) => `${key}=${param.value}`).join("; "));
33
33
  s.push(...headerLines);
34
34
  const method = data.method[0].toUpperCase() + data.method.slice(1).toLowerCase() + "Async";
35
- if (body) s.push(`var response = await client.${method}("${url}", body);`);
36
- else s.push(`var response = await client.${method}("${url}");`);
35
+ if (body) s.push(`var response = await client.${method}("${data.url}", body);`);
36
+ else s.push(`var response = await client.${method}("${data.url}");`);
37
37
  s.push("var responseBody = await response.Content.ReadAsStringAsync();");
38
38
  return s.join("\n");
39
39
  }
@@ -3,9 +3,9 @@ import { doubleQuote, indent, inputToString, singleQuote } from "../string-utils
3
3
  const curl = {
4
4
  label: "cURL",
5
5
  lang: "bash",
6
- generate(url, data) {
6
+ generate(data) {
7
7
  const s = [];
8
- s.push(`curl -X ${data.method.toUpperCase()} "${url}"`);
8
+ s.push(`curl -X ${data.method.toUpperCase()} "${data.url}"`);
9
9
  for (const header in data.header) {
10
10
  const value = `${header}: ${data.header[header].value}`;
11
11
  s.push(`-H "${value}"`);
@@ -5,7 +5,7 @@ import "../media/adapter.js";
5
5
  const go = {
6
6
  label: "Go",
7
7
  lang: "go",
8
- generate(url, data, { mediaAdapters }) {
8
+ generate(data, { mediaAdapters }) {
9
9
  const imports = [
10
10
  "fmt",
11
11
  "net/http",
@@ -13,7 +13,7 @@ const go = {
13
13
  ];
14
14
  const headers = /* @__PURE__ */ new Map();
15
15
  const variables = /* @__PURE__ */ new Map();
16
- variables.set("url", doubleQuote(url));
16
+ variables.set("url", doubleQuote(data.url));
17
17
  for (const header in data.header) headers.set(header, doubleQuote(data.header[header].value));
18
18
  const cookies = Object.entries(data.cookie);
19
19
  if (cookies.length > 0) headers.set("Cookie", doubleQuote(cookies.map(([k, param]) => `${k}=${param.value}`).join("; ")));
@@ -1,55 +1,42 @@
1
1
  import { MediaAdapter } from "../media/adapter.js";
2
2
  import { RequestData } from "../types.js";
3
+ import * as Shared from "@fumadocs/api-docs/codegen";
3
4
 
4
5
  //#region src/requests/generators/index.d.ts
5
- interface CodeUsageGeneratorRegistry {
6
- add: (id: string, generator: CodeUsageGenerator) => void;
7
- get: (id: string) => CodeUsageGenerator | undefined;
8
- addInline: (generator: InlineCodeUsageGenerator) => void;
9
- /**
10
- * @returns if the generator is removed
11
- */
12
- remove: (id: string) => boolean;
13
- map: () => Map<string, CodeUsageGenerator>;
14
- }
6
+ declare function pathnameFromRequest(pathname: string, {
7
+ path,
8
+ query
9
+ }: RequestData): string;
10
+ type CodeUsageGeneratorRegistry = Shared.CodeUsageGeneratorRegistry<RequestData & {
11
+ url: string;
12
+ }, {
13
+ mediaAdapters: Record<string, MediaAdapter>;
14
+ custom: unknown;
15
+ }>;
15
16
  /**
16
17
  * Generate code example for given programming language
17
18
  */
18
- interface CodeUsageGenerator {
19
- generate: CodeUsageGeneratorFn;
20
- lang: string;
21
- label?: string;
22
- /**
23
- * for inline generators passed from server, this stores info available for client (e.g. forwarded from "use client").
24
- */
25
- _client?: {
26
- generate: string | CodeUsageGeneratorFn;
27
- serverContext?: unknown;
28
- };
29
- }
19
+ type CodeUsageGenerator = Shared.CodeUsageGenerator<RequestData & {
20
+ url: string;
21
+ }, {
22
+ mediaAdapters: Record<string, MediaAdapter>;
23
+ custom: unknown;
24
+ }>;
30
25
  /**
31
26
  * Generate code example for given programming language
32
27
  */
33
- interface InlineCodeUsageGenerator<T = unknown> {
34
- id?: string;
35
- lang: string;
36
- label?: string;
37
- /**
38
- * either:
39
- * - code
40
- * - a function imported from a file with "use client" directive
41
- * - false (disabled)
42
- */
43
- source?: string | CodeUsageGeneratorFn<T> | false;
44
- /**
45
- * Pass extra context to client-side source generator
46
- */
47
- serverContext?: T;
48
- }
28
+ type InlineCodeUsageGenerator<T = unknown> = Shared.InlineCodeUsageGenerator<RequestData & {
29
+ url: string;
30
+ }, {
31
+ mediaAdapters: Record<string, MediaAdapter>;
32
+ custom: T;
33
+ }>;
49
34
  declare function createCodeUsageGeneratorRegistry(inherit?: CodeUsageGeneratorRegistry): CodeUsageGeneratorRegistry;
50
- type CodeUsageGeneratorFn<ServerContext = unknown> = (url: string, data: RequestData, context: {
35
+ type CodeUsageGeneratorFn<T = unknown> = (data: RequestData & {
36
+ url: string;
37
+ }, context: {
51
38
  mediaAdapters: Record<string, MediaAdapter>;
52
- server: ServerContext;
39
+ custom: T;
53
40
  }) => string;
54
41
  //#endregion
55
- export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry };
42
+ export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry, pathnameFromRequest };
@@ -1,39 +1,22 @@
1
+ import * as Shared from "@fumadocs/api-docs/codegen";
1
2
  //#region src/requests/generators/index.ts
3
+ function pathnameFromRequest(pathname, { path, query }) {
4
+ for (const key in path) {
5
+ const param = path[key];
6
+ pathname = pathname.replace(`{${key}}`, param.value);
7
+ }
8
+ const [pathPart, existingQueryString] = pathname.split("?", 2);
9
+ const searchParams = new URLSearchParams(existingQueryString || "");
10
+ for (const key in query) {
11
+ const param = query[key];
12
+ if (!param || param.values.length === 0) continue;
13
+ searchParams.delete(key);
14
+ for (const item of param.values) searchParams.append(key, item);
15
+ }
16
+ return searchParams.size > 0 ? `${pathPart}?${searchParams}` : pathPart;
17
+ }
2
18
  function createCodeUsageGeneratorRegistry(inherit) {
3
- const registry = new Map(inherit?.map());
4
- return {
5
- add(id, generator) {
6
- registry.set(id, generator);
7
- },
8
- get(id) {
9
- return registry.get(id);
10
- },
11
- addInline(generator) {
12
- const source = generator.source;
13
- const id = generator.id ?? generator.lang;
14
- if (!source) {
15
- this.remove(id);
16
- return;
17
- }
18
- registry.set(id, {
19
- lang: generator.lang,
20
- label: generator.label,
21
- generate() {
22
- return typeof source === "string" ? source : "";
23
- },
24
- _client: {
25
- generate: source,
26
- serverContext: generator.serverContext
27
- }
28
- });
29
- },
30
- remove(id) {
31
- return registry.delete(id);
32
- },
33
- map() {
34
- return registry;
35
- }
36
- };
19
+ return Shared.createCodeUsageGeneratorRegistry(inherit);
37
20
  }
38
21
  //#endregion
39
- export { createCodeUsageGeneratorRegistry };
22
+ export { createCodeUsageGeneratorRegistry, pathnameFromRequest };
@@ -5,7 +5,7 @@ import "../media/adapter.js";
5
5
  const java = {
6
6
  label: "Java",
7
7
  lang: "java",
8
- generate(url, data, { mediaAdapters }) {
8
+ generate(data, { mediaAdapters }) {
9
9
  const s = [];
10
10
  const headers = { ...data.header };
11
11
  const imports = new Set([
@@ -31,7 +31,7 @@ const java = {
31
31
  s.push(indent(".build();"));
32
32
  s.push("");
33
33
  s.push("HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()");
34
- s.push(indent(`.uri(URI.create(${doubleQuote(url)}))`));
34
+ s.push(indent(`.uri(URI.create(${doubleQuote(data.url)}))`));
35
35
  for (const [key, param] of Object.entries(headers)) s.push(indent(`.header(${doubleQuote(key)}, ${doubleQuote(param.value)})`));
36
36
  if (data.bodyMediaType) s.push(indent(`.header("Content-Type", "${data.bodyMediaType}")`));
37
37
  const cookies = Object.entries(data.cookie);
@@ -5,7 +5,7 @@ import "../media/adapter.js";
5
5
  const javascript = {
6
6
  label: "JavaScript",
7
7
  lang: "js",
8
- generate(url, data, { mediaAdapters }) {
8
+ generate(data, { mediaAdapters }) {
9
9
  const s = [];
10
10
  const options = /* @__PURE__ */ new Map();
11
11
  const headers = {};
@@ -26,7 +26,7 @@ const javascript = {
26
26
  s.push(body);
27
27
  options.set("body", "body");
28
28
  }
29
- const params = [doubleQuote(url)];
29
+ const params = [doubleQuote(data.url)];
30
30
  if (options.size > 0) {
31
31
  const str = Array.from(options.entries()).map(([k, v]) => indent(k === v ? k : `${k}: ${v}`)).join(",\n");
32
32
  params.push(`{\n${str}\n}`);
@@ -5,7 +5,7 @@ import "../media/adapter.js";
5
5
  const python = {
6
6
  label: "Python",
7
7
  lang: "python",
8
- generate(url, data, { mediaAdapters }) {
8
+ generate(data, { mediaAdapters }) {
9
9
  const headers = {};
10
10
  const imports = /* @__PURE__ */ new Set();
11
11
  const params = [`"${data.method.toUpperCase()}"`, "url"];
@@ -27,7 +27,7 @@ const python = {
27
27
  }
28
28
  return `${Array.from(imports).map((name) => "import " + name).join("\n")}
29
29
 
30
- url = ${doubleQuote(url)}
30
+ url = ${doubleQuote(data.url)}
31
31
  ${body ?? ""}
32
32
  response = requests.request(${params.join(", ")})
33
33
 
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { I18nLabel } from "../ui/client/i18n.js";
3
2
  import { cn } from "../utils/cn.js";
4
3
  import { MethodLabel } from "../ui/components/method-label.js";
5
4
  import { useEffect, useState } from "react";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useTranslations } from "@fuma-translate/react";
7
7
  import { buttonVariants } from "fumadocs-ui/components/ui/button";
8
8
  import { useApiClient } from "@scalar/api-client-react";
9
9
  import { useTheme } from "fumadocs-ui/provider/base";
@@ -11,6 +11,7 @@ import "@scalar/api-client-react/style.css";
11
11
  //#region src/scalar/client.tsx
12
12
  function ScalarPlayground({ path, method, spec }) {
13
13
  const { resolvedTheme } = useTheme();
14
+ const t = useTranslations({ note: "scalar API client" });
14
15
  const [mounted, setMounted] = useState(false);
15
16
  const client = useApiClient({ configuration: { content: spec } });
16
17
  useEffect(() => {
@@ -37,7 +38,7 @@ function ScalarPlayground({ path, method, spec }) {
37
38
  path,
38
39
  method
39
40
  }),
40
- children: /* @__PURE__ */ jsx(I18nLabel, { label: "test" })
41
+ children: t("Test")
41
42
  })
42
43
  ]
43
44
  });
@@ -1,4 +1,4 @@
1
- import { CreateAPIPageOptions } from "../ui/index.js";
1
+ import { CreateOpenAPIPageOptions } from "../ui/index.js";
2
2
 
3
3
  //#region src/scalar/index.d.ts
4
4
  /**
@@ -6,6 +6,6 @@ import { CreateAPIPageOptions } from "../ui/index.js";
6
6
  *
7
7
  * Requires `@scalar/api-client-react` to be installed, it imports the styles automatically.
8
8
  */
9
- declare function withScalar(options?: CreateAPIPageOptions): CreateAPIPageOptions;
9
+ declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
10
10
  //#endregion
11
11
  export { withScalar };
@@ -1,14 +1,8 @@
1
+ "use client";
1
2
  import { lazy } from "react";
2
3
  import { jsx } from "react/jsx-runtime";
3
4
  //#region src/scalar/index.tsx
4
5
  const Client = lazy(() => import("./client.js"));
5
- function APIPlayground({ path, method, ctx }) {
6
- return /* @__PURE__ */ jsx(Client, {
7
- method: method.method,
8
- path,
9
- spec: ctx.schema.bundled
10
- });
11
- }
12
6
  /**
13
7
  * Enable Scalar for API playgrounds by wrapping your options inside.
14
8
  *
@@ -19,8 +13,15 @@ function withScalar(options = {}) {
19
13
  ...options,
20
14
  playground: {
21
15
  ...options.playground,
22
- render(props) {
23
- return /* @__PURE__ */ jsx(APIPlayground, { ...props });
16
+ provider(props) {
17
+ return props.children;
18
+ },
19
+ render({ method, path, ctx }) {
20
+ return /* @__PURE__ */ jsx(Client, {
21
+ method,
22
+ path,
23
+ spec: ctx.schema.bundled
24
+ });
24
25
  }
25
26
  }
26
27
  };
@@ -1,29 +1,27 @@
1
- import { InlineCodeUsageGenerator } from "../requests/generators/index.js";
2
1
  import { CreateProxyOptions, Proxy, createProxy } from "./proxy.js";
3
- import { ProcessedDocument } from "../utils/document/process.js";
4
- import { ApiPageProps } from "../ui/api-page.js";
5
- import { ClientApiPageProps } from "../ui/create-client.js";
2
+ import { OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec } from "../ui/index.js";
6
3
  import { SchemaToPagesOptions } from "../utils/pages/preset-auto.js";
7
- import { Document } from "../types.js";
8
- import { DereferencedDocument } from "../utils/document/dereference.js";
9
- import { DynamicSource, LoaderPlugin, MetaData, PageData, PageTreeTransformer, Source } from "fumadocs-core/source";
4
+ import { Awaitable, Document } from "../types.js";
5
+ import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source";
10
6
  import { StructuredData } from "fumadocs-core/mdx-plugins/remark-structure";
11
7
  import { TOCItemType } from "fumadocs-core/toc";
12
8
 
13
9
  //#region src/server/index.d.ts
14
10
  /**
15
- * schema id -> file path, URL, or downloaded schema object
11
+ * schema ID -> file path, URL, downloaded schema object, or a function returning them
16
12
  */
17
- type SchemaMap = Record<string, string | Document>;
18
- type ProcessedSchemaMap = Record<string, ProcessedDocument>;
13
+ type SchemaRecord = Record<string, string | Document | (() => Awaitable<string | Document>)>;
14
+ interface LoadedDocument {
15
+ bundled: Document;
16
+ }
19
17
  interface OpenAPIOptions {
20
18
  /**
21
19
  * Schema files, can be:
22
20
  * - URL
23
21
  * - file path
24
- * - a function returning records of downloaded schemas.
22
+ * - a schema record object
25
23
  */
26
- input?: string[] | (() => SchemaMap | Promise<SchemaMap>);
24
+ input?: string[] | SchemaRecord;
27
25
  disableCache?: boolean;
28
26
  /**
29
27
  * The url of proxy to avoid CORS issues
@@ -32,8 +30,8 @@ interface OpenAPIOptions {
32
30
  }
33
31
  interface OpenAPIServer {
34
32
  createProxy: typeof createProxy;
35
- getSchemas: () => Promise<ProcessedSchemaMap>;
36
- getSchema: (document: string) => Promise<ProcessedDocument>;
33
+ getSchemas: () => Promise<Record<string, LoadedDocument>>;
34
+ getSchema: (document: string) => Promise<LoadedDocument>;
37
35
  readonly options: OpenAPIOptions;
38
36
  /**
39
37
  * Generate virtual pages for Fumadocs Source API
@@ -49,6 +47,7 @@ interface OpenAPIServer {
49
47
  metaData: MetaData;
50
48
  pageData: OpenAPIPageData;
51
49
  }>;
50
+ preloadOpenAPIPage: <Type extends string | undefined, Data extends PageData>(page: Page<Type, Data>) => Promise<Pick<OpenAPIPageProps_Preloaded, 'preloaded'>>;
52
51
  /**
53
52
  * Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
54
53
  */
@@ -57,14 +56,18 @@ interface OpenAPIServer {
57
56
  _getWatchPaths: () => string[];
58
57
  }
59
58
  interface OpenAPIPageData extends PageData {
60
- getAPIPageProps: () => ApiPageProps;
59
+ getOpenAPIPageProps: () => OpenAPIPageProps_Spec;
61
60
  getSchema: () => {
62
61
  id: string;
63
- } & DereferencedDocument;
64
- getClientAPIPageProps: () => Promise<ClientApiPageProps>;
62
+ bundled: Document;
63
+ };
65
64
  structuredData: StructuredData;
66
65
  toc: TOCItemType[];
67
- _openapi?: InternalOpenAPIMeta;
66
+ _openapi: InternalOpenAPIMeta;
67
+ /** @deprecated use `getOpenAPIPageProps()` instead */
68
+ getAPIPageProps: () => OpenAPIPageProps_Spec;
69
+ /** @deprecated use `getOpenAPIPageProps()` instead */
70
+ getClientAPIPageProps: () => OpenAPIPageProps_Spec;
68
71
  }
69
72
  type OpenAPISourceOptions = SchemaToPagesOptions & {
70
73
  baseDir?: string; /** Generate `meta.json` files */
@@ -73,14 +76,11 @@ type OpenAPISourceOptions = SchemaToPagesOptions & {
73
76
  };
74
77
  };
75
78
  declare function createOpenAPI(options?: OpenAPIOptions): OpenAPIServer;
76
- /**
77
- * @deprecated
78
- */
79
- declare function createCodeSample<T>(options: InlineCodeUsageGenerator<T>): InlineCodeUsageGenerator<T>;
80
79
  interface InternalOpenAPIMeta {
81
80
  method?: string;
82
81
  webhook?: boolean;
83
82
  deprecated?: boolean;
83
+ preload?: string[];
84
84
  }
85
85
  /**
86
86
  * Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
@@ -93,9 +93,5 @@ declare function openapiSource(server: OpenAPIServer, options?: OpenAPISourceOpt
93
93
  metaData: MetaData;
94
94
  pageData: OpenAPIPageData;
95
95
  }>>;
96
- /**
97
- * @deprecated use `openapiPlugin()`
98
- */
99
- declare function transformerOpenAPI(): PageTreeTransformer;
100
96
  //#endregion
101
- export { type CreateProxyOptions, InternalOpenAPIMeta, OpenAPIOptions, OpenAPIPageData, OpenAPIServer, OpenAPISourceOptions, type Proxy, createCodeSample, createOpenAPI, openapiPlugin, openapiSource, transformerOpenAPI };
97
+ export { type CreateProxyOptions, InternalOpenAPIMeta, OpenAPIOptions, OpenAPIPageData, type OpenAPIPageProps_Preloaded, type OpenAPIPageProps_Spec, OpenAPIServer, OpenAPISourceOptions, type Proxy, createOpenAPI, openapiPlugin, openapiSource };
@@ -2,23 +2,35 @@ import { getPageProps } from "../utils/pages/builder.js";
2
2
  import { toStaticData } from "../utils/pages/to-static-data.js";
3
3
  import { MethodLabel } from "../ui/components/method-label.js";
4
4
  import { createProxy } from "./proxy.js";
5
- import { processDocument } from "../utils/document/process.js";
5
+ import { loadDocument } from "../utils/document/load.js";
6
6
  import path from "node:path";
7
7
  import { PathUtils } from "fumadocs-core/source";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import fs from "node:fs";
10
10
  //#region src/server/index.tsx
11
11
  function createOpenAPI(options = {}) {
12
- const { input = [], disableCache = false } = options;
13
- let schemas;
14
- async function getSchemas() {
15
- if (Array.isArray(input)) {
16
- const entries = await Promise.all(input.map(async (item) => [item, await processDocument(item)]));
17
- return Object.fromEntries(entries);
18
- } else {
19
- const entries = await Promise.all(Object.entries(await input()).map(async ([k, v]) => [k, await processDocument(v)]));
20
- return Object.fromEntries(entries);
12
+ const { disableCache = false } = options;
13
+ const schemaMap = /* @__PURE__ */ new Map();
14
+ let resolvedInput = {};
15
+ if (Array.isArray(options.input)) for (const item of options.input) resolvedInput[item] = item;
16
+ else if (options.input) resolvedInput = options.input;
17
+ function getSchema(schemaId) {
18
+ if (!(schemaId in resolvedInput)) {
19
+ console.warn(`[Fumadocs OpenAPI] the document "${schemaId}" is not listed in the input array, this may be unexpected and won't be cached properly.`);
20
+ return loadDocument(schemaId);
21
+ }
22
+ if (!disableCache) {
23
+ const cached = schemaMap.get(schemaId);
24
+ if (cached) return cached;
21
25
  }
26
+ const raw = resolvedInput[schemaId];
27
+ const output = Promise.resolve(typeof raw === "function" ? raw() : raw).then(loadDocument);
28
+ if (!disableCache) schemaMap.set(schemaId, output);
29
+ return output;
30
+ }
31
+ async function getSchemas() {
32
+ const entries = await Promise.all(Object.keys(resolvedInput).map(async (k) => [k, await getSchema(k)]));
33
+ return Object.fromEntries(entries);
22
34
  }
23
35
  async function getVirtualFiles(server, options) {
24
36
  const { baseDir = "", meta = false } = options;
@@ -28,7 +40,7 @@ function createOpenAPI(options = {}) {
28
40
  const schemas = await server.getSchemas();
29
41
  const builderOptions = createAutoPreset(options);
30
42
  for (const [id, schema] of Object.entries(schemas)) {
31
- onEntries(fromSchema(id, schema, builderOptions));
43
+ onEntries(fromSchema(id, schema.bundled, builderOptions));
32
44
  function onEntry(entry) {
33
45
  const props = getPageProps(entry);
34
46
  files.push({
@@ -37,9 +49,12 @@ function createOpenAPI(options = {}) {
37
49
  data: {
38
50
  ...entry.info,
39
51
  getAPIPageProps() {
40
- return props;
52
+ return this.getOpenAPIPageProps();
53
+ },
54
+ getClientAPIPageProps() {
55
+ return this.getOpenAPIPageProps();
41
56
  },
42
- async getClientAPIPageProps() {
57
+ getOpenAPIPageProps() {
43
58
  return {
44
59
  payload: {
45
60
  bundled: schema.bundled,
@@ -51,10 +66,10 @@ function createOpenAPI(options = {}) {
51
66
  getSchema() {
52
67
  return {
53
68
  id,
54
- ...schema
69
+ bundled: schema.bundled
55
70
  };
56
71
  },
57
- ...toStaticData(props, schema.dereferenced),
72
+ ...toStaticData(props, schema.bundled),
58
73
  _openapi: {
59
74
  method: entry.type === "operation" || entry.type === "webhook" ? entry.item.method : void 0,
60
75
  webhook: entry.type === "webhook",
@@ -100,18 +115,19 @@ function createOpenAPI(options = {}) {
100
115
  options,
101
116
  createProxy,
102
117
  _getWatchPaths() {
103
- return (Array.isArray(input) ? input : Object.keys(input)).filter((key) => !URL.canParse(key) && fs.existsSync(key));
104
- },
105
- async getSchema(document) {
106
- const schemas = await this.getSchemas();
107
- if (document in schemas) return schemas[document];
108
- console.warn(`[Fumadocs OpenAPI] the document "${document}" is not listed in the input array, this may not be expected.`);
109
- return processDocument(document);
118
+ return Object.keys(resolvedInput).filter((key) => !URL.canParse(key) && fs.existsSync(key));
110
119
  },
111
- async getSchemas() {
112
- if (disableCache) return getSchemas();
113
- return schemas ??= getSchemas();
120
+ async preloadOpenAPIPage(page) {
121
+ const out = {
122
+ docs: {},
123
+ proxyUrl: options.proxyUrl
124
+ };
125
+ const openapiMeta = page.data._openapi;
126
+ if (openapiMeta?.preload) out.docs = Object.fromEntries(await Promise.all(openapiMeta.preload.map(async (k) => [k, (await getSchema(k)).bundled])));
127
+ return { preloaded: out };
114
128
  },
129
+ getSchema,
130
+ getSchemas,
115
131
  async staticSource(options = {}) {
116
132
  return { files: await getVirtualFiles(this, options) };
117
133
  },
@@ -124,12 +140,6 @@ function createOpenAPI(options = {}) {
124
140
  };
125
141
  }
126
142
  /**
127
- * @deprecated
128
- */
129
- function createCodeSample(options) {
130
- return options;
131
- }
132
- /**
133
143
  * Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
134
144
  */
135
145
  function openapiPlugin() {
@@ -172,11 +182,5 @@ function openapiPlugin() {
172
182
  async function openapiSource(server, options = {}) {
173
183
  return server.staticSource(options);
174
184
  }
175
- /**
176
- * @deprecated use `openapiPlugin()`
177
- */
178
- function transformerOpenAPI() {
179
- return openapiPlugin().transformPageTree;
180
- }
181
185
  //#endregion
182
- export { createCodeSample, createOpenAPI, openapiPlugin, openapiSource, transformerOpenAPI };
186
+ export { createOpenAPI, openapiPlugin, openapiSource };
@@ -5,12 +5,6 @@ interface Proxy extends Record<(typeof methods)[number], Handler> {
5
5
  handle: Handler;
6
6
  }
7
7
  interface CreateProxyOptions {
8
- /**
9
- * Filter by prefixes of request url
10
- *
11
- * @deprecated Use `allowedOrigins` for filtering origins, or `filterRequest` for more detailed rules.
12
- */
13
- allowedUrls?: string[];
14
8
  /**
15
9
  * List of allowed origins to proxy to.
16
10
  */