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.
- package/css/generated/shared.css +1 -1151
- package/css/preset.css +1 -0
- package/dist/.translations/index.d.ts +80 -0
- package/dist/.translations/keys.js +80 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -10
- package/dist/generate-file.d.ts +0 -4
- package/dist/generate-file.js +4 -5
- package/dist/i18n.d.ts +5 -100
- package/dist/i18n.js +8 -108
- package/dist/index.d.ts +4 -4
- 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
- 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
- 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
- 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
- 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
- package/dist/playground/auth.js +4 -4
- package/dist/playground/client.d.ts +12 -21
- package/dist/playground/client.js +80 -59
- package/dist/playground/components/oauth-dialog.js +33 -33
- package/dist/playground/components/result-display.d.ts +1 -2
- package/dist/playground/components/result-display.js +7 -8
- package/dist/playground/components/server-select.js +11 -11
- package/dist/playground/status-info.js +29 -37
- package/dist/requests/generators/csharp.js +3 -3
- package/dist/requests/generators/curl.js +2 -2
- package/dist/requests/generators/go.js +2 -2
- package/dist/requests/generators/index.d.ts +28 -41
- package/dist/requests/generators/index.js +18 -35
- package/dist/requests/generators/java.js +2 -2
- package/dist/requests/generators/javascript.js +2 -2
- package/dist/requests/generators/python.js +2 -2
- package/dist/scalar/client.js +3 -2
- package/dist/scalar/index.d.ts +2 -2
- package/dist/scalar/index.js +10 -9
- package/dist/server/index.d.ts +23 -27
- package/dist/server/index.js +42 -38
- package/dist/server/proxy.d.ts +0 -6
- package/dist/server/proxy.js +2 -4
- package/dist/{_openapi/types.d.ts → types/openapi.d.ts} +127 -136
- package/dist/types.d.ts +14 -18
- package/dist/ui/base.d.ts +15 -162
- package/dist/ui/base.js +148 -107
- package/dist/ui/components/codeblock.js +6 -14
- package/dist/ui/components/heading.js +8 -4
- package/dist/ui/components/markdown.js +12 -0
- package/dist/ui/contexts/api.js +8 -26
- package/dist/ui/index.d.ts +204 -7
- package/dist/ui/index.js +10 -15
- package/dist/ui/operation/context.js +48 -0
- package/dist/ui/operation/index.js +168 -126
- package/dist/ui/operation/request-tabs.d.ts +10 -5
- package/dist/ui/operation/request-tabs.js +35 -22
- package/dist/ui/operation/response-tabs.d.ts +5 -2
- package/dist/ui/operation/response-tabs.js +22 -15
- package/dist/ui/operation/usage-tabs.js +144 -0
- package/dist/utils/document/dereference.d.ts +1 -1
- package/dist/utils/document/dereference.js +5 -8
- package/dist/utils/document/load.js +17 -0
- package/dist/utils/get-example-requests.d.ts +13 -0
- package/dist/{ui/operation → utils}/get-example-requests.js +31 -20
- package/dist/utils/pages/builder.d.ts +38 -10
- package/dist/utils/pages/builder.js +12 -10
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +15 -15
- package/dist/utils/pages/to-static-data.js +5 -4
- package/dist/utils/pages/to-text.d.ts +1 -0
- package/dist/utils/pages/to-text.js +21 -11
- package/dist/utils/remove-undefined.js +14 -9
- package/dist/utils/schema.d.ts +2 -0
- package/dist/utils/{schema/index.js → schema.js} +3 -30
- package/dist/{ui/client → utils}/storage-key.js +3 -3
- package/package.json +16 -29
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +0 -108
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +0 -110
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +0 -138
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +0 -674
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +0 -141
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +0 -102
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +0 -223
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +0 -133
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +0 -146
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +0 -172
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +0 -433
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +0 -113
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +0 -583
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +0 -42
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +0 -50
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +0 -36
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +0 -85
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -57
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -96
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -29
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -89
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -87
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -62
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -60
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -34
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -52
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -41
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +0 -130
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +0 -112
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -101
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +0 -35
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +0 -45
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +0 -15
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +0 -10
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +0 -13
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -49
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -47
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -38
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -70
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +0 -33
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -236
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -187
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -282
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +0 -78
- package/dist/playground/components/inputs.js +0 -419
- package/dist/playground/components/spinner.js +0 -15
- package/dist/playground/schema.d.ts +0 -15
- package/dist/playground/schema.js +0 -144
- package/dist/ui/api-page.d.ts +0 -31
- package/dist/ui/api-page.js +0 -59
- package/dist/ui/client/boundary.d.ts +0 -11
- package/dist/ui/client/boundary.js +0 -17
- package/dist/ui/client/boundary.lazy.js +0 -19
- package/dist/ui/client/full.js +0 -13
- package/dist/ui/client/i18n.js +0 -16
- package/dist/ui/client/index.d.ts +0 -42
- package/dist/ui/client/index.js +0 -7
- package/dist/ui/components/accordion.js +0 -67
- package/dist/ui/components/codeblock.d.ts +0 -14
- package/dist/ui/components/dialog.js +0 -56
- package/dist/ui/components/input.js +0 -17
- package/dist/ui/components/select-tab.js +0 -56
- package/dist/ui/components/select.js +0 -71
- package/dist/ui/contexts/api.d.ts +0 -29
- package/dist/ui/create-client.d.ts +0 -26
- package/dist/ui/create-client.js +0 -125
- package/dist/ui/operation/client.js +0 -78
- package/dist/ui/operation/get-example-requests.d.ts +0 -11
- package/dist/ui/operation/usage-tabs/client.d.ts +0 -14
- package/dist/ui/operation/usage-tabs/client.js +0 -91
- package/dist/ui/operation/usage-tabs/index.js +0 -54
- package/dist/ui/schema/client.d.ts +0 -18
- package/dist/ui/schema/client.js +0 -409
- package/dist/ui/schema/index.d.ts +0 -61
- package/dist/ui/schema/index.js +0 -256
- package/dist/utils/auto-anchor.client.js +0 -20
- package/dist/utils/auto-anchor.js +0 -17
- package/dist/utils/deep-equal.js +0 -21
- package/dist/utils/document/process.d.ts +0 -6
- package/dist/utils/document/process.js +0 -18
- package/dist/utils/id-to-title.js +0 -12
- package/dist/utils/is-plain-object.js +0 -8
- package/dist/utils/merge-refs.js +0 -11
- package/dist/utils/schema/dereference.js +0 -45
- package/dist/utils/schema/index.d.ts +0 -18
- package/dist/utils/schema/merge.js +0 -156
- package/dist/utils/schema/pick.js +0 -44
- package/dist/utils/schema/ref.js +0 -35
- package/dist/utils/schema/resolve-ref.js +0 -11
- package/dist/utils/schema/sample.js +0 -442
- package/dist/utils/schema/to-string.d.ts +0 -1
- package/dist/utils/schema/to-string.js +0 -53
- package/dist/utils/url.js +0 -39
package/dist/types.d.ts
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
|
+
import { OpenAPIV3_2 } from "./types/openapi.js";
|
|
2
|
+
import { DereferencedDocument } from "./utils/document/dereference.js";
|
|
1
3
|
import { InlineCodeUsageGenerator } from "./requests/generators/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import { OpenAPIV3_2 } from "./_openapi/types.js";
|
|
4
|
-
import { CreateAPIPageOptions } from "./ui/base.js";
|
|
4
|
+
import { CreateOpenAPIPageOptions } from "./ui/index.js";
|
|
5
5
|
import { OpenAPIOptions } from "./server/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { FC, ReactNode } from "react";
|
|
7
|
+
import { SchemaUIOptions } from "@fumadocs/api-docs/components/schema";
|
|
8
8
|
|
|
9
9
|
//#region src/types.d.ts
|
|
10
10
|
type Document = OpenAPIV3_2.Document;
|
|
11
|
-
type OperationObject = OpenAPIV3_2.OperationObject
|
|
11
|
+
type OperationObject = OpenAPIV3_2.OperationObject & {
|
|
12
|
+
'x-codeSamples'?: InlineCodeUsageGenerator[];
|
|
13
|
+
'x-selectedCodeSample'?: string;
|
|
14
|
+
'x-exclusiveCodeSample'?: string;
|
|
15
|
+
};
|
|
12
16
|
type ParameterObject = OpenAPIV3_2.ParameterObject;
|
|
13
|
-
type SecuritySchemeObject = OpenAPIV3_2.SecuritySchemeObject;
|
|
14
|
-
type ReferenceObject = OpenAPIV3_2.ReferenceObject;
|
|
15
17
|
type PathItemObject = OpenAPIV3_2.PathItemObject;
|
|
16
18
|
type TagObject = OpenAPIV3_2.TagObject;
|
|
17
|
-
type ServerObject = OpenAPIV3_2.ServerObject;
|
|
18
19
|
type ResponseObject = OpenAPIV3_2.ResponseObject;
|
|
19
20
|
type HttpMethods = OpenAPIV3_2.HttpMethods;
|
|
20
|
-
type MethodInformation = NoReference<OperationObject> & {
|
|
21
|
-
method: HttpMethods;
|
|
22
|
-
'x-codeSamples'?: InlineCodeUsageGenerator[];
|
|
23
|
-
'x-selectedCodeSample'?: string;
|
|
24
|
-
'x-exclusiveCodeSample'?: string;
|
|
25
|
-
};
|
|
26
21
|
type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
27
|
-
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<
|
|
22
|
+
interface RenderContext extends Pick<OpenAPIOptions, 'proxyUrl'>, Omit<RequireKeys<CreateOpenAPIPageOptions, 'generateTypeScriptDefinitions' | 'mediaAdapters' | 'codeUsages' | 'shikiOptions' | 'shiki'>, 'schemaUI'> {
|
|
28
23
|
/**
|
|
29
24
|
* dereferenced schema
|
|
30
25
|
*/
|
|
31
26
|
schema: DereferencedDocument;
|
|
32
|
-
|
|
27
|
+
_default_processMarkdown: (md: string) => ReactNode;
|
|
28
|
+
SchemaUI: FC<Omit<SchemaUIOptions, 'resolver' | 'renderMarkdown'>>;
|
|
33
29
|
}
|
|
34
30
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
35
31
|
type Awaitable<T> = T | Promise<T>;
|
|
36
32
|
//#endregion
|
|
37
|
-
export { Awaitable, DistributiveOmit, Document, HttpMethods,
|
|
33
|
+
export { Awaitable, DistributiveOmit, Document, HttpMethods, OperationObject, ParameterObject, PathItemObject, RenderContext, ResponseObject, TagObject };
|
package/dist/ui/base.d.ts
CHANGED
|
@@ -1,167 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ExampleRequestItem } from "./operation/get-example-requests.js";
|
|
4
|
-
import { APIPageClientOptions } from "./client/index.js";
|
|
5
|
-
import { SchemaUIOptions } from "./schema/index.js";
|
|
6
|
-
import { ApiPageProps, OperationItem, WebhookItem } from "./api-page.js";
|
|
7
|
-
import { ResponseTab } from "./operation/response-tabs.js";
|
|
8
|
-
import { RequestTabsRenderContext } from "./operation/request-tabs.js";
|
|
9
|
-
import { ClientCodeBlockProvider } from "./components/codeblock.js";
|
|
10
|
-
import { OpenAPIServer } from "../server/index.js";
|
|
11
|
-
import { Awaitable, MethodInformation, RenderContext } from "../types.js";
|
|
12
|
-
import { NoReference } from "../utils/schema/index.js";
|
|
13
|
-
import { DereferencedDocument } from "../utils/document/dereference.js";
|
|
14
|
-
import { FC, HTMLAttributes, ReactNode } from "react";
|
|
1
|
+
import { CreateOpenAPIPageOptions, OpenAPIPageProps } from "./index.js";
|
|
2
|
+
import { FC } from "react";
|
|
15
3
|
import { ShikiFactory } from "fumadocs-core/highlight/shiki";
|
|
16
|
-
import { JSONSchema } from "json-schema-typed";
|
|
17
|
-
import { BundledTheme, CodeOptionsThemes, CodeToHastOptionsCommon } from "shiki";
|
|
18
4
|
|
|
19
5
|
//#region src/ui/base.d.ts
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
path: string;
|
|
32
|
-
method: MethodInformation;
|
|
33
|
-
ctx: RenderContext;
|
|
34
|
-
}
|
|
35
|
-
interface CreateAPIPageOptions {
|
|
36
|
-
/**
|
|
37
|
-
* Generate TypeScript definitions from response schema.
|
|
38
|
-
*
|
|
39
|
-
* Pass `false` to disable it.
|
|
40
|
-
*
|
|
41
|
-
* @param method - the operation object
|
|
42
|
-
* @param statusCode - status code
|
|
43
|
-
* @deprecated use `generateTypeScriptDefinitions` instead.
|
|
44
|
-
*/
|
|
45
|
-
generateTypeScriptSchema?: ((method: NoReference<MethodInformation>, statusCode: string, contentType: string, ctx: RenderContext) => Awaitable<string | undefined>) | false;
|
|
46
|
-
/**
|
|
47
|
-
* Generate TypeScript definitions from JSON schema.
|
|
48
|
-
*
|
|
49
|
-
* Pass `false` to disable it.
|
|
50
|
-
*/
|
|
51
|
-
generateTypeScriptDefinitions?: ((schema: JSONSchema, ctx: GenerateTypeScriptDefinitionsContext) => Awaitable<string | undefined>) | false;
|
|
52
|
-
/**
|
|
53
|
-
* Generate example code usage for all endpoints.
|
|
54
|
-
*/
|
|
55
|
-
codeUsages?: CodeUsageGeneratorRegistry;
|
|
56
|
-
/**
|
|
57
|
-
* Generate example code usage for each endpoint.
|
|
58
|
-
*/
|
|
59
|
-
generateCodeSamples?: (method: MethodInformation) => InlineCodeUsageGenerator[];
|
|
6
|
+
/**
|
|
7
|
+
* Create `<OpenAPIPage />` (a client component) without the full Shiki bundle.
|
|
8
|
+
*/
|
|
9
|
+
declare function createOpenAPIPageBase({
|
|
10
|
+
shiki,
|
|
11
|
+
shikiOptions,
|
|
12
|
+
schemaUI: schemaUIOptions,
|
|
13
|
+
codeUsages,
|
|
14
|
+
generateTypeScriptDefinitions,
|
|
15
|
+
...options
|
|
16
|
+
}: CreateOpenAPIPageOptions & {
|
|
60
17
|
shiki: ShikiFactory;
|
|
61
|
-
|
|
62
|
-
shikiOptions: Omit<CodeToHastOptionsCommon, 'lang'> & CodeOptionsThemes<BundledTheme>;
|
|
63
|
-
/**
|
|
64
|
-
* Show full response schema instead of only example response & Typescript definitions.
|
|
65
|
-
*
|
|
66
|
-
* @default true
|
|
67
|
-
*/
|
|
68
|
-
showResponseSchema?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Support other media types (for server-side generation).
|
|
71
|
-
*/
|
|
72
|
-
mediaAdapters?: Record<string, MediaAdapter>;
|
|
73
|
-
/**
|
|
74
|
-
* Customize page content
|
|
75
|
-
*/
|
|
76
|
-
content?: {
|
|
77
|
-
renderResponseTabs?: (tabs: ResponseTab[], ctx: RenderContext) => ReactNode;
|
|
78
|
-
renderRequestTabs?: (items: ExampleRequestItem[], ctx: RequestTabsRenderContext) => ReactNode;
|
|
79
|
-
renderAPIExampleLayout?: (slots: {
|
|
80
|
-
selector: ReactNode;
|
|
81
|
-
usageTabs: ReactNode;
|
|
82
|
-
responseTabs: ReactNode;
|
|
83
|
-
}, ctx: RenderContext) => ReactNode;
|
|
84
|
-
/**
|
|
85
|
-
* @param generators - codegens for API example usages
|
|
86
|
-
*/
|
|
87
|
-
renderAPIExampleUsageTabs?: (generators: CodeUsageGeneratorRegistry, ctx: RenderContext) => ReactNode;
|
|
88
|
-
/**
|
|
89
|
-
* renderer of the entire page's layout (containing all operations & webhooks UI)
|
|
90
|
-
*/
|
|
91
|
-
renderPageLayout?: (slots: {
|
|
92
|
-
operations?: {
|
|
93
|
-
item: OperationItem;
|
|
94
|
-
children: ReactNode;
|
|
95
|
-
}[];
|
|
96
|
-
webhooks?: {
|
|
97
|
-
item: WebhookItem;
|
|
98
|
-
children: ReactNode;
|
|
99
|
-
}[];
|
|
100
|
-
}, ctx: RenderContext) => ReactNode;
|
|
101
|
-
renderOperationLayout?: (slots: {
|
|
102
|
-
header: ReactNode;
|
|
103
|
-
description: ReactNode;
|
|
104
|
-
apiExample: ReactNode;
|
|
105
|
-
apiPlayground: ReactNode;
|
|
106
|
-
authSchemes: ReactNode;
|
|
107
|
-
parameters: ReactNode;
|
|
108
|
-
body: ReactNode;
|
|
109
|
-
responses: ReactNode;
|
|
110
|
-
callbacks: ReactNode;
|
|
111
|
-
}, ctx: RenderContext, method: NoReference<MethodInformation>) => ReactNode;
|
|
112
|
-
renderWebhookLayout?: (slots: {
|
|
113
|
-
header: ReactNode;
|
|
114
|
-
description: ReactNode;
|
|
115
|
-
authSchemes: ReactNode;
|
|
116
|
-
parameters: ReactNode;
|
|
117
|
-
body: ReactNode;
|
|
118
|
-
requests: ReactNode;
|
|
119
|
-
responses: ReactNode;
|
|
120
|
-
callbacks: ReactNode;
|
|
121
|
-
}) => ReactNode;
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Info UI for JSON schemas
|
|
125
|
-
*/
|
|
126
|
-
schemaUI?: {
|
|
127
|
-
render?: (options: SchemaUIOptions, ctx: RenderContext) => ReactNode;
|
|
128
|
-
/**
|
|
129
|
-
* Show examples under the generated content of JSON schemas.
|
|
130
|
-
*
|
|
131
|
-
* @defaultValue false
|
|
132
|
-
*/
|
|
133
|
-
showExample?: boolean;
|
|
134
|
-
};
|
|
135
|
-
/**
|
|
136
|
-
* Customize API playground
|
|
137
|
-
*/
|
|
138
|
-
playground?: {
|
|
139
|
-
/**
|
|
140
|
-
* @defaultValue true
|
|
141
|
-
*/
|
|
142
|
-
enabled?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* render a page-level provider (useful for handling auth)
|
|
145
|
-
*/
|
|
146
|
-
provider?: (props: {
|
|
147
|
-
children: ReactNode;
|
|
148
|
-
}) => ReactNode;
|
|
149
|
-
/**
|
|
150
|
-
* replace the renderer
|
|
151
|
-
*/
|
|
152
|
-
render?: (props: APIPlaygroundProps) => ReactNode;
|
|
153
|
-
};
|
|
154
|
-
/** @deprecated no longer used */
|
|
155
|
-
renderHeading?: (props: HTMLAttributes<HTMLHeadingElement>, depth: number) => ReactNode;
|
|
156
|
-
renderCodeBlock?: (props: {
|
|
157
|
-
lang: string;
|
|
158
|
-
code: string;
|
|
159
|
-
}) => ReactNode;
|
|
160
|
-
client?: APIPageClientOptions;
|
|
161
|
-
}
|
|
162
|
-
interface ServerApiPageProps extends Omit<ApiPageProps, 'document'> {
|
|
163
|
-
document: string | DereferencedDocument;
|
|
164
|
-
}
|
|
165
|
-
declare function createAPIPage(server: OpenAPIServer, options: CreateAPIPageOptions): FC<ServerApiPageProps>;
|
|
18
|
+
}): FC<OpenAPIPageProps>;
|
|
166
19
|
//#endregion
|
|
167
|
-
export {
|
|
20
|
+
export { createOpenAPIPageBase };
|
package/dist/ui/base.js
CHANGED
|
@@ -1,135 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { RenderContextProvider, ServerProvider, useRenderContext } from "./contexts/api.js";
|
|
3
|
+
import { ClientCodeBlock } from "./components/codeblock.js";
|
|
3
4
|
import { createCodeUsageGeneratorRegistry } from "../requests/generators/index.js";
|
|
5
|
+
import { defaultAdapters } from "../requests/media/adapter.js";
|
|
6
|
+
import { AuthProvider } from "../playground/auth.js";
|
|
7
|
+
import { Markdown } from "./components/markdown.js";
|
|
8
|
+
import { Operation } from "./operation/index.js";
|
|
9
|
+
import { dereferenceBundledDocument } from "../utils/document/dereference.js";
|
|
4
10
|
import { registerDefault } from "../requests/generators/all.js";
|
|
5
|
-
import {
|
|
6
|
-
import { encodeInternalRef } from "../utils/schema/ref.js";
|
|
7
|
-
import { APIPage } from "./api-page.js";
|
|
8
|
-
import { pickSchema } from "../utils/schema/pick.js";
|
|
9
|
-
import { PlaygroundAuthProvider } from "./client/boundary.lazy.js";
|
|
11
|
+
import { Children, useMemo } from "react";
|
|
10
12
|
import * as JsxRuntime from "react/jsx-runtime";
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
import { createRehypeCode } from "fumadocs-core/mdx-plugins/rehype-code.core";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { remarkGfm } from "fumadocs-core/mdx-plugins/remark-gfm";
|
|
14
15
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
15
16
|
import { remark } from "remark";
|
|
16
17
|
import remarkRehype from "remark-rehype";
|
|
17
18
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
18
|
-
import { CodeBlock, Pre } from "fumadocs-ui/components/codeblock";
|
|
19
|
-
import { highlightHast } from "fumadocs-core/highlight/shiki";
|
|
20
19
|
import { compile } from "@fumari/json-schema-ts";
|
|
20
|
+
import { Schema } from "@fumadocs/api-docs/components/schema";
|
|
21
21
|
//#region src/ui/base.tsx
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Create `<OpenAPIPage />` (a client component) without the full Shiki bundle.
|
|
24
|
+
*/
|
|
25
|
+
function createOpenAPIPageBase({ shiki, shikiOptions = { themes: {
|
|
26
|
+
light: "github-light",
|
|
27
|
+
dark: "github-dark"
|
|
28
|
+
} }, schemaUI: schemaUIOptions, codeUsages = registerDefault(createCodeUsageGeneratorRegistry()), generateTypeScriptDefinitions = (schema, ctx) => {
|
|
29
|
+
if (typeof schema !== "object") return;
|
|
30
|
+
try {
|
|
31
|
+
return compile(schema, {
|
|
32
|
+
name: "Response",
|
|
33
|
+
readOnly: ctx.readOnly,
|
|
34
|
+
writeOnly: ctx.writeOnly,
|
|
35
|
+
getSchemaId: ctx.ctx.schema.getRawRef
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.warn("Failed to generate typescript schema:", e);
|
|
39
|
+
}
|
|
40
|
+
}, ...options }) {
|
|
23
41
|
let processor;
|
|
24
42
|
function createMarkdownProcessor() {
|
|
43
|
+
const mdxComponents = {
|
|
44
|
+
...defaultMdxComponents,
|
|
45
|
+
img: void 0,
|
|
46
|
+
pre: MarkdownPre
|
|
47
|
+
};
|
|
25
48
|
function rehypeReact() {
|
|
26
49
|
this.compiler = (tree, file) => {
|
|
27
50
|
return toJsxRuntime(tree, {
|
|
28
51
|
development: false,
|
|
29
52
|
filePath: file.path,
|
|
30
53
|
...JsxRuntime,
|
|
31
|
-
components:
|
|
54
|
+
components: mdxComponents
|
|
32
55
|
});
|
|
33
56
|
};
|
|
34
57
|
}
|
|
35
|
-
return remark().use(remarkGfm).use(remarkRehype).use(
|
|
36
|
-
langs: [],
|
|
37
|
-
lazy: true,
|
|
38
|
-
defaultColor: false,
|
|
39
|
-
...options.shikiOptions
|
|
40
|
-
}).use(rehypeReact);
|
|
41
|
-
}
|
|
42
|
-
function renderPlaygroundProviderDefault({ children }) {
|
|
43
|
-
return /* @__PURE__ */ jsx(PlaygroundAuthProvider, { children });
|
|
58
|
+
return remark().use(remarkGfm).use(remarkRehype).use(rehypeReact);
|
|
44
59
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
doc
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
...options.mediaAdapters
|
|
82
|
-
},
|
|
83
|
-
playground: {
|
|
84
|
-
...options.playground,
|
|
85
|
-
provider: options.playground?.provider ?? renderPlaygroundProviderDefault,
|
|
86
|
-
render: options.playground?.render ?? renderPlaygroundDefault
|
|
87
|
-
},
|
|
88
|
-
generateTypeScriptDefinitions: options.generateTypeScriptDefinitions ?? ((schema, ctx) => {
|
|
89
|
-
if (options.generateTypeScriptSchema && ctx._internal_legacy) {
|
|
90
|
-
const { statusCode, contentType } = ctx._internal_legacy;
|
|
91
|
-
return options.generateTypeScriptSchema(ctx.operation, statusCode, contentType, ctx);
|
|
92
|
-
}
|
|
93
|
-
if (typeof schema !== "object") return;
|
|
94
|
-
try {
|
|
95
|
-
return compile(schema, {
|
|
96
|
-
name: "Response",
|
|
97
|
-
readOnly: ctx.readOnly,
|
|
98
|
-
writeOnly: ctx.writeOnly,
|
|
99
|
-
getSchemaId: ctx.schema.getRawRef
|
|
60
|
+
return function OpenAPIPage(props) {
|
|
61
|
+
let doc;
|
|
62
|
+
let proxyUrl;
|
|
63
|
+
if ("preloaded" in props) {
|
|
64
|
+
doc = props.preloaded.docs[props.document];
|
|
65
|
+
if (!doc) throw new Error(`[Fumadocs OpenAPI] the document ${props.document} is not preloaded, make sure to pass the "preloaded" prop to <OpenAPIPage />`);
|
|
66
|
+
proxyUrl = props.preloaded.proxyUrl;
|
|
67
|
+
} else {
|
|
68
|
+
doc = props.payload.bundled;
|
|
69
|
+
proxyUrl = props.payload.proxyUrl;
|
|
70
|
+
}
|
|
71
|
+
const processed = useMemo(() => dereferenceBundledDocument(doc), [doc]);
|
|
72
|
+
const ctx = useMemo(() => {
|
|
73
|
+
function renderMarkdown(md) {
|
|
74
|
+
return /* @__PURE__ */ jsx(Markdown, { md });
|
|
75
|
+
}
|
|
76
|
+
function resolver(v) {
|
|
77
|
+
return {
|
|
78
|
+
dereferenced: v,
|
|
79
|
+
$ref: typeof v === "object" ? processed.getRawRef(v) : void 0
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
schema: processed,
|
|
84
|
+
proxyUrl,
|
|
85
|
+
shiki,
|
|
86
|
+
shikiOptions,
|
|
87
|
+
generateTypeScriptDefinitions,
|
|
88
|
+
codeUsages,
|
|
89
|
+
SchemaUI(props) {
|
|
90
|
+
if (schemaUIOptions?.render) return schemaUIOptions.render(props, ctx);
|
|
91
|
+
return /* @__PURE__ */ jsx(Schema, {
|
|
92
|
+
...props,
|
|
93
|
+
showExample: props.showExample ?? schemaUIOptions?.showExample,
|
|
94
|
+
resolver,
|
|
95
|
+
renderMarkdown
|
|
100
96
|
});
|
|
101
|
-
}
|
|
102
|
-
|
|
97
|
+
},
|
|
98
|
+
...options,
|
|
99
|
+
_default_processMarkdown(md) {
|
|
100
|
+
processor ??= createMarkdownProcessor();
|
|
101
|
+
return processor.processSync(md).result;
|
|
102
|
+
},
|
|
103
|
+
mediaAdapters: {
|
|
104
|
+
...defaultAdapters,
|
|
105
|
+
...options.mediaAdapters
|
|
103
106
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
async renderCodeBlock({ lang, code }) {
|
|
111
|
-
if (options.renderCodeBlock) return options.renderCodeBlock({
|
|
112
|
-
lang,
|
|
113
|
-
code
|
|
114
|
-
});
|
|
115
|
-
return /* @__PURE__ */ jsx(CodeBlock, {
|
|
116
|
-
className: "my-0",
|
|
117
|
-
children: toJsxRuntime(await highlightHast(await options.shiki.getOrInit(), code, {
|
|
118
|
-
lang,
|
|
119
|
-
defaultColor: false,
|
|
120
|
-
...options.shikiOptions
|
|
121
|
-
}), {
|
|
122
|
-
...JsxRuntime,
|
|
123
|
-
components: { pre: Pre }
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
return /* @__PURE__ */ jsx(APIPage, {
|
|
129
|
-
...props,
|
|
130
|
-
ctx
|
|
107
|
+
};
|
|
108
|
+
}, [proxyUrl, processed]);
|
|
109
|
+
return /* @__PURE__ */ jsx(RenderContextProvider, {
|
|
110
|
+
ctx,
|
|
111
|
+
children: /* @__PURE__ */ jsx(PageContent, { ...props })
|
|
131
112
|
});
|
|
132
113
|
};
|
|
133
114
|
}
|
|
115
|
+
function PageContent({ showTitle: hasHead = false, showDescription, operations, webhooks }) {
|
|
116
|
+
const ctx = useRenderContext();
|
|
117
|
+
const { dereferenced } = ctx.schema;
|
|
118
|
+
let { renderPageLayout } = ctx.content ?? {};
|
|
119
|
+
renderPageLayout ??= (slots) => /* @__PURE__ */ jsxs("div", {
|
|
120
|
+
className: "flex flex-col gap-24 text-sm @container",
|
|
121
|
+
children: [slots.operations?.map((op) => op.children), slots.webhooks?.map((op) => op.children)]
|
|
122
|
+
});
|
|
123
|
+
let content = renderPageLayout({
|
|
124
|
+
operations: operations?.map((item) => {
|
|
125
|
+
const pathItem = dereferenced.paths?.[item.path];
|
|
126
|
+
if (!pathItem) throw new Error(`[Fumadocs OpenAPI] Path not found in OpenAPI schema: ${item.path}`);
|
|
127
|
+
const operation = pathItem[item.method];
|
|
128
|
+
if (!operation) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in operation: ${item.path}`);
|
|
129
|
+
return {
|
|
130
|
+
item,
|
|
131
|
+
children: /* @__PURE__ */ jsx(Operation, {
|
|
132
|
+
method: item.method,
|
|
133
|
+
pathItem,
|
|
134
|
+
operation,
|
|
135
|
+
path: item.path,
|
|
136
|
+
showTitle: hasHead,
|
|
137
|
+
showDescription
|
|
138
|
+
}, `${item.path}:${item.method}`)
|
|
139
|
+
};
|
|
140
|
+
}),
|
|
141
|
+
webhooks: webhooks?.map((item) => {
|
|
142
|
+
const webhook = dereferenced.webhooks?.[item.name];
|
|
143
|
+
if (!webhook) throw new Error(`[Fumadocs OpenAPI] Webhook not found in OpenAPI schema: ${item.name}`);
|
|
144
|
+
const hook = webhook[item.method];
|
|
145
|
+
if (!hook) throw new Error(`[Fumadocs OpenAPI] Method ${item.method} not found in webhook: ${item.name}`);
|
|
146
|
+
return {
|
|
147
|
+
item,
|
|
148
|
+
children: /* @__PURE__ */ jsx(Operation, {
|
|
149
|
+
type: "webhook",
|
|
150
|
+
method: item.method,
|
|
151
|
+
pathItem: webhook,
|
|
152
|
+
operation: hook,
|
|
153
|
+
path: `/${item.name}`,
|
|
154
|
+
showTitle: hasHead,
|
|
155
|
+
showDescription
|
|
156
|
+
}, `${item.name}:${item.method}`)
|
|
157
|
+
};
|
|
158
|
+
})
|
|
159
|
+
}, ctx);
|
|
160
|
+
if (ctx.playground?.enabled !== false) content = ctx.playground?.provider ? ctx.playground.provider({ children: content }) : /* @__PURE__ */ jsx(AuthProvider, { children: content });
|
|
161
|
+
return /* @__PURE__ */ jsx(ServerProvider, {
|
|
162
|
+
servers: dereferenced.servers,
|
|
163
|
+
children: content
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function MarkdownPre(props) {
|
|
167
|
+
const codeProps = Children.only(props.children).props;
|
|
168
|
+
const content = codeProps.children;
|
|
169
|
+
if (typeof content !== "string") return null;
|
|
170
|
+
return /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
171
|
+
lang: codeProps.className?.split(" ").find((v) => v.startsWith("language-"))?.slice(9) ?? "text",
|
|
172
|
+
code: content.trimEnd()
|
|
173
|
+
});
|
|
174
|
+
}
|
|
134
175
|
//#endregion
|
|
135
|
-
export {
|
|
176
|
+
export { createOpenAPIPageBase };
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { createContext, use } from "react";
|
|
2
|
+
import { useRenderContext } from "../contexts/api.js";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock.core";
|
|
6
5
|
//#region src/ui/components/codeblock.tsx
|
|
7
|
-
const CodeBlockContext = createContext(null);
|
|
8
6
|
function ClientCodeBlock(props) {
|
|
9
|
-
const { shikiOptions } =
|
|
10
|
-
|
|
11
|
-
if (
|
|
7
|
+
const { shiki, shikiOptions, renderCodeBlock, components: { CodeBlock: Comp } = {} } = useRenderContext();
|
|
8
|
+
if (renderCodeBlock) return renderCodeBlock(props);
|
|
9
|
+
if (Comp) return /* @__PURE__ */ jsx(Comp, { ...props });
|
|
12
10
|
return /* @__PURE__ */ jsx(DynamicCodeBlock, {
|
|
13
|
-
highlighter: () =>
|
|
11
|
+
highlighter: () => shiki.getOrInit(),
|
|
14
12
|
options: shikiOptions,
|
|
15
13
|
...props
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
|
-
function ClientCodeBlockProvider({ factory, children }) {
|
|
19
|
-
return /* @__PURE__ */ jsx(CodeBlockContext, {
|
|
20
|
-
value: factory,
|
|
21
|
-
children
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
16
|
//#endregion
|
|
25
|
-
export { ClientCodeBlock
|
|
17
|
+
export { ClientCodeBlock };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useAnchorId } from "../../utils/auto-anchor.client.js";
|
|
2
|
+
import { useRenderContext } from "../contexts/api.js";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useAnchorId } from "@fumadocs/api-docs/auto-anchor/client";
|
|
5
5
|
import { Heading } from "fumadocs-ui/components/heading";
|
|
6
6
|
//#region src/ui/components/heading.tsx
|
|
7
7
|
function Heading$1({ id: _id, depth, ...props }) {
|
|
8
8
|
const id = useAnchorId([_id]);
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
9
|
+
const { renderHeading, components: { Heading: Comp } = {} } = useRenderContext();
|
|
10
|
+
if (renderHeading) return renderHeading({
|
|
11
|
+
id,
|
|
12
|
+
...props
|
|
13
|
+
}, depth);
|
|
14
|
+
if (Comp) return /* @__PURE__ */ jsx(Comp, {
|
|
11
15
|
id,
|
|
12
16
|
depth,
|
|
13
17
|
...props
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useRenderContext } from "../contexts/api.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/ui/components/markdown.tsx
|
|
5
|
+
function Markdown({ md }) {
|
|
6
|
+
const { _default_processMarkdown: processMarkdown, renderMarkdown, components: { Markdown: Comp } = {} } = useRenderContext();
|
|
7
|
+
if (renderMarkdown) return renderMarkdown(md);
|
|
8
|
+
if (Comp) return /* @__PURE__ */ jsx(Comp, { md });
|
|
9
|
+
return useMemo(() => processMarkdown(md), [processMarkdown, md]);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Markdown };
|
package/dist/ui/contexts/api.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useStorageKey } from "../client/storage-key.js";
|
|
4
|
-
import { createCodeUsageGeneratorRegistry } from "../../requests/generators/index.js";
|
|
5
|
-
import { registerDefault } from "../../requests/generators/all.js";
|
|
2
|
+
import { useStorageKey } from "../../utils/storage-key.js";
|
|
6
3
|
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
7
4
|
import { jsx } from "react/jsx-runtime";
|
|
8
5
|
//#region src/ui/contexts/api.tsx
|
|
9
|
-
const
|
|
6
|
+
const Context = createContext(null);
|
|
10
7
|
const ServerContext = createContext(null);
|
|
11
|
-
function
|
|
12
|
-
const ctx = use(
|
|
8
|
+
function useRenderContext() {
|
|
9
|
+
const ctx = use(Context);
|
|
13
10
|
if (!ctx) throw new Error("Component must be used under <ApiProvider />");
|
|
14
11
|
return ctx;
|
|
15
12
|
}
|
|
@@ -18,24 +15,9 @@ function useServerContext() {
|
|
|
18
15
|
if (!ctx) throw new Error("Component must be used under <ApiProvider />");
|
|
19
16
|
return ctx;
|
|
20
17
|
}
|
|
21
|
-
function
|
|
22
|
-
return /* @__PURE__ */ jsx(
|
|
23
|
-
value:
|
|
24
|
-
return {
|
|
25
|
-
shikiOptions,
|
|
26
|
-
client,
|
|
27
|
-
codeUsages: client.codeUsages ?? registerDefault(createCodeUsageGeneratorRegistry()),
|
|
28
|
-
schemes,
|
|
29
|
-
mediaAdapters: {
|
|
30
|
-
...defaultAdapters,
|
|
31
|
-
...client.mediaAdapters
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}, [
|
|
35
|
-
client,
|
|
36
|
-
schemes,
|
|
37
|
-
shikiOptions
|
|
38
|
-
]),
|
|
18
|
+
function RenderContextProvider({ children, ctx }) {
|
|
19
|
+
return /* @__PURE__ */ jsx(Context, {
|
|
20
|
+
value: ctx,
|
|
39
21
|
children
|
|
40
22
|
});
|
|
41
23
|
}
|
|
@@ -99,4 +81,4 @@ function getDefaultValues(server) {
|
|
|
99
81
|
return out;
|
|
100
82
|
}
|
|
101
83
|
//#endregion
|
|
102
|
-
export {
|
|
84
|
+
export { RenderContextProvider, ServerProvider, useRenderContext, useServerContext };
|