fumadocs-openapi 10.10.2 → 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 -1151
  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 +16 -29
  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 -409
  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,419 +0,0 @@
1
- "use client";
2
- import { useTranslations } from "../../ui/client/i18n.js";
3
- import { cn } from "../../utils/cn.js";
4
- import { anyFields, useFieldInfo, useResolvedSchema, useSchemaScope, useSchemaUtils } from "../schema.js";
5
- import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../ui/components/select.js";
6
- import { Input, labelVariants } from "../../ui/components/input.js";
7
- import { useState } from "react";
8
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
- import { ChevronRight, Plus, Trash2, X } from "lucide-react";
10
- import { buttonVariants } from "fumadocs-ui/components/ui/button";
11
- import { cva } from "class-variance-authority";
12
- import { useArray, useDataEngine, useFieldValue, useObject } from "@fumari/stf";
13
- import { stringifyFieldKey } from "@fumari/stf/lib/utils";
14
- //#region src/playground/components/inputs.tsx
15
- const fieldLabelVariants = cva("w-full inline-flex items-center gap-0.5");
16
- function FieldLabelType(props) {
17
- return /* @__PURE__ */ jsx("code", {
18
- ...props,
19
- className: cn("text-xs text-fd-muted-foreground", props.className),
20
- children: props.children
21
- });
22
- }
23
- function ObjectInput({ field: _field, fieldName, ...props }) {
24
- const { generateDefault } = useSchemaUtils();
25
- const field = useResolvedSchema(_field);
26
- const schemaPropKeys = field.properties ? Object.keys(field.properties) : [];
27
- const { patternProperties = {}, additionalProperties, "x-playground-lazy": isLazy = schemaPropKeys.length > 100 } = field;
28
- const isDynamic = Object.keys(patternProperties).length > 0 || additionalProperties;
29
- const [nextName, setNextName] = useState("");
30
- const { properties, onAppend, onDelete, _objectKeys } = useObject(fieldName, {
31
- lazy: isLazy,
32
- defaultValue: () => generateDefault(field),
33
- properties: field.properties ?? {},
34
- fallback: additionalProperties,
35
- patternProperties
36
- });
37
- const hiddenProperties = isLazy ? schemaPropKeys.filter((key) => !_objectKeys.includes(key)) : [];
38
- const t = useTranslations();
39
- return /* @__PURE__ */ jsxs("div", {
40
- ...props,
41
- className: cn("grid grid-cols-1 gap-4 @md:grid-cols-2 *:data-[collapsible=true]:order-last", props.className),
42
- children: [
43
- isLazy && hiddenProperties.length > 0 && /* @__PURE__ */ jsxs(Select, {
44
- value: "",
45
- onValueChange: onAppend,
46
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
47
- className: "col-span-full",
48
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t.playgroundShowProperty })
49
- }), /* @__PURE__ */ jsx(SelectContent, { children: hiddenProperties.map((key) => /* @__PURE__ */ jsx(SelectItem, {
50
- value: key,
51
- children: key
52
- }, key)) })]
53
- }),
54
- properties.map((child) => {
55
- let toolbar = null;
56
- if (child.kind === "pattern" || child.kind === "fallback") toolbar = /* @__PURE__ */ jsx("button", {
57
- type: "button",
58
- "aria-label": t.playgroundRemoveItem,
59
- className: cn(buttonVariants({
60
- color: "outline",
61
- size: "icon-xs"
62
- })),
63
- onClick: () => {
64
- onDelete(child.key);
65
- },
66
- children: /* @__PURE__ */ jsx(Trash2, {})
67
- });
68
- return /* @__PURE__ */ jsx(FieldSet, {
69
- name: child.key,
70
- field: child.info,
71
- fieldName: child.field,
72
- isRequired: field.required?.includes(child.key),
73
- toolbar
74
- }, child.key);
75
- }),
76
- isDynamic && /* @__PURE__ */ jsxs("div", {
77
- className: "flex gap-2 order-last col-span-full",
78
- children: [/* @__PURE__ */ jsx(Input, {
79
- value: nextName,
80
- placeholder: t.playgroundPropertyPlaceholder,
81
- onChange: (e) => setNextName(e.target.value),
82
- onKeyDown: (e) => {
83
- if (e.key === "Enter") {
84
- setNextName("");
85
- onAppend(nextName);
86
- e.preventDefault();
87
- }
88
- }
89
- }), /* @__PURE__ */ jsx("button", {
90
- type: "button",
91
- className: cn(buttonVariants({
92
- color: "secondary",
93
- size: "sm"
94
- }), "px-4"),
95
- onClick: () => {
96
- onAppend(nextName);
97
- setNextName("");
98
- },
99
- children: t.playgroundNewProperty
100
- })]
101
- })
102
- ]
103
- });
104
- }
105
- function JsonInput({ fieldName }) {
106
- const engine = useDataEngine();
107
- const [error, setError] = useState(null);
108
- const [value, setValue] = useState(() => JSON.stringify(engine.init(fieldName, {}), null, 2));
109
- return /* @__PURE__ */ jsxs("div", {
110
- className: "flex flex-col bg-fd-secondary text-fd-secondary-foreground overflow-hidden border rounded-lg",
111
- children: [/* @__PURE__ */ jsx("textarea", {
112
- value,
113
- className: "p-2 h-[240px] text-sm font-mono resize-none focus-visible:outline-none",
114
- onChange: (v) => {
115
- setValue(v.target.value);
116
- try {
117
- engine.update(fieldName, JSON.parse(v.target.value));
118
- setError(null);
119
- } catch (e) {
120
- if (e instanceof Error) setError(e.message);
121
- }
122
- }
123
- }), /* @__PURE__ */ jsx("p", {
124
- className: "p-2 text-xs font-mono border-t text-red-400 empty:hidden",
125
- children: error
126
- })]
127
- });
128
- }
129
- function FieldInput({ field, fieldName, isRequired, ...props }) {
130
- const [value, setValue] = useFieldValue(fieldName);
131
- const id = stringifyFieldKey(fieldName);
132
- const t = useTranslations();
133
- if (field.type === "null") return;
134
- if (field.type === "string" && field.format === "binary") return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("label", {
135
- htmlFor: id,
136
- className: cn(buttonVariants({
137
- color: "secondary",
138
- className: "w-full h-9 gap-2 truncate"
139
- })),
140
- children: value instanceof File ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
141
- className: "text-fd-muted-foreground text-xs",
142
- children: t.playgroundSelected
143
- }), /* @__PURE__ */ jsx("span", {
144
- className: "truncate w-0 flex-1 text-end",
145
- children: value.name
146
- })] }) : /* @__PURE__ */ jsx("span", {
147
- className: "text-fd-muted-foreground",
148
- children: t.playgroundInputUpload
149
- })
150
- }), /* @__PURE__ */ jsx("input", {
151
- id,
152
- type: "file",
153
- multiple: false,
154
- onChange: (e) => {
155
- if (!e.target.files || e.target.files.length === 0) return;
156
- setValue(e.target.files.item(0));
157
- },
158
- hidden: true
159
- })] });
160
- if (field.enum && field.enum.length > 0) {
161
- const idx = field.enum.indexOf(value);
162
- return /* @__PURE__ */ jsxs(Select, {
163
- value: idx === -1 && isRequired ? "" : String(idx),
164
- onValueChange: (v) => setValue(field.enum[Number(v)]),
165
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
166
- id,
167
- ...props,
168
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t.playgroundSelectPlaceholder })
169
- }), /* @__PURE__ */ jsxs(SelectContent, { children: [field.enum.map((item, i) => /* @__PURE__ */ jsx(SelectItem, {
170
- value: String(i),
171
- children: typeof item === "string" ? item : JSON.stringify(item, null, 2)
172
- }, i)), !isRequired && /* @__PURE__ */ jsx(SelectItem, {
173
- value: "-1",
174
- children: t.playgroundInputUnset
175
- })] })]
176
- });
177
- }
178
- if (field.type === "boolean") return /* @__PURE__ */ jsxs(Select, {
179
- value: String(value),
180
- onValueChange: (value) => setValue(value === "undefined" ? void 0 : value === "true"),
181
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
182
- id,
183
- ...props,
184
- children: /* @__PURE__ */ jsx(SelectValue, {})
185
- }), /* @__PURE__ */ jsxs(SelectContent, { children: [
186
- /* @__PURE__ */ jsx(SelectItem, {
187
- value: "true",
188
- children: "True"
189
- }),
190
- /* @__PURE__ */ jsx(SelectItem, {
191
- value: "false",
192
- children: "False"
193
- }),
194
- !isRequired && /* @__PURE__ */ jsx(SelectItem, {
195
- value: "undefined",
196
- children: t.playgroundInputUnset
197
- })
198
- ] })]
199
- });
200
- const isNumber = field.type === "integer" || field.type === "number";
201
- return /* @__PURE__ */ jsx(Input, {
202
- id,
203
- placeholder: t.inputPlaceholder,
204
- type: isNumber ? "number" : "text",
205
- step: field.type === "integer" ? 1 : void 0,
206
- value: String(value ?? ""),
207
- onChange: (e) => {
208
- if (isNumber) setValue(Number.isNaN(e.target.valueAsNumber) ? void 0 : e.target.valueAsNumber);
209
- else if (!isNumber) setValue(e.target.value);
210
- }
211
- });
212
- }
213
- function FieldSet({ field: _field, fieldName, toolbar, name, isRequired, depth = 0, slotType, collapsible = true, ...props }) {
214
- const { readOnly, writeOnly } = useSchemaScope();
215
- const { generateDefault, schemaToString } = useSchemaUtils();
216
- const field = useResolvedSchema(_field);
217
- const [show, setShow] = useState(!collapsible);
218
- const { info, updateInfo } = useFieldInfo(fieldName, field, depth);
219
- const id = stringifyFieldKey(fieldName);
220
- const dataEngine = useDataEngine();
221
- const [isDefined] = useFieldValue(fieldName, { compute(currentValue) {
222
- return currentValue !== void 0;
223
- } });
224
- if (_field === false) return;
225
- if (field.readOnly && !readOnly) return;
226
- if (field.writeOnly && !writeOnly) return;
227
- if (collapsible && !isDefined && show) setShow(false);
228
- function renderLabelTrigger(schema = field) {
229
- if (!collapsible) return renderLabelName();
230
- return /* @__PURE__ */ jsxs("button", {
231
- type: "button",
232
- className: cn(labelVariants(), "inline-flex items-center gap-1 font-mono me-auto"),
233
- onClick: () => {
234
- dataEngine.init(fieldName, generateDefault(schema));
235
- setShow((prev) => !prev);
236
- },
237
- children: [
238
- /* @__PURE__ */ jsx(ChevronRight, { className: cn("size-3.5 text-fd-muted-foreground", show && "rotate-90") }),
239
- name,
240
- isRequired && /* @__PURE__ */ jsx("span", {
241
- className: "text-red-400/80",
242
- children: "*"
243
- })
244
- ]
245
- });
246
- }
247
- function renderLabelName() {
248
- return /* @__PURE__ */ jsxs("span", {
249
- className: cn(labelVariants(), "font-mono me-auto"),
250
- children: [name, isRequired && /* @__PURE__ */ jsx("span", {
251
- className: "text-red-400/80 mx-1",
252
- children: "*"
253
- })]
254
- });
255
- }
256
- function renderUnsetButton() {
257
- return /* @__PURE__ */ jsx("button", {
258
- type: "button",
259
- onClick: () => dataEngine.delete(fieldName),
260
- className: "text-fd-muted-foreground hover:text-fd-accent-foreground",
261
- children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
262
- });
263
- }
264
- if (info.unionField && field[info.unionField] && field[info.unionField].length > 0) {
265
- const union = field[info.unionField];
266
- const showSelect = union.length > 1;
267
- return /* @__PURE__ */ jsx(FieldSet, {
268
- ...props,
269
- name,
270
- fieldName,
271
- isRequired,
272
- field: union[info.oneOf],
273
- depth: depth + 1,
274
- slotType: showSelect ? false : slotType,
275
- collapsible,
276
- toolbar: /* @__PURE__ */ jsxs(Fragment$1, { children: [showSelect && /* @__PURE__ */ jsx("select", {
277
- className: "text-xs font-mono",
278
- value: info.oneOf,
279
- onChange: (e) => {
280
- updateInfo({ oneOf: Number(e.target.value) });
281
- },
282
- children: union.map((item, i) => /* @__PURE__ */ jsx("option", {
283
- value: i,
284
- className: "bg-fd-popover text-fd-popover-foreground",
285
- children: schemaToString(item, 1)
286
- }, i))
287
- }), toolbar] })
288
- });
289
- }
290
- if (Array.isArray(field.type)) {
291
- const showSelect = field.type.length > 1;
292
- return /* @__PURE__ */ jsx(FieldSet, {
293
- ...props,
294
- name,
295
- fieldName,
296
- isRequired,
297
- field: {
298
- ...field,
299
- type: info.selectedType
300
- },
301
- collapsible,
302
- depth: depth + 1,
303
- slotType: showSelect ? false : slotType,
304
- toolbar: /* @__PURE__ */ jsxs(Fragment$1, { children: [showSelect && /* @__PURE__ */ jsx("select", {
305
- className: "text-xs font-mono",
306
- value: info.selectedType,
307
- onChange: (e) => {
308
- updateInfo({ selectedType: e.target.value });
309
- },
310
- children: field.type.map((item) => /* @__PURE__ */ jsx("option", {
311
- value: item,
312
- className: "bg-fd-popover text-fd-popover-foreground",
313
- children: item
314
- }, item))
315
- }), toolbar] })
316
- });
317
- }
318
- if (field.type === "object") return /* @__PURE__ */ jsxs("fieldset", {
319
- ...props,
320
- "data-collapsible": collapsible,
321
- className: cn("flex flex-col gap-1.5 col-span-full @container", props.className),
322
- children: [/* @__PURE__ */ jsxs("div", {
323
- className: fieldLabelVariants(),
324
- children: [
325
- renderLabelTrigger(field),
326
- slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
327
- toolbar,
328
- !isRequired && isDefined && renderUnsetButton()
329
- ]
330
- }), show && /* @__PURE__ */ jsx(ObjectInput, {
331
- field,
332
- fieldName,
333
- className: "rounded-lg border border-fd-primary/20 bg-fd-background/50 p-2 shadow-sm"
334
- })]
335
- });
336
- if (field.type === "array") return /* @__PURE__ */ jsxs("fieldset", {
337
- ...props,
338
- "data-collapsible": collapsible,
339
- className: cn("flex flex-col gap-1.5 col-span-full", props.className),
340
- children: [/* @__PURE__ */ jsxs("div", {
341
- className: fieldLabelVariants(),
342
- children: [
343
- renderLabelTrigger(),
344
- slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
345
- toolbar,
346
- !isRequired && isDefined && renderUnsetButton()
347
- ]
348
- }), show && /* @__PURE__ */ jsx(ArrayInput, {
349
- fieldName,
350
- items: field.items ?? anyFields,
351
- className: "rounded-lg border border-fd-primary/20 bg-fd-background/50 p-2 shadow-sm"
352
- })]
353
- });
354
- return /* @__PURE__ */ jsxs("fieldset", {
355
- ...props,
356
- className: cn("flex flex-col gap-1.5", props.className),
357
- children: [/* @__PURE__ */ jsxs("label", {
358
- className: fieldLabelVariants(),
359
- htmlFor: id,
360
- children: [
361
- renderLabelName(),
362
- slotType ?? /* @__PURE__ */ jsx(FieldLabelType, { children: schemaToString(field) }),
363
- toolbar,
364
- !isRequired && isDefined && renderUnsetButton()
365
- ]
366
- }), /* @__PURE__ */ jsx(FieldInput, {
367
- field,
368
- fieldName,
369
- isRequired
370
- })]
371
- });
372
- }
373
- function ArrayInput({ fieldName, items: itemSchema, ...props }) {
374
- const name = fieldName.at(-1) ?? "";
375
- const { generateDefault } = useSchemaUtils();
376
- const { items, insertItem, removeItem } = useArray(fieldName);
377
- const t = useTranslations();
378
- return /* @__PURE__ */ jsxs("div", {
379
- ...props,
380
- className: cn("flex flex-col gap-2", props.className),
381
- children: [items.map((item) => /* @__PURE__ */ jsx(FieldSet, {
382
- name: /* @__PURE__ */ jsxs("span", {
383
- className: "text-fd-muted-foreground",
384
- children: [
385
- name,
386
- "[",
387
- item.index,
388
- "]"
389
- ]
390
- }),
391
- field: itemSchema,
392
- isRequired: true,
393
- fieldName: item.field,
394
- toolbar: /* @__PURE__ */ jsx("button", {
395
- type: "button",
396
- "aria-label": t.playgroundRemoveItem,
397
- className: cn(buttonVariants({
398
- color: "outline",
399
- size: "icon-xs"
400
- })),
401
- onClick: () => removeItem(item.index),
402
- children: /* @__PURE__ */ jsx(Trash2, {})
403
- })
404
- }, item.index)), /* @__PURE__ */ jsxs("button", {
405
- type: "button",
406
- className: cn(buttonVariants({
407
- color: "secondary",
408
- className: "gap-1.5 py-2",
409
- size: "sm"
410
- })),
411
- onClick: () => {
412
- insertItem(generateDefault(itemSchema));
413
- },
414
- children: [/* @__PURE__ */ jsx(Plus, { className: "size-4" }), t.playgroundNewItem]
415
- })]
416
- });
417
- }
418
- //#endregion
419
- export { FieldInput, FieldSet, JsonInput, ObjectInput };
@@ -1,15 +0,0 @@
1
- import { useTranslations } from "../../ui/client/i18n.js";
2
- import { cn } from "../../utils/cn.js";
3
- import { jsx } from "react/jsx-runtime";
4
- import { Loader2Icon } from "lucide-react";
5
- //#region src/playground/components/spinner.tsx
6
- function Spinner({ className, ...props }) {
7
- return /* @__PURE__ */ jsx(Loader2Icon, {
8
- role: "status",
9
- "aria-label": useTranslations().loading,
10
- className: cn("size-4 animate-spin", className),
11
- ...props
12
- });
13
- }
14
- //#endregion
15
- export { Spinner };
@@ -1,15 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { FieldKey } from "@fumari/stf";
3
- //#region src/playground/schema.d.ts
4
- interface SchemaScope {
5
- /**
6
- * show write only fields
7
- */
8
- writeOnly: boolean;
9
- /**
10
- * show read only fields
11
- */
12
- readOnly: boolean;
13
- }
14
- //#endregion
15
- export { SchemaScope };
@@ -1,144 +0,0 @@
1
- import { require__2020 } from "../node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";
2
- import { mergeAllOf } from "../utils/schema/merge.js";
3
- import { sample } from "../utils/schema/sample.js";
4
- import { schemaToString } from "../utils/schema/to-string.js";
5
- import { dereferenceSwallow } from "../utils/schema/dereference.js";
6
- import { createContext, use, useMemo } from "react";
7
- import { jsx } from "react/jsx-runtime";
8
- import { useDataEngine, useFieldValue, useNamespace } from "@fumari/stf";
9
- import { stringifyFieldKey } from "@fumari/stf/lib/utils";
10
- //#region src/playground/schema.tsx
11
- var import__2020 = require__2020();
12
- const SchemaContext = createContext(void 0);
13
- const anyFields = {
14
- type: [
15
- "string",
16
- "number",
17
- "boolean",
18
- "array",
19
- "object"
20
- ],
21
- items: true,
22
- additionalProperties: true
23
- };
24
- function SchemaProvider({ doc, readOnly, writeOnly, children }) {
25
- const ajv = useMemo(() => new import__2020.Ajv2020({
26
- strict: false,
27
- validateSchema: false,
28
- validateFormats: false
29
- }), []);
30
- return /* @__PURE__ */ jsx(SchemaContext.Provider, {
31
- value: useMemo(() => ({
32
- doc,
33
- ajv,
34
- readOnly,
35
- writeOnly
36
- }), [
37
- doc,
38
- ajv,
39
- readOnly,
40
- writeOnly
41
- ]),
42
- children
43
- });
44
- }
45
- function useSchemaScope() {
46
- return use(SchemaContext);
47
- }
48
- /**
49
- * A hook to store dynamic info of a field, such as selected schema of `oneOf`.
50
- *
51
- * @param fieldName - field name of form.
52
- * @param schema - The **resolved** JSON Schema to generate initial values.
53
- * @param depth - The depth to avoid duplicated field name with same schema (e.g. nested `oneOf`).
54
- */
55
- function useFieldInfo(fieldName, schema, depth = 0) {
56
- const { ajv, doc } = use(SchemaContext);
57
- const engine = useDataEngine();
58
- const { generateDefault } = useSchemaUtils();
59
- const [info, setInfo] = useFieldValue([], { stf: useNamespace({
60
- namespace: `field-info:${depth}:${stringifyFieldKey(fieldName)}`,
61
- initial() {
62
- const value = engine.get(fieldName);
63
- const out = { oneOf: -1 };
64
- const union = getUnion(schema);
65
- if (union) {
66
- const [members, field] = union;
67
- out.oneOf = members.findIndex((item) => typeof item === "object" && ajv.validate({
68
- ...doc,
69
- ...item
70
- }, value));
71
- if (out.oneOf === -1) out.oneOf = 0;
72
- out.unionField = field;
73
- }
74
- if (Array.isArray(schema.type)) {
75
- const types = schema.type;
76
- out.selectedType = types.find((type) => {
77
- return ajv.validate({
78
- ...doc,
79
- ...schema,
80
- type
81
- }, value);
82
- }) ?? types[0];
83
- }
84
- return out;
85
- }
86
- }) });
87
- return {
88
- info,
89
- schema,
90
- updateInfo(value) {
91
- const updated = {
92
- ...info,
93
- ...value
94
- };
95
- if (updated.oneOf === info.oneOf && updated.selectedType === info.selectedType) return;
96
- setInfo(updated);
97
- let valueSchema = schema;
98
- if (updated.unionField) valueSchema = schema[updated.unionField][updated.oneOf];
99
- else if (updated.selectedType) valueSchema = {
100
- ...schema,
101
- type: updated.selectedType,
102
- examples: void 0
103
- };
104
- engine.update(fieldName, generateDefault(valueSchema));
105
- }
106
- };
107
- }
108
- function useSchemaUtils() {
109
- const { doc, readOnly } = use(SchemaContext);
110
- return {
111
- generateDefault(schema) {
112
- return sample(schema, {
113
- skipNonRequired: true,
114
- skipReadOnly: !readOnly,
115
- quiet: true
116
- }, doc);
117
- },
118
- schemaToString(value, flags) {
119
- return schemaToString(value, (raw) => ({
120
- raw,
121
- dereferenced: dereferenceSwallow(raw, doc)
122
- }), flags);
123
- }
124
- };
125
- }
126
- /**
127
- * dereference & merge `allOf`.
128
- */
129
- function useResolvedSchema(raw) {
130
- const { doc } = use(SchemaContext);
131
- return useMemo(() => {
132
- let out = dereferenceSwallow(raw, doc);
133
- if (typeof out === "object" && out.allOf) out = mergeAllOf(out, { dereference(schema) {
134
- return dereferenceSwallow(schema, doc);
135
- } });
136
- return typeof out === "boolean" ? anyFields : out;
137
- }, [doc, raw]);
138
- }
139
- function getUnion(schema) {
140
- if (schema.anyOf) return [schema.anyOf, "anyOf"];
141
- if (schema.oneOf) return [schema.oneOf, "oneOf"];
142
- }
143
- //#endregion
144
- export { SchemaProvider, anyFields, useFieldInfo, useResolvedSchema, useSchemaScope, useSchemaUtils };
@@ -1,31 +0,0 @@
1
- import { HttpMethods } from "../types.js";
2
- //#region src/ui/api-page.d.ts
3
- interface ApiPageProps {
4
- document: string;
5
- showTitle?: boolean;
6
- showDescription?: boolean;
7
- /**
8
- * An array of operations
9
- */
10
- operations?: OperationItem[];
11
- webhooks?: WebhookItem[];
12
- }
13
- interface WebhookItem {
14
- /**
15
- * webhook name in `webhooks`
16
- */
17
- name: string;
18
- method: HttpMethods;
19
- }
20
- interface OperationItem {
21
- /**
22
- * the path of operation in `paths`
23
- */
24
- path: string;
25
- /**
26
- * the HTTP method of operation
27
- */
28
- method: HttpMethods;
29
- }
30
- //#endregion
31
- export { ApiPageProps, OperationItem, WebhookItem };
@@ -1,59 +0,0 @@
1
- import { createMethod } from "../utils/schema/index.js";
2
- import { Operation } from "./operation/index.js";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/ui/api-page.tsx
5
- function APIPage({ showTitle: hasHead = false, showDescription, operations, webhooks, ctx }) {
6
- const { dereferenced } = ctx.schema;
7
- let { renderPageLayout } = ctx.content ?? {};
8
- renderPageLayout ??= (slots) => /* @__PURE__ */ jsxs("div", {
9
- className: "flex flex-col gap-24 text-sm @container",
10
- children: [slots.operations?.map((op) => op.children), slots.webhooks?.map((op) => op.children)]
11
- });
12
- let content = renderPageLayout({
13
- operations: operations?.map((item) => {
14
- const pathItem = dereferenced.paths?.[item.path];
15
- if (!pathItem) throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
16
- const operation = pathItem[item.method];
17
- if (!operation) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in operation: ${item.path}`);
18
- return {
19
- item,
20
- children: /* @__PURE__ */ jsx(Operation, {
21
- method: createMethod(item.method, pathItem, operation),
22
- path: item.path,
23
- ctx,
24
- showTitle: hasHead,
25
- showDescription
26
- }, `${item.path}:${item.method}`)
27
- };
28
- }),
29
- webhooks: webhooks?.map((item) => {
30
- const webhook = dereferenced.webhooks?.[item.name];
31
- if (!webhook) throw new Error(`[Fumadocs OpenAPI] Webhook not found in OpenAPI schema: ${item.name}`);
32
- const hook = webhook[item.method];
33
- if (!hook) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in webhook: ${item.name}`);
34
- return {
35
- item,
36
- children: /* @__PURE__ */ jsx(Operation, {
37
- type: "webhook",
38
- method: createMethod(item.method, webhook, hook),
39
- ctx,
40
- path: `/${item.name}`,
41
- showTitle: hasHead,
42
- showDescription
43
- }, `${item.name}:${item.method}`)
44
- };
45
- })
46
- }, ctx);
47
- if (ctx.playground?.enabled !== false && ctx.playground?.provider) content = ctx.playground.provider({ children: content });
48
- return /* @__PURE__ */ jsx(ctx.clientBoundary.ApiProvider, {
49
- schemes: dereferenced.components?.securitySchemes ?? {},
50
- shikiOptions: ctx.shikiOptions,
51
- client: ctx.client ?? {},
52
- children: /* @__PURE__ */ jsx(ctx.clientBoundary.ServerProvider, {
53
- servers: dereferenced.servers,
54
- children: content
55
- })
56
- });
57
- }
58
- //#endregion
59
- export { APIPage };
@@ -1,11 +0,0 @@
1
- import PlaygroundClient from "../../playground/client.js";
2
- import { ApiProvider, ServerProvider } from "../contexts/api.js";
3
- import { UsageTab, UsageTabsSelector } from "../operation/usage-tabs/client.js";
4
- import { SchemaUI } from "../schema/client.js";
5
-
6
- //#region src/ui/client/boundary.d.ts
7
- declare namespace boundary_d_exports {
8
- export { ApiProvider, PlaygroundClient, SchemaUI, ServerProvider, UsageTab, UsageTabsSelector };
9
- }
10
- //#endregion
11
- export { boundary_d_exports };