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,6 +1,5 @@
1
1
  import { OperationOutput, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput } from "./builder.js";
2
2
  import { DistributiveOmit } from "../../types.js";
3
- import { DereferencedDocument } from "../document/dereference.js";
4
3
 
5
4
  //#region src/utils/pages/preset-auto.d.ts
6
5
  interface OperationConfig extends BaseConfig {
@@ -46,7 +45,7 @@ interface SchemaConfig extends BaseConfig {
46
45
  type SchemaToPagesOptions = SchemaConfig | TagConfig | OperationConfig | ({
47
46
  per: 'custom';
48
47
  } & PagesBuilderConfig);
49
- type NameFn<Entry extends OperationOutput | WebhookOutput | PageOutput = OperationOutput | WebhookOutput | PageOutput> = (this: PagesBuilder, output: DistributiveOmit<Entry, 'path'>, document: DereferencedDocument['dereferenced']) => string;
48
+ type NameFn<Entry extends OperationOutput | WebhookOutput | PageOutput = OperationOutput | WebhookOutput | PageOutput> = (this: PagesBuilder, output: DistributiveOmit<Entry, 'path'>) => string;
50
49
  interface NameFnOptions {
51
50
  /**
52
51
  * The version of algorithm used to generate file paths.
@@ -1,5 +1,5 @@
1
- import { isUrl } from "../url.js";
2
1
  import * as path$1 from "node:path";
2
+ import { dereferenceShallow } from "@fumadocs/api-docs/schema/dereference";
3
3
  //#region src/utils/pages/preset-auto.ts
4
4
  function createAutoPreset(options) {
5
5
  if (options.per === "custom") return options;
@@ -10,18 +10,18 @@ function createAutoPreset(options) {
10
10
  if (typeof options.name === "function") nameFn = options.name;
11
11
  else {
12
12
  const { algorithm = "v2" } = options.name ?? {};
13
- nameFn = function(result, document) {
13
+ nameFn = function(result) {
14
14
  if (result.type === "page") {
15
15
  if (result.tag) return slugify(result.tag.name);
16
16
  const schemaId = result.schemaId;
17
- return isUrl(schemaId) ? "index" : path$1.basename(schemaId, path$1.extname(schemaId));
17
+ return schemaId.startsWith("http://") || schemaId.startsWith("https://") ? "index" : path$1.basename(schemaId, path$1.extname(schemaId));
18
18
  }
19
19
  if (result.type === "operation") {
20
- const operation = document.paths[result.item.path][result.item.method];
20
+ const operation = this.document.paths[result.item.path][result.item.method];
21
21
  if (algorithm === "v2" && operation.operationId) return operation.operationId;
22
22
  return path$1.join(this.routePathToFilePath(result.item.path), result.item.method.toLowerCase());
23
23
  }
24
- const hook = document.webhooks[result.item.name][result.item.method];
24
+ const hook = dereferenceShallow(this.document.webhooks[result.item.name], this.document)[result.item.method];
25
25
  if (algorithm === "v2" && hook.operationId) return hook.operationId;
26
26
  return slugify(result.item.name);
27
27
  };
@@ -29,7 +29,7 @@ function createAutoPreset(options) {
29
29
  function group(builder, entries) {
30
30
  const groups = /* @__PURE__ */ new Map();
31
31
  const rest = [];
32
- const { dereferenced } = builder.document;
32
+ const doc = builder.document;
33
33
  const { groupBy = "none" } = options;
34
34
  for (const entry of entries) switch (groupBy) {
35
35
  case "route": {
@@ -52,7 +52,7 @@ function createAutoPreset(options) {
52
52
  break;
53
53
  }
54
54
  case "tag": {
55
- let tags = entry.type === "operation" ? dereferenced.paths[entry.item.path][entry.item.method].tags : dereferenced.webhooks[entry.item.name][entry.item.method].tags;
55
+ let tags = entry.type === "operation" ? dereferenceShallow(doc.paths?.[entry.item.path], doc)?.[entry.item.method]?.tags : dereferenceShallow(doc.webhooks?.[entry.item.name], doc)?.[entry.item.method]?.tags;
56
56
  if (!tags || tags.length === 0) {
57
57
  console.warn("When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.");
58
58
  tags = ["unknown"];
@@ -78,13 +78,13 @@ function createAutoPreset(options) {
78
78
  }
79
79
  group.entries.push({
80
80
  ...entry,
81
- path: path$1.join(groupName, `${nameFn.call(builder, entry, dereferenced)}.mdx`)
81
+ path: path$1.join(groupName, `${nameFn.call(builder, entry)}.mdx`)
82
82
  });
83
83
  }
84
84
  break;
85
85
  }
86
86
  default: {
87
- const fileName = `${nameFn.call(builder, entry, dereferenced)}.mdx`;
87
+ const fileName = `${nameFn.call(builder, entry)}.mdx`;
88
88
  if (typeof groupBy === "function") {
89
89
  const groupDisplayName = groupBy(entry);
90
90
  const groupName = slugify(groupDisplayName);
@@ -115,7 +115,7 @@ function createAutoPreset(options) {
115
115
  return rest;
116
116
  }
117
117
  return { toPages(builder) {
118
- const { dereferenced } = builder.document;
118
+ const doc = builder.document;
119
119
  const items = builder.extract();
120
120
  if (options.per === "file") {
121
121
  const entry = {
@@ -123,17 +123,17 @@ function createAutoPreset(options) {
123
123
  schemaId: builder.id,
124
124
  path: "",
125
125
  info: {
126
- title: dereferenced.info?.title ?? "Unknown",
127
- description: dereferenced.info?.description
126
+ title: doc.info?.title ?? "Unknown",
127
+ description: doc.info?.description
128
128
  },
129
129
  ...items
130
130
  };
131
- entry.path = `${nameFn.call(builder, entry, dereferenced)}.mdx`;
131
+ entry.path = `${nameFn.call(builder, entry)}.mdx`;
132
132
  builder.create(entry);
133
133
  return;
134
134
  }
135
135
  if (options.per === "tag") {
136
- const tags = dereferenced.tags ?? [];
136
+ const tags = doc.tags ?? [];
137
137
  for (const tag of tags) {
138
138
  const { displayName } = builder.fromTag(tag);
139
139
  const entry = {
@@ -148,7 +148,7 @@ function createAutoPreset(options) {
148
148
  operations: items.operations.filter((op) => op.tags?.includes(tag.name)),
149
149
  tag
150
150
  };
151
- entry.path = `${nameFn.call(builder, entry, dereferenced)}.mdx`;
151
+ entry.path = `${nameFn.call(builder, entry)}.mdx`;
152
152
  builder.create(entry);
153
153
  }
154
154
  return;
@@ -1,7 +1,8 @@
1
- import { idToTitle } from "../id-to-title.js";
1
+ import { idToTitle } from "@fumadocs/api-docs/utils/id-to-title";
2
+ import { dereferenceShallow } from "@fumadocs/api-docs/schema/dereference";
2
3
  import Slugger from "github-slugger";
3
4
  //#region src/utils/pages/to-static-data.ts
4
- function toStaticData(page, dereferenced) {
5
+ function toStaticData(page, doc) {
5
6
  const slugger = new Slugger();
6
7
  const toc = [];
7
8
  const structuredData = {
@@ -28,12 +29,12 @@ function toStaticData(page, dereferenced) {
28
29
  });
29
30
  }
30
31
  for (const item of page.operations ?? []) {
31
- const operation = dereferenced.paths?.[item.path]?.[item.method];
32
+ const operation = dereferenceShallow(doc.paths?.[item.path], doc)?.[item.method];
32
33
  if (!operation) continue;
33
34
  pathItem(operation, item.path);
34
35
  }
35
36
  for (const item of page.webhooks ?? []) {
36
- const webhook = dereferenced.webhooks?.[item.name]?.[item.method];
37
+ const webhook = dereferenceShallow(doc.webhooks?.[item.name], doc)?.[item.method];
37
38
  if (!webhook) continue;
38
39
  pathItem(webhook, item.name);
39
40
  }
@@ -1,4 +1,5 @@
1
1
  import { TagObject } from "../../types.js";
2
+
2
3
  //#region src/utils/pages/to-text.d.ts
3
4
  interface PagesToTextOptions {
4
5
  /**
@@ -1,10 +1,10 @@
1
- import { removeUndefined } from "../remove-undefined.js";
2
1
  import { getPageProps } from "./builder.js";
3
2
  import { toStaticData } from "./to-static-data.js";
4
3
  import { doubleQuote } from "../../requests/string-utils.js";
4
+ import { removeUndefined } from "../remove-undefined.js";
5
5
  import { dump } from "js-yaml";
6
6
  //#region src/utils/pages/to-text.ts
7
- function toText(entry, processed, options = {}) {
7
+ function toText(entry, doc, options = {}) {
8
8
  const { frontmatter, includeDescription = false } = options;
9
9
  const extend = frontmatter?.(entry.info.title, entry.info.description, entry.type === "page" ? entry.tag ? {
10
10
  type: "tag",
@@ -12,13 +12,13 @@ function toText(entry, processed, options = {}) {
12
12
  } : { type: "file" } : { type: "operation" });
13
13
  const pageProps = getPageProps(entry);
14
14
  if (!includeDescription) pageProps.showDescription = false;
15
- let meta;
16
- if (entry.type === "operation" || entry.type === "webhook") meta = {
17
- method: entry.item.method.toUpperCase(),
18
- webhook: entry.type === "webhook",
19
- deprecated: entry.info.deprecated
20
- };
21
- const data = toStaticData(pageProps, processed.dereferenced);
15
+ let meta = { preload: [entry.schemaId] };
16
+ if (entry.type === "operation" || entry.type === "webhook") {
17
+ meta.method = entry.item.method.toUpperCase();
18
+ meta.webhook = entry.type === "webhook";
19
+ meta.deprecated = entry.info.deprecated;
20
+ }
21
+ const data = toStaticData(pageProps, doc);
22
22
  return generateDocument({
23
23
  title: entry.info.title,
24
24
  description: !includeDescription ? entry.info.description : void 0,
@@ -47,7 +47,7 @@ function generateDocument(frontmatter, content, options) {
47
47
  return out.join("\n\n");
48
48
  }
49
49
  function pageContent({ showTitle, showDescription, document, webhooks, operations }) {
50
- const propStrs = [`document={${doubleQuote(document)}}`];
50
+ const propStrs = [`document=${doubleQuote(document)}`];
51
51
  if (webhooks) propStrs.push(`webhooks={${JSON.stringify(webhooks.map((item) => ({
52
52
  name: item.name,
53
53
  method: item.method
@@ -58,7 +58,17 @@ function pageContent({ showTitle, showDescription, document, webhooks, operation
58
58
  })))}}`);
59
59
  if (showTitle) propStrs.push(`showTitle`);
60
60
  if (showDescription) propStrs.push(`showDescription`);
61
- return `<APIPage ${propStrs.join(" ")} />`;
61
+ return `export default function Layout(props) {
62
+ const { APIPage, OpenAPIPage } = props.components ?? {};
63
+ // "APIPage" is the old name from v10, this allows both for backward compatibility
64
+ const Comp = OpenAPIPage ?? APIPage;
65
+ return (
66
+ <>
67
+ {props.children}
68
+ <Comp ${propStrs.join(" ")} />
69
+ </>
70
+ );
71
+ }`;
62
72
  }
63
73
  //#endregion
64
74
  export { generateDocument, toText };
@@ -1,19 +1,24 @@
1
- import { isPlainObject } from "./is-plain-object.js";
2
1
  //#region src/utils/remove-undefined.ts
3
2
  function removeUndefined(value, deep = false) {
4
- if (!isPlainObject(value)) return value;
5
- for (const key in value) {
6
- const prop = value[key];
7
- if (prop === void 0) {
8
- delete value[key];
3
+ const obj = value;
4
+ for (const key in obj) {
5
+ if (obj[key] === void 0) delete obj[key];
6
+ if (!deep) continue;
7
+ const entry = obj[key];
8
+ if (isPlainObject(entry)) {
9
+ removeUndefined(entry, deep);
9
10
  continue;
10
11
  }
11
- if (deep) {
12
- if (Array.isArray(prop)) for (const item of prop) removeUndefined(item, deep);
13
- if (isPlainObject(prop)) removeUndefined(prop, deep);
12
+ if (Array.isArray(entry)) {
13
+ for (const item of entry) if (isPlainObject(item)) removeUndefined(item, deep);
14
14
  }
15
15
  }
16
16
  return value;
17
17
  }
18
+ function isPlainObject(value) {
19
+ if (typeof value !== "object" || value === null) return false;
20
+ const prototype = Object.getPrototypeOf(value);
21
+ return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
22
+ }
18
23
  //#endregion
19
24
  export { removeUndefined };
@@ -0,0 +1,2 @@
1
+ import { ParsedSchema } from "@fumadocs/api-docs/schema";
2
+ export type { ParsedSchema };
@@ -1,5 +1,5 @@
1
- import { idToTitle } from "../id-to-title.js";
2
- //#region src/utils/schema/index.ts
1
+ import { idToTitle } from "@fumadocs/api-docs/utils/id-to-title";
2
+ //#region src/utils/schema.ts
3
3
  const methodKeys = [
4
4
  "get",
5
5
  "post",
@@ -17,19 +17,6 @@ function getTagDisplayName(tag) {
17
17
  if (tag.summary) return tag.summary;
18
18
  return idToTitle(tag.name);
19
19
  }
20
- /**
21
- * Summarize method endpoint information
22
- */
23
- function createMethod(method, path, operation) {
24
- return {
25
- description: path.description,
26
- summary: path.summary,
27
- ...operation,
28
- servers: operation.servers ?? path.servers,
29
- parameters: [...operation.parameters ?? [], ...path.parameters ?? []],
30
- method
31
- };
32
- }
33
20
  function pickExample(value) {
34
21
  if (value.example !== void 0) return value.example;
35
22
  if (value.content) {
@@ -45,19 +32,5 @@ function pickExample(value) {
45
32
  if (examples.length > 0) return examples[0].value;
46
33
  }
47
34
  }
48
- function parseSecurities(method, dereferenced) {
49
- const result = [];
50
- const security = method.security ?? dereferenced.security ?? [];
51
- if (security.length === 0) return result;
52
- for (const map of security) {
53
- const list = [];
54
- for (const [key, scopes] of Object.entries(map)) list.push({
55
- id: key,
56
- scopes
57
- });
58
- if (list.length > 0) result.push(list);
59
- }
60
- return result;
61
- }
62
35
  //#endregion
63
- export { createMethod, getPreferredType, getTagDisplayName, methodKeys, parseSecurities, pickExample };
36
+ export { getPreferredType, getTagDisplayName, methodKeys, pickExample };
@@ -1,8 +1,8 @@
1
- import { useApiContext } from "../contexts/api.js";
1
+ import { useRenderContext } from "../ui/contexts/api.js";
2
2
  import { useMemo } from "react";
3
- //#region src/ui/client/storage-key.ts
3
+ //#region src/utils/storage-key.ts
4
4
  function useStorageKey() {
5
- const { storageKeyPrefix } = useApiContext().client;
5
+ const { storageKeyPrefix } = useRenderContext();
6
6
  return useMemo(() => ({
7
7
  of: (name) => getStorageKey(storageKeyPrefix, name),
8
8
  AuthField: (schemeId) => getStorageKey(storageKeyPrefix, `auth-${schemeId}`)
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "fumadocs-openapi",
3
- "version": "10.10.3",
3
+ "version": "11.0.0",
4
4
  "description": "Generate MDX docs for your OpenAPI spec",
5
5
  "keywords": [
6
6
  "Docs",
7
- "NextJs"
7
+ "fumadocs"
8
8
  ],
9
9
  "homepage": "https://fumadocs.dev",
10
10
  "license": "MIT",
@@ -31,8 +31,6 @@
31
31
  "./server": "./dist/server/index.js",
32
32
  "./ui": "./dist/ui/index.js",
33
33
  "./ui/base": "./dist/ui/base.js",
34
- "./ui/client": "./dist/ui/client/index.js",
35
- "./ui/create-client": "./dist/ui/create-client.js",
36
34
  "./package.json": "./package.json",
37
35
  "./css/*": "./css/*"
38
36
  },
@@ -40,46 +38,41 @@
40
38
  "access": "public"
41
39
  },
42
40
  "dependencies": {
41
+ "@fuma-translate/react": "^0.0.3",
43
42
  "@fumari/json-schema-ts": "^0.0.2",
44
- "@radix-ui/react-accordion": "^1.2.12",
45
- "@radix-ui/react-dialog": "^1.1.15",
46
- "@radix-ui/react-select": "^2.2.6",
47
43
  "chokidar": "^5.0.0",
48
44
  "class-variance-authority": "^0.7.1",
49
45
  "github-slugger": "^2.0.0",
50
46
  "hast-util-to-jsx-runtime": "^2.3.6",
51
- "js-yaml": "^4.1.1",
47
+ "js-yaml": "^4.2.0",
52
48
  "lucide-react": "^1.17.0",
53
49
  "remark": "^15.0.1",
54
50
  "remark-rehype": "^11.1.2",
55
- "shiki": "^4.1.0",
51
+ "shiki": "^4.2.0",
56
52
  "tailwind-merge": "^3.6.0",
53
+ "@fumadocs/api-docs": "0.0.1",
57
54
  "@fumari/stf": "1.0.5"
58
55
  },
59
56
  "devDependencies": {
60
- "@apidevtools/json-schema-ref-parser": "^15.3.5",
61
- "@fastify/deepmerge": "^3.2.1",
62
- "@scalar/api-client-react": "2.0.20",
63
- "@scalar/openapi-upgrader": "^0.2.8",
57
+ "@scalar/api-client-react": "^2.0.21",
58
+ "@scalar/openapi-upgrader": "^0.2.9",
64
59
  "@tailwindcss/oxide": "^4.3.0",
65
60
  "@types/js-yaml": "^4.0.9",
66
61
  "@types/node": "25.9.1",
67
- "@types/react": "^19.2.15",
68
- "ajv": "^8.20.0",
62
+ "@types/react": "^19.2.16",
69
63
  "fast-content-type-parse": "^3.0.0",
70
64
  "json-schema-typed": "^8.0.2",
71
- "tailwindcss": "^4.3.0",
72
- "tsdown": "0.22.0",
65
+ "tsdown": "0.22.1",
73
66
  "xml-js": "^1.6.11",
74
- "fumadocs-core": "16.9.3",
75
- "fumadocs-ui": "16.9.3",
67
+ "fumadocs-core": "16.10.0",
68
+ "fumadocs-ui": "16.10.0",
76
69
  "tsconfig": "0.0.0"
77
70
  },
78
71
  "peerDependencies": {
79
72
  "@scalar/api-client-react": "^2.0.20",
80
73
  "@types/react": "*",
81
- "fumadocs-core": "^16.9.0",
82
- "fumadocs-ui": "^16.9.0",
74
+ "fumadocs-core": "^16.10.0",
75
+ "fumadocs-ui": "^16.10.0",
83
76
  "json-schema-typed": "*",
84
77
  "react": "^19.2.0",
85
78
  "react-dom": "^19.2.0"
@@ -96,14 +89,8 @@
96
89
  }
97
90
  },
98
91
  "inlinedDependencies": {
99
- "@apidevtools/json-schema-ref-parser": "15.3.5",
100
- "@fastify/deepmerge": "3.2.1",
101
- "@scalar/openapi-upgrader": "0.2.8",
102
- "ajv": "8.20.0",
92
+ "@scalar/openapi-upgrader": "0.2.9",
103
93
  "fast-content-type-parse": "3.0.0",
104
- "fast-deep-equal": "3.1.3",
105
- "fast-uri": "3.1.0",
106
- "json-schema-traverse": "1.0.0",
107
94
  "xml-js": "1.6.11"
108
95
  },
109
96
  "scripts": {
@@ -1,239 +0,0 @@
1
- import { getHash, resolve, stripHash } from "./util/url.js";
2
- import { getSchemaBasePath } from "./util/schema-resources.js";
3
- import Pointer from "./pointer.js";
4
- import $Ref from "./ref.js";
5
- //#region ../../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
6
- /**
7
- * Bundles all external JSON references into the main JSON schema, thus resulting in a schema that
8
- * only has *internal* references, not any *external* references.
9
- * This method mutates the JSON schema object, adding new references and re-mapping existing ones.
10
- *
11
- * @param parser
12
- * @param options
13
- */
14
- function bundle(parser, options) {
15
- const rootScopeBase = parser.$refs._root$Ref.dynamicIdScope ? getSchemaBasePath(parser.$refs._root$Ref.path, parser.schema) : parser.$refs._root$Ref.path;
16
- const inventory = [];
17
- crawl(parser, "schema", parser.$refs._root$Ref.path + "#", rootScopeBase, parser.$refs._root$Ref.dynamicIdScope, "#", 0, inventory, parser.$refs, options);
18
- remap(inventory, options, parser.schema && typeof parser.schema === "object" && "$id" in parser.schema ? parser.schema.$id : void 0);
19
- if ((options.bundle || {}).optimizeInternalRefs !== false) fixRefsThroughRefs(inventory, parser.schema);
20
- }
21
- /**
22
- * Recursively crawls the given value, and inventories all JSON references.
23
- *
24
- * @param parent - The object containing the value to crawl. If the value is not an object or array, it will be ignored.
25
- * @param key - The property key of `parent` to be crawled
26
- * @param path - The full path of the property being crawled, possibly with a JSON Pointer in the hash
27
- * @param pathFromRoot - The path of the property being crawled, from the schema root
28
- * @param indirections
29
- * @param inventory - An array of already-inventoried $ref pointers
30
- * @param $refs
31
- * @param options
32
- */
33
- function crawl(parent, key, path, scopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options) {
34
- const obj = key === null ? parent : parent[key];
35
- const bundleOptions = options.bundle || {};
36
- const isExcludedPath = bundleOptions.excludedPathMatcher || (() => false);
37
- if (obj && typeof obj === "object" && !ArrayBuffer.isView(obj) && !isExcludedPath(pathFromRoot)) {
38
- const currentScopeBase = scopeBase;
39
- if ($Ref.isAllowed$Ref(obj)) inventory$Ref(parent, key, path, currentScopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options);
40
- else {
41
- const keys = Object.keys(obj).sort((a, b) => {
42
- if (a === "definitions" || a === "$defs") return -1;
43
- else if (b === "definitions" || b === "$defs") return 1;
44
- else return a.length - b.length;
45
- });
46
- for (const key of keys) {
47
- const keyPath = Pointer.join(path, key);
48
- const keyPathFromRoot = Pointer.join(pathFromRoot, key);
49
- const value = obj[key];
50
- const childScopeBase = dynamicIdScope && value && typeof value === "object" && !ArrayBuffer.isView(value) ? getSchemaBasePath(currentScopeBase, value) : currentScopeBase;
51
- if ($Ref.isAllowed$Ref(value)) inventory$Ref(obj, key, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, indirections, inventory, $refs, options);
52
- else crawl(obj, key, keyPath, childScopeBase, dynamicIdScope, keyPathFromRoot, indirections, inventory, $refs, options);
53
- if (value && typeof value === "object" && !Array.isArray(value)) {
54
- if ("$ref" in value) bundleOptions?.onBundle?.(value["$ref"], obj[key], obj, key);
55
- }
56
- }
57
- }
58
- }
59
- }
60
- /**
61
- * Inventories the given JSON Reference (i.e. records detailed information about it so we can
62
- * optimize all $refs in the schema), and then crawls the resolved value.
63
- *
64
- * @param $refParent - The object that contains a JSON Reference as one of its keys
65
- * @param $refKey - The key in `$refParent` that is a JSON Reference
66
- * @param path - The full path of the JSON Reference at `$refKey`, possibly with a JSON Pointer in the hash
67
- * @param indirections - unknown
68
- * @param pathFromRoot - The path of the JSON Reference at `$refKey`, from the schema root
69
- * @param inventory - An array of already-inventoried $ref pointers
70
- * @param $refs
71
- * @param options
72
- */
73
- function inventory$Ref($refParent, $refKey, path, scopeBase, dynamicIdScope, pathFromRoot, indirections, inventory, $refs, options) {
74
- const $ref = $refKey === null ? $refParent : $refParent[$refKey];
75
- const $refPath = resolve(dynamicIdScope ? scopeBase : path, $ref.$ref);
76
- const pointer = $refs._resolve($refPath, pathFromRoot, options);
77
- if (pointer === null) return;
78
- const depth = Pointer.parse(pathFromRoot).length;
79
- const file = stripHash(pointer.path);
80
- const hash = getHash(pointer.path);
81
- const external = file !== $refs._root$Ref.path && !$refs._aliases[file];
82
- const extended = $Ref.isExtended$Ref($ref);
83
- indirections += pointer.indirections;
84
- const existingEntry = findInInventory(inventory, $refParent, $refKey);
85
- if (existingEntry) if (depth < existingEntry.depth || indirections < existingEntry.indirections) removeFromInventory(inventory, existingEntry);
86
- else return;
87
- inventory.push({
88
- $ref,
89
- parent: $refParent,
90
- key: $refKey,
91
- pathFromRoot,
92
- depth,
93
- file,
94
- hash,
95
- value: pointer.value,
96
- circular: pointer.circular,
97
- extended,
98
- external,
99
- indirections
100
- });
101
- if (!existingEntry || external) crawl(pointer.value, null, pointer.path, pointer.$ref.path, pointer.$ref.dynamicIdScope, pathFromRoot, indirections + 1, inventory, $refs, options);
102
- }
103
- /**
104
- * Re-maps every $ref pointer, so that they're all relative to the root of the JSON Schema.
105
- * Each referenced value is dereferenced EXACTLY ONCE. All subsequent references to the same
106
- * value are re-mapped to point to the first reference.
107
- *
108
- * @example: {
109
- * first: { $ref: somefile.json#/some/part },
110
- * second: { $ref: somefile.json#/another/part },
111
- * third: { $ref: somefile.json },
112
- * fourth: { $ref: somefile.json#/some/part/sub/part }
113
- * }
114
- *
115
- * In this example, there are four references to the same file, but since the third reference points
116
- * to the ENTIRE file, that's the only one we need to dereference. The other three can just be
117
- * remapped to point inside the third one.
118
- *
119
- * On the other hand, if the third reference DIDN'T exist, then the first and second would both need
120
- * to be dereferenced, since they point to different parts of the file. The fourth reference does NOT
121
- * need to be dereferenced, because it can be remapped to point inside the first one.
122
- *
123
- * @param inventory
124
- */
125
- function remap(inventory, options, rootId) {
126
- inventory.sort((a, b) => {
127
- if (a.file !== b.file) return a.file < b.file ? -1 : 1;
128
- else if (a.hash !== b.hash) return a.hash < b.hash ? -1 : 1;
129
- else if (a.circular !== b.circular) return a.circular ? -1 : 1;
130
- else if (a.extended !== b.extended) return a.extended ? 1 : -1;
131
- else if (a.indirections !== b.indirections) return a.indirections - b.indirections;
132
- else if (a.depth !== b.depth) return a.depth - b.depth;
133
- else {
134
- const aDefinitionsIndex = Math.max(a.pathFromRoot.lastIndexOf("/definitions"), a.pathFromRoot.lastIndexOf("/$defs"));
135
- const bDefinitionsIndex = Math.max(b.pathFromRoot.lastIndexOf("/definitions"), b.pathFromRoot.lastIndexOf("/$defs"));
136
- if (aDefinitionsIndex !== bDefinitionsIndex) return bDefinitionsIndex - aDefinitionsIndex;
137
- else return a.pathFromRoot.length - b.pathFromRoot.length;
138
- }
139
- });
140
- let file, hash, pathFromRoot;
141
- for (const entry of inventory) {
142
- const bundleOpts = options.bundle || {};
143
- if (!entry.external) {
144
- if (bundleOpts.optimizeInternalRefs !== false) entry.$ref.$ref = entry.hash;
145
- } else if (entry.file === file && entry.hash === hash) if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + pathFromRoot;
146
- else entry.$ref.$ref = pathFromRoot;
147
- else if (entry.file === file && entry.hash.indexOf(hash + "/") === 0) {
148
- const subPath = Pointer.join(pathFromRoot, Pointer.parse(entry.hash.replace(hash, "#")));
149
- if (rootId && isInsideIdScope(inventory, entry)) entry.$ref.$ref = rootId + subPath;
150
- else entry.$ref.$ref = subPath;
151
- } else {
152
- file = entry.file;
153
- hash = entry.hash;
154
- pathFromRoot = entry.pathFromRoot;
155
- entry.$ref = entry.parent[entry.key] = $Ref.dereference(entry.$ref, entry.value, options);
156
- if (entry.circular) entry.$ref.$ref = entry.pathFromRoot;
157
- }
158
- }
159
- }
160
- /**
161
- * TODO
162
- */
163
- function findInInventory(inventory, $refParent, $refKey) {
164
- for (const existingEntry of inventory) if (existingEntry && existingEntry.parent === $refParent && existingEntry.key === $refKey) return existingEntry;
165
- }
166
- function removeFromInventory(inventory, entry) {
167
- const index = inventory.indexOf(entry);
168
- inventory.splice(index, 1);
169
- }
170
- /**
171
- * After remapping, some $ref paths may traverse through other $ref nodes.
172
- * JSON pointer resolution does not follow $ref indirection, so these paths are invalid.
173
- * This function detects and fixes such paths by following any intermediate $refs
174
- * to compute a valid direct path.
175
- */
176
- function fixRefsThroughRefs(inventory, schema) {
177
- for (const entry of inventory) {
178
- if (!entry.$ref || typeof entry.$ref !== "object" || !("$ref" in entry.$ref)) continue;
179
- const refValue = entry.$ref.$ref;
180
- if (typeof refValue !== "string" || !refValue.startsWith("#/")) continue;
181
- const fixedPath = resolvePathThroughRefs(schema, refValue);
182
- if (fixedPath !== refValue) entry.$ref.$ref = fixedPath;
183
- }
184
- }
185
- /**
186
- * Walks a JSON pointer path through the schema. If any intermediate value
187
- * is a $ref, follows it and adjusts the path accordingly.
188
- * Returns the corrected path that doesn't traverse through any $ref.
189
- */
190
- function resolvePathThroughRefs(schema, refPath) {
191
- if (!refPath.startsWith("#/")) return refPath;
192
- const segments = refPath.slice(2).split("/");
193
- let current = schema;
194
- const resolvedSegments = [];
195
- for (const seg of segments) {
196
- if (current === null || current === void 0 || typeof current !== "object") return refPath;
197
- if ("$ref" in current && typeof current.$ref === "string" && current.$ref.startsWith("#/")) {
198
- const targetSegments = current.$ref.slice(2).split("/");
199
- resolvedSegments.length = 0;
200
- resolvedSegments.push(...targetSegments);
201
- current = walkPath(schema, current.$ref);
202
- if (current === null || current === void 0 || typeof current !== "object") return refPath;
203
- }
204
- const decoded = seg.replace(/~1/g, "/").replace(/~0/g, "~");
205
- current = current[Array.isArray(current) ? parseInt(decoded) : decoded];
206
- resolvedSegments.push(seg);
207
- }
208
- return "#/" + resolvedSegments.join("/");
209
- }
210
- /**
211
- * Walks a JSON pointer path through a schema object, returning the value at that path.
212
- */
213
- function walkPath(schema, path) {
214
- if (!path.startsWith("#/")) return;
215
- const segments = path.slice(2).split("/");
216
- let current = schema;
217
- for (const seg of segments) {
218
- if (current === null || current === void 0 || typeof current !== "object") return;
219
- const decoded = seg.replace(/~1/g, "/").replace(/~0/g, "~");
220
- current = current[Array.isArray(current) ? parseInt(decoded) : decoded];
221
- }
222
- return current;
223
- }
224
- /**
225
- * Checks whether the given inventory entry is located inside a sub-schema that has its own $id.
226
- * If so, root-relative JSON Pointer $refs placed at this location would be resolved against
227
- * the $id base URI rather than the document root, making them invalid.
228
- */
229
- function isInsideIdScope(inventory, entry) {
230
- for (const other of inventory) {
231
- if (other.pathFromRoot === "#" || other.pathFromRoot === "#/") continue;
232
- if (entry.pathFromRoot.startsWith(other.pathFromRoot + "/")) {
233
- if (other.value && typeof other.value === "object" && "$id" in other.value) return true;
234
- }
235
- }
236
- return false;
237
- }
238
- //#endregion
239
- export { bundle as default };