fumadocs-openapi 10.10.3 → 11.0.1
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 -1159
- 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 -410
- 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
|
@@ -1,52 +1,44 @@
|
|
|
1
|
-
import { useTranslations } from "../ui/client/i18n.js";
|
|
2
1
|
import { useMemo } from "react";
|
|
3
2
|
import { CircleCheck, CircleX } from "lucide-react";
|
|
3
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
4
4
|
//#region src/playground/status-info.tsx
|
|
5
|
-
const statusKeys = {
|
|
6
|
-
400: {
|
|
7
|
-
key: "statusBadRequest",
|
|
8
|
-
color: "text-red-500",
|
|
9
|
-
icon: CircleX
|
|
10
|
-
},
|
|
11
|
-
401: {
|
|
12
|
-
key: "statusUnauthorized",
|
|
13
|
-
color: "text-red-500",
|
|
14
|
-
icon: CircleX
|
|
15
|
-
},
|
|
16
|
-
403: {
|
|
17
|
-
key: "statusForbidden",
|
|
18
|
-
color: "text-red-500",
|
|
19
|
-
icon: CircleX
|
|
20
|
-
},
|
|
21
|
-
404: {
|
|
22
|
-
key: "statusNotFound",
|
|
23
|
-
color: "text-fd-muted-foreground",
|
|
24
|
-
icon: CircleX
|
|
25
|
-
},
|
|
26
|
-
500: {
|
|
27
|
-
key: "statusInternalServerError",
|
|
28
|
-
color: "text-red-500",
|
|
29
|
-
icon: CircleX
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
5
|
function useStatusInfo(status) {
|
|
33
|
-
const t = useTranslations();
|
|
6
|
+
const t = useTranslations({ note: "playground status info" });
|
|
34
7
|
return useMemo(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
8
|
+
switch (status) {
|
|
9
|
+
case 400: return {
|
|
10
|
+
description: t("Bad Request"),
|
|
11
|
+
color: "text-red-500",
|
|
12
|
+
icon: CircleX
|
|
13
|
+
};
|
|
14
|
+
case 401: return {
|
|
15
|
+
description: t("Unauthorized"),
|
|
16
|
+
color: "text-red-500",
|
|
17
|
+
icon: CircleX
|
|
18
|
+
};
|
|
19
|
+
case 403: return {
|
|
20
|
+
description: t("Forbidden"),
|
|
21
|
+
color: "text-red-500",
|
|
22
|
+
icon: CircleX
|
|
23
|
+
};
|
|
24
|
+
case 404: return {
|
|
25
|
+
description: t("Not Found"),
|
|
26
|
+
color: "text-fd-muted-foreground",
|
|
27
|
+
icon: CircleX
|
|
28
|
+
};
|
|
29
|
+
case 500: return {
|
|
30
|
+
description: t("Internal Server Error"),
|
|
31
|
+
color: "text-red-500",
|
|
32
|
+
icon: CircleX
|
|
41
33
|
};
|
|
42
34
|
}
|
|
43
35
|
if (status >= 200 && status < 300) return {
|
|
44
|
-
description: t
|
|
36
|
+
description: t("Successful"),
|
|
45
37
|
color: "text-green-500",
|
|
46
38
|
icon: CircleCheck
|
|
47
39
|
};
|
|
48
40
|
if (status >= 400) return {
|
|
49
|
-
description: t
|
|
41
|
+
description: t("Error"),
|
|
50
42
|
color: "text-red-500",
|
|
51
43
|
icon: CircleX
|
|
52
44
|
};
|
|
@@ -5,7 +5,7 @@ import "../media/adapter.js";
|
|
|
5
5
|
const csharp = {
|
|
6
6
|
label: "C#",
|
|
7
7
|
lang: "csharp",
|
|
8
|
-
generate(
|
|
8
|
+
generate(data, { mediaAdapters }) {
|
|
9
9
|
const s = [];
|
|
10
10
|
const imports = new Set([
|
|
11
11
|
"System",
|
|
@@ -32,8 +32,8 @@ const csharp = {
|
|
|
32
32
|
if (Object.keys(data.cookie).length > 0) addHeader("cookie", Object.entries(data.cookie).map(([key, param]) => `${key}=${param.value}`).join("; "));
|
|
33
33
|
s.push(...headerLines);
|
|
34
34
|
const method = data.method[0].toUpperCase() + data.method.slice(1).toLowerCase() + "Async";
|
|
35
|
-
if (body) s.push(`var response = await client.${method}("${url}", body);`);
|
|
36
|
-
else s.push(`var response = await client.${method}("${url}");`);
|
|
35
|
+
if (body) s.push(`var response = await client.${method}("${data.url}", body);`);
|
|
36
|
+
else s.push(`var response = await client.${method}("${data.url}");`);
|
|
37
37
|
s.push("var responseBody = await response.Content.ReadAsStringAsync();");
|
|
38
38
|
return s.join("\n");
|
|
39
39
|
}
|
|
@@ -3,9 +3,9 @@ import { doubleQuote, indent, inputToString, singleQuote } from "../string-utils
|
|
|
3
3
|
const curl = {
|
|
4
4
|
label: "cURL",
|
|
5
5
|
lang: "bash",
|
|
6
|
-
generate(
|
|
6
|
+
generate(data) {
|
|
7
7
|
const s = [];
|
|
8
|
-
s.push(`curl -X ${data.method.toUpperCase()} "${url}"`);
|
|
8
|
+
s.push(`curl -X ${data.method.toUpperCase()} "${data.url}"`);
|
|
9
9
|
for (const header in data.header) {
|
|
10
10
|
const value = `${header}: ${data.header[header].value}`;
|
|
11
11
|
s.push(`-H "${value}"`);
|
|
@@ -5,7 +5,7 @@ import "../media/adapter.js";
|
|
|
5
5
|
const go = {
|
|
6
6
|
label: "Go",
|
|
7
7
|
lang: "go",
|
|
8
|
-
generate(
|
|
8
|
+
generate(data, { mediaAdapters }) {
|
|
9
9
|
const imports = [
|
|
10
10
|
"fmt",
|
|
11
11
|
"net/http",
|
|
@@ -13,7 +13,7 @@ const go = {
|
|
|
13
13
|
];
|
|
14
14
|
const headers = /* @__PURE__ */ new Map();
|
|
15
15
|
const variables = /* @__PURE__ */ new Map();
|
|
16
|
-
variables.set("url", doubleQuote(url));
|
|
16
|
+
variables.set("url", doubleQuote(data.url));
|
|
17
17
|
for (const header in data.header) headers.set(header, doubleQuote(data.header[header].value));
|
|
18
18
|
const cookies = Object.entries(data.cookie);
|
|
19
19
|
if (cookies.length > 0) headers.set("Cookie", doubleQuote(cookies.map(([k, param]) => `${k}=${param.value}`).join("; ")));
|
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
import { MediaAdapter } from "../media/adapter.js";
|
|
2
2
|
import { RequestData } from "../types.js";
|
|
3
|
+
import * as Shared from "@fumadocs/api-docs/codegen";
|
|
3
4
|
|
|
4
5
|
//#region src/requests/generators/index.d.ts
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
6
|
+
declare function pathnameFromRequest(pathname: string, {
|
|
7
|
+
path,
|
|
8
|
+
query
|
|
9
|
+
}: RequestData): string;
|
|
10
|
+
type CodeUsageGeneratorRegistry = Shared.CodeUsageGeneratorRegistry<RequestData & {
|
|
11
|
+
url: string;
|
|
12
|
+
}, {
|
|
13
|
+
mediaAdapters: Record<string, MediaAdapter>;
|
|
14
|
+
custom: unknown;
|
|
15
|
+
}>;
|
|
15
16
|
/**
|
|
16
17
|
* Generate code example for given programming language
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
*/
|
|
25
|
-
_client?: {
|
|
26
|
-
generate: string | CodeUsageGeneratorFn;
|
|
27
|
-
serverContext?: unknown;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
19
|
+
type CodeUsageGenerator = Shared.CodeUsageGenerator<RequestData & {
|
|
20
|
+
url: string;
|
|
21
|
+
}, {
|
|
22
|
+
mediaAdapters: Record<string, MediaAdapter>;
|
|
23
|
+
custom: unknown;
|
|
24
|
+
}>;
|
|
30
25
|
/**
|
|
31
26
|
* Generate code example for given programming language
|
|
32
27
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* - code
|
|
40
|
-
* - a function imported from a file with "use client" directive
|
|
41
|
-
* - false (disabled)
|
|
42
|
-
*/
|
|
43
|
-
source?: string | CodeUsageGeneratorFn<T> | false;
|
|
44
|
-
/**
|
|
45
|
-
* Pass extra context to client-side source generator
|
|
46
|
-
*/
|
|
47
|
-
serverContext?: T;
|
|
48
|
-
}
|
|
28
|
+
type InlineCodeUsageGenerator<T = unknown> = Shared.InlineCodeUsageGenerator<RequestData & {
|
|
29
|
+
url: string;
|
|
30
|
+
}, {
|
|
31
|
+
mediaAdapters: Record<string, MediaAdapter>;
|
|
32
|
+
custom: T;
|
|
33
|
+
}>;
|
|
49
34
|
declare function createCodeUsageGeneratorRegistry(inherit?: CodeUsageGeneratorRegistry): CodeUsageGeneratorRegistry;
|
|
50
|
-
type CodeUsageGeneratorFn<
|
|
35
|
+
type CodeUsageGeneratorFn<T = unknown> = (data: RequestData & {
|
|
36
|
+
url: string;
|
|
37
|
+
}, context: {
|
|
51
38
|
mediaAdapters: Record<string, MediaAdapter>;
|
|
52
|
-
|
|
39
|
+
custom: T;
|
|
53
40
|
}) => string;
|
|
54
41
|
//#endregion
|
|
55
|
-
export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry };
|
|
42
|
+
export { CodeUsageGenerator, CodeUsageGeneratorFn, CodeUsageGeneratorRegistry, InlineCodeUsageGenerator, createCodeUsageGeneratorRegistry, pathnameFromRequest };
|
|
@@ -1,39 +1,22 @@
|
|
|
1
|
+
import * as Shared from "@fumadocs/api-docs/codegen";
|
|
1
2
|
//#region src/requests/generators/index.ts
|
|
3
|
+
function pathnameFromRequest(pathname, { path, query }) {
|
|
4
|
+
for (const key in path) {
|
|
5
|
+
const param = path[key];
|
|
6
|
+
pathname = pathname.replace(`{${key}}`, param.value);
|
|
7
|
+
}
|
|
8
|
+
const [pathPart, existingQueryString] = pathname.split("?", 2);
|
|
9
|
+
const searchParams = new URLSearchParams(existingQueryString || "");
|
|
10
|
+
for (const key in query) {
|
|
11
|
+
const param = query[key];
|
|
12
|
+
if (!param || param.values.length === 0) continue;
|
|
13
|
+
searchParams.delete(key);
|
|
14
|
+
for (const item of param.values) searchParams.append(key, item);
|
|
15
|
+
}
|
|
16
|
+
return searchParams.size > 0 ? `${pathPart}?${searchParams}` : pathPart;
|
|
17
|
+
}
|
|
2
18
|
function createCodeUsageGeneratorRegistry(inherit) {
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
add(id, generator) {
|
|
6
|
-
registry.set(id, generator);
|
|
7
|
-
},
|
|
8
|
-
get(id) {
|
|
9
|
-
return registry.get(id);
|
|
10
|
-
},
|
|
11
|
-
addInline(generator) {
|
|
12
|
-
const source = generator.source;
|
|
13
|
-
const id = generator.id ?? generator.lang;
|
|
14
|
-
if (!source) {
|
|
15
|
-
this.remove(id);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
registry.set(id, {
|
|
19
|
-
lang: generator.lang,
|
|
20
|
-
label: generator.label,
|
|
21
|
-
generate() {
|
|
22
|
-
return typeof source === "string" ? source : "";
|
|
23
|
-
},
|
|
24
|
-
_client: {
|
|
25
|
-
generate: source,
|
|
26
|
-
serverContext: generator.serverContext
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
remove(id) {
|
|
31
|
-
return registry.delete(id);
|
|
32
|
-
},
|
|
33
|
-
map() {
|
|
34
|
-
return registry;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
19
|
+
return Shared.createCodeUsageGeneratorRegistry(inherit);
|
|
37
20
|
}
|
|
38
21
|
//#endregion
|
|
39
|
-
export { createCodeUsageGeneratorRegistry };
|
|
22
|
+
export { createCodeUsageGeneratorRegistry, pathnameFromRequest };
|
|
@@ -5,7 +5,7 @@ import "../media/adapter.js";
|
|
|
5
5
|
const java = {
|
|
6
6
|
label: "Java",
|
|
7
7
|
lang: "java",
|
|
8
|
-
generate(
|
|
8
|
+
generate(data, { mediaAdapters }) {
|
|
9
9
|
const s = [];
|
|
10
10
|
const headers = { ...data.header };
|
|
11
11
|
const imports = new Set([
|
|
@@ -31,7 +31,7 @@ const java = {
|
|
|
31
31
|
s.push(indent(".build();"));
|
|
32
32
|
s.push("");
|
|
33
33
|
s.push("HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()");
|
|
34
|
-
s.push(indent(`.uri(URI.create(${doubleQuote(url)}))`));
|
|
34
|
+
s.push(indent(`.uri(URI.create(${doubleQuote(data.url)}))`));
|
|
35
35
|
for (const [key, param] of Object.entries(headers)) s.push(indent(`.header(${doubleQuote(key)}, ${doubleQuote(param.value)})`));
|
|
36
36
|
if (data.bodyMediaType) s.push(indent(`.header("Content-Type", "${data.bodyMediaType}")`));
|
|
37
37
|
const cookies = Object.entries(data.cookie);
|
|
@@ -5,7 +5,7 @@ import "../media/adapter.js";
|
|
|
5
5
|
const javascript = {
|
|
6
6
|
label: "JavaScript",
|
|
7
7
|
lang: "js",
|
|
8
|
-
generate(
|
|
8
|
+
generate(data, { mediaAdapters }) {
|
|
9
9
|
const s = [];
|
|
10
10
|
const options = /* @__PURE__ */ new Map();
|
|
11
11
|
const headers = {};
|
|
@@ -26,7 +26,7 @@ const javascript = {
|
|
|
26
26
|
s.push(body);
|
|
27
27
|
options.set("body", "body");
|
|
28
28
|
}
|
|
29
|
-
const params = [doubleQuote(url)];
|
|
29
|
+
const params = [doubleQuote(data.url)];
|
|
30
30
|
if (options.size > 0) {
|
|
31
31
|
const str = Array.from(options.entries()).map(([k, v]) => indent(k === v ? k : `${k}: ${v}`)).join(",\n");
|
|
32
32
|
params.push(`{\n${str}\n}`);
|
|
@@ -5,7 +5,7 @@ import "../media/adapter.js";
|
|
|
5
5
|
const python = {
|
|
6
6
|
label: "Python",
|
|
7
7
|
lang: "python",
|
|
8
|
-
generate(
|
|
8
|
+
generate(data, { mediaAdapters }) {
|
|
9
9
|
const headers = {};
|
|
10
10
|
const imports = /* @__PURE__ */ new Set();
|
|
11
11
|
const params = [`"${data.method.toUpperCase()}"`, "url"];
|
|
@@ -27,7 +27,7 @@ const python = {
|
|
|
27
27
|
}
|
|
28
28
|
return `${Array.from(imports).map((name) => "import " + name).join("\n")}
|
|
29
29
|
|
|
30
|
-
url = ${doubleQuote(url)}
|
|
30
|
+
url = ${doubleQuote(data.url)}
|
|
31
31
|
${body ?? ""}
|
|
32
32
|
response = requests.request(${params.join(", ")})
|
|
33
33
|
|
package/dist/scalar/client.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { I18nLabel } from "../ui/client/i18n.js";
|
|
3
2
|
import { cn } from "../utils/cn.js";
|
|
4
3
|
import { MethodLabel } from "../ui/components/method-label.js";
|
|
5
4
|
import { useEffect, useState } from "react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
7
7
|
import { buttonVariants } from "fumadocs-ui/components/ui/button";
|
|
8
8
|
import { useApiClient } from "@scalar/api-client-react";
|
|
9
9
|
import { useTheme } from "fumadocs-ui/provider/base";
|
|
@@ -11,6 +11,7 @@ import "@scalar/api-client-react/style.css";
|
|
|
11
11
|
//#region src/scalar/client.tsx
|
|
12
12
|
function ScalarPlayground({ path, method, spec }) {
|
|
13
13
|
const { resolvedTheme } = useTheme();
|
|
14
|
+
const t = useTranslations({ note: "scalar API client" });
|
|
14
15
|
const [mounted, setMounted] = useState(false);
|
|
15
16
|
const client = useApiClient({ configuration: { content: spec } });
|
|
16
17
|
useEffect(() => {
|
|
@@ -37,7 +38,7 @@ function ScalarPlayground({ path, method, spec }) {
|
|
|
37
38
|
path,
|
|
38
39
|
method
|
|
39
40
|
}),
|
|
40
|
-
children:
|
|
41
|
+
children: t("Test")
|
|
41
42
|
})
|
|
42
43
|
]
|
|
43
44
|
});
|
package/dist/scalar/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateOpenAPIPageOptions } from "../ui/index.js";
|
|
2
2
|
|
|
3
3
|
//#region src/scalar/index.d.ts
|
|
4
4
|
/**
|
|
@@ -6,6 +6,6 @@ import { CreateAPIPageOptions } from "../ui/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* Requires `@scalar/api-client-react` to be installed, it imports the styles automatically.
|
|
8
8
|
*/
|
|
9
|
-
declare function withScalar(options?:
|
|
9
|
+
declare function withScalar(options?: CreateOpenAPIPageOptions): CreateOpenAPIPageOptions;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { withScalar };
|
package/dist/scalar/index.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { lazy } from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region src/scalar/index.tsx
|
|
4
5
|
const Client = lazy(() => import("./client.js"));
|
|
5
|
-
function APIPlayground({ path, method, ctx }) {
|
|
6
|
-
return /* @__PURE__ */ jsx(Client, {
|
|
7
|
-
method: method.method,
|
|
8
|
-
path,
|
|
9
|
-
spec: ctx.schema.bundled
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
6
|
/**
|
|
13
7
|
* Enable Scalar for API playgrounds by wrapping your options inside.
|
|
14
8
|
*
|
|
@@ -19,8 +13,15 @@ function withScalar(options = {}) {
|
|
|
19
13
|
...options,
|
|
20
14
|
playground: {
|
|
21
15
|
...options.playground,
|
|
22
|
-
|
|
23
|
-
return
|
|
16
|
+
provider(props) {
|
|
17
|
+
return props.children;
|
|
18
|
+
},
|
|
19
|
+
render({ method, path, ctx }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(Client, {
|
|
21
|
+
method,
|
|
22
|
+
path,
|
|
23
|
+
spec: ctx.schema.bundled
|
|
24
|
+
});
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import { InlineCodeUsageGenerator } from "../requests/generators/index.js";
|
|
2
1
|
import { CreateProxyOptions, Proxy, createProxy } from "./proxy.js";
|
|
3
|
-
import {
|
|
4
|
-
import { ApiPageProps } from "../ui/api-page.js";
|
|
5
|
-
import { ClientApiPageProps } from "../ui/create-client.js";
|
|
2
|
+
import { OpenAPIPageProps_Preloaded, OpenAPIPageProps_Spec } from "../ui/index.js";
|
|
6
3
|
import { SchemaToPagesOptions } from "../utils/pages/preset-auto.js";
|
|
7
|
-
import { Document } from "../types.js";
|
|
8
|
-
import {
|
|
9
|
-
import { DynamicSource, LoaderPlugin, MetaData, PageData, PageTreeTransformer, Source } from "fumadocs-core/source";
|
|
4
|
+
import { Awaitable, Document } from "../types.js";
|
|
5
|
+
import { DynamicSource, LoaderPlugin, MetaData, Page, PageData, Source } from "fumadocs-core/source";
|
|
10
6
|
import { StructuredData } from "fumadocs-core/mdx-plugins/remark-structure";
|
|
11
7
|
import { TOCItemType } from "fumadocs-core/toc";
|
|
12
8
|
|
|
13
9
|
//#region src/server/index.d.ts
|
|
14
10
|
/**
|
|
15
|
-
* schema
|
|
11
|
+
* schema ID -> file path, URL, downloaded schema object, or a function returning them
|
|
16
12
|
*/
|
|
17
|
-
type
|
|
18
|
-
|
|
13
|
+
type SchemaRecord = Record<string, string | Document | (() => Awaitable<string | Document>)>;
|
|
14
|
+
interface LoadedDocument {
|
|
15
|
+
bundled: Document;
|
|
16
|
+
}
|
|
19
17
|
interface OpenAPIOptions {
|
|
20
18
|
/**
|
|
21
19
|
* Schema files, can be:
|
|
22
20
|
* - URL
|
|
23
21
|
* - file path
|
|
24
|
-
* - a
|
|
22
|
+
* - a schema record object
|
|
25
23
|
*/
|
|
26
|
-
input?: string[] |
|
|
24
|
+
input?: string[] | SchemaRecord;
|
|
27
25
|
disableCache?: boolean;
|
|
28
26
|
/**
|
|
29
27
|
* The url of proxy to avoid CORS issues
|
|
@@ -32,8 +30,8 @@ interface OpenAPIOptions {
|
|
|
32
30
|
}
|
|
33
31
|
interface OpenAPIServer {
|
|
34
32
|
createProxy: typeof createProxy;
|
|
35
|
-
getSchemas: () => Promise<
|
|
36
|
-
getSchema: (document: string) => Promise<
|
|
33
|
+
getSchemas: () => Promise<Record<string, LoadedDocument>>;
|
|
34
|
+
getSchema: (document: string) => Promise<LoadedDocument>;
|
|
37
35
|
readonly options: OpenAPIOptions;
|
|
38
36
|
/**
|
|
39
37
|
* Generate virtual pages for Fumadocs Source API
|
|
@@ -49,6 +47,7 @@ interface OpenAPIServer {
|
|
|
49
47
|
metaData: MetaData;
|
|
50
48
|
pageData: OpenAPIPageData;
|
|
51
49
|
}>;
|
|
50
|
+
preloadOpenAPIPage: <Type extends string | undefined, Data extends PageData>(page: Page<Type, Data>) => Promise<Pick<OpenAPIPageProps_Preloaded, 'preloaded'>>;
|
|
52
51
|
/**
|
|
53
52
|
* Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
|
|
54
53
|
*/
|
|
@@ -57,14 +56,18 @@ interface OpenAPIServer {
|
|
|
57
56
|
_getWatchPaths: () => string[];
|
|
58
57
|
}
|
|
59
58
|
interface OpenAPIPageData extends PageData {
|
|
60
|
-
|
|
59
|
+
getOpenAPIPageProps: () => OpenAPIPageProps_Spec;
|
|
61
60
|
getSchema: () => {
|
|
62
61
|
id: string;
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
bundled: Document;
|
|
63
|
+
};
|
|
65
64
|
structuredData: StructuredData;
|
|
66
65
|
toc: TOCItemType[];
|
|
67
|
-
_openapi
|
|
66
|
+
_openapi: InternalOpenAPIMeta;
|
|
67
|
+
/** @deprecated use `getOpenAPIPageProps()` instead */
|
|
68
|
+
getAPIPageProps: () => OpenAPIPageProps_Spec;
|
|
69
|
+
/** @deprecated use `getOpenAPIPageProps()` instead */
|
|
70
|
+
getClientAPIPageProps: () => OpenAPIPageProps_Spec;
|
|
68
71
|
}
|
|
69
72
|
type OpenAPISourceOptions = SchemaToPagesOptions & {
|
|
70
73
|
baseDir?: string; /** Generate `meta.json` files */
|
|
@@ -73,14 +76,11 @@ type OpenAPISourceOptions = SchemaToPagesOptions & {
|
|
|
73
76
|
};
|
|
74
77
|
};
|
|
75
78
|
declare function createOpenAPI(options?: OpenAPIOptions): OpenAPIServer;
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated
|
|
78
|
-
*/
|
|
79
|
-
declare function createCodeSample<T>(options: InlineCodeUsageGenerator<T>): InlineCodeUsageGenerator<T>;
|
|
80
79
|
interface InternalOpenAPIMeta {
|
|
81
80
|
method?: string;
|
|
82
81
|
webhook?: boolean;
|
|
83
82
|
deprecated?: boolean;
|
|
83
|
+
preload?: string[];
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
|
|
@@ -93,9 +93,5 @@ declare function openapiSource(server: OpenAPIServer, options?: OpenAPISourceOpt
|
|
|
93
93
|
metaData: MetaData;
|
|
94
94
|
pageData: OpenAPIPageData;
|
|
95
95
|
}>>;
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated use `openapiPlugin()`
|
|
98
|
-
*/
|
|
99
|
-
declare function transformerOpenAPI(): PageTreeTransformer;
|
|
100
96
|
//#endregion
|
|
101
|
-
export { type CreateProxyOptions, InternalOpenAPIMeta, OpenAPIOptions, OpenAPIPageData, OpenAPIServer, OpenAPISourceOptions, type Proxy,
|
|
97
|
+
export { type CreateProxyOptions, InternalOpenAPIMeta, OpenAPIOptions, OpenAPIPageData, type OpenAPIPageProps_Preloaded, type OpenAPIPageProps_Spec, OpenAPIServer, OpenAPISourceOptions, type Proxy, createOpenAPI, openapiPlugin, openapiSource };
|
package/dist/server/index.js
CHANGED
|
@@ -2,23 +2,35 @@ import { getPageProps } from "../utils/pages/builder.js";
|
|
|
2
2
|
import { toStaticData } from "../utils/pages/to-static-data.js";
|
|
3
3
|
import { MethodLabel } from "../ui/components/method-label.js";
|
|
4
4
|
import { createProxy } from "./proxy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { loadDocument } from "../utils/document/load.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { PathUtils } from "fumadocs-core/source";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
//#region src/server/index.tsx
|
|
11
11
|
function createOpenAPI(options = {}) {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
12
|
+
const { disableCache = false } = options;
|
|
13
|
+
const schemaMap = /* @__PURE__ */ new Map();
|
|
14
|
+
let resolvedInput = {};
|
|
15
|
+
if (Array.isArray(options.input)) for (const item of options.input) resolvedInput[item] = item;
|
|
16
|
+
else if (options.input) resolvedInput = options.input;
|
|
17
|
+
function getSchema(schemaId) {
|
|
18
|
+
if (!(schemaId in resolvedInput)) {
|
|
19
|
+
console.warn(`[Fumadocs OpenAPI] the document "${schemaId}" is not listed in the input array, this may be unexpected and won't be cached properly.`);
|
|
20
|
+
return loadDocument(schemaId);
|
|
21
|
+
}
|
|
22
|
+
if (!disableCache) {
|
|
23
|
+
const cached = schemaMap.get(schemaId);
|
|
24
|
+
if (cached) return cached;
|
|
21
25
|
}
|
|
26
|
+
const raw = resolvedInput[schemaId];
|
|
27
|
+
const output = Promise.resolve(typeof raw === "function" ? raw() : raw).then(loadDocument);
|
|
28
|
+
if (!disableCache) schemaMap.set(schemaId, output);
|
|
29
|
+
return output;
|
|
30
|
+
}
|
|
31
|
+
async function getSchemas() {
|
|
32
|
+
const entries = await Promise.all(Object.keys(resolvedInput).map(async (k) => [k, await getSchema(k)]));
|
|
33
|
+
return Object.fromEntries(entries);
|
|
22
34
|
}
|
|
23
35
|
async function getVirtualFiles(server, options) {
|
|
24
36
|
const { baseDir = "", meta = false } = options;
|
|
@@ -28,7 +40,7 @@ function createOpenAPI(options = {}) {
|
|
|
28
40
|
const schemas = await server.getSchemas();
|
|
29
41
|
const builderOptions = createAutoPreset(options);
|
|
30
42
|
for (const [id, schema] of Object.entries(schemas)) {
|
|
31
|
-
onEntries(fromSchema(id, schema, builderOptions));
|
|
43
|
+
onEntries(fromSchema(id, schema.bundled, builderOptions));
|
|
32
44
|
function onEntry(entry) {
|
|
33
45
|
const props = getPageProps(entry);
|
|
34
46
|
files.push({
|
|
@@ -37,9 +49,12 @@ function createOpenAPI(options = {}) {
|
|
|
37
49
|
data: {
|
|
38
50
|
...entry.info,
|
|
39
51
|
getAPIPageProps() {
|
|
40
|
-
return
|
|
52
|
+
return this.getOpenAPIPageProps();
|
|
53
|
+
},
|
|
54
|
+
getClientAPIPageProps() {
|
|
55
|
+
return this.getOpenAPIPageProps();
|
|
41
56
|
},
|
|
42
|
-
|
|
57
|
+
getOpenAPIPageProps() {
|
|
43
58
|
return {
|
|
44
59
|
payload: {
|
|
45
60
|
bundled: schema.bundled,
|
|
@@ -51,10 +66,10 @@ function createOpenAPI(options = {}) {
|
|
|
51
66
|
getSchema() {
|
|
52
67
|
return {
|
|
53
68
|
id,
|
|
54
|
-
|
|
69
|
+
bundled: schema.bundled
|
|
55
70
|
};
|
|
56
71
|
},
|
|
57
|
-
...toStaticData(props, schema.
|
|
72
|
+
...toStaticData(props, schema.bundled),
|
|
58
73
|
_openapi: {
|
|
59
74
|
method: entry.type === "operation" || entry.type === "webhook" ? entry.item.method : void 0,
|
|
60
75
|
webhook: entry.type === "webhook",
|
|
@@ -100,18 +115,19 @@ function createOpenAPI(options = {}) {
|
|
|
100
115
|
options,
|
|
101
116
|
createProxy,
|
|
102
117
|
_getWatchPaths() {
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
async getSchema(document) {
|
|
106
|
-
const schemas = await this.getSchemas();
|
|
107
|
-
if (document in schemas) return schemas[document];
|
|
108
|
-
console.warn(`[Fumadocs OpenAPI] the document "${document}" is not listed in the input array, this may not be expected.`);
|
|
109
|
-
return processDocument(document);
|
|
118
|
+
return Object.keys(resolvedInput).filter((key) => !URL.canParse(key) && fs.existsSync(key));
|
|
110
119
|
},
|
|
111
|
-
async
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
async preloadOpenAPIPage(page) {
|
|
121
|
+
const out = {
|
|
122
|
+
docs: {},
|
|
123
|
+
proxyUrl: options.proxyUrl
|
|
124
|
+
};
|
|
125
|
+
const openapiMeta = page.data._openapi;
|
|
126
|
+
if (openapiMeta?.preload) out.docs = Object.fromEntries(await Promise.all(openapiMeta.preload.map(async (k) => [k, (await getSchema(k)).bundled])));
|
|
127
|
+
return { preloaded: out };
|
|
114
128
|
},
|
|
129
|
+
getSchema,
|
|
130
|
+
getSchemas,
|
|
115
131
|
async staticSource(options = {}) {
|
|
116
132
|
return { files: await getVirtualFiles(this, options) };
|
|
117
133
|
},
|
|
@@ -124,12 +140,6 @@ function createOpenAPI(options = {}) {
|
|
|
124
140
|
};
|
|
125
141
|
}
|
|
126
142
|
/**
|
|
127
|
-
* @deprecated
|
|
128
|
-
*/
|
|
129
|
-
function createCodeSample(options) {
|
|
130
|
-
return options;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
143
|
* Fumadocs Source API integration, pass this to `plugins` array in `loader()`.
|
|
134
144
|
*/
|
|
135
145
|
function openapiPlugin() {
|
|
@@ -172,11 +182,5 @@ function openapiPlugin() {
|
|
|
172
182
|
async function openapiSource(server, options = {}) {
|
|
173
183
|
return server.staticSource(options);
|
|
174
184
|
}
|
|
175
|
-
/**
|
|
176
|
-
* @deprecated use `openapiPlugin()`
|
|
177
|
-
*/
|
|
178
|
-
function transformerOpenAPI() {
|
|
179
|
-
return openapiPlugin().transformPageTree;
|
|
180
|
-
}
|
|
181
185
|
//#endregion
|
|
182
|
-
export {
|
|
186
|
+
export { createOpenAPI, openapiPlugin, openapiSource };
|
package/dist/server/proxy.d.ts
CHANGED
|
@@ -5,12 +5,6 @@ interface Proxy extends Record<(typeof methods)[number], Handler> {
|
|
|
5
5
|
handle: Handler;
|
|
6
6
|
}
|
|
7
7
|
interface CreateProxyOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Filter by prefixes of request url
|
|
10
|
-
*
|
|
11
|
-
* @deprecated Use `allowedOrigins` for filtering origins, or `filterRequest` for more detailed rules.
|
|
12
|
-
*/
|
|
13
|
-
allowedUrls?: string[];
|
|
14
8
|
/**
|
|
15
9
|
* List of allowed origins to proxy to.
|
|
16
10
|
*/
|