fumadocs-openapi 10.10.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +15 -28
- 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,67 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRenderContext } from "../contexts/api.js";
|
|
3
|
+
import { ClientCodeBlock } from "../components/codeblock.js";
|
|
4
|
+
import { pathnameFromRequest } from "../../requests/generators/index.js";
|
|
3
5
|
import { MethodLabel } from "../components/method-label.js";
|
|
4
|
-
import {
|
|
6
|
+
import { Markdown } from "../components/markdown.js";
|
|
5
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
9
|
+
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "@fumadocs/api-docs/components/accordion";
|
|
6
10
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "fumadocs-ui/components/tabs";
|
|
7
11
|
//#region src/ui/operation/request-tabs.tsx
|
|
8
|
-
function RequestTabs({ path, operation,
|
|
12
|
+
function RequestTabs({ path, operation, method, pathItem, examples }) {
|
|
13
|
+
const ctx = useRenderContext();
|
|
9
14
|
if (!operation.requestBody) return null;
|
|
10
15
|
const { renderRequestTabs = renderRequestTabsDefault } = ctx.content ?? {};
|
|
11
|
-
return renderRequestTabs(
|
|
12
|
-
|
|
16
|
+
return renderRequestTabs({
|
|
17
|
+
items: examples,
|
|
13
18
|
route: path,
|
|
19
|
+
method,
|
|
20
|
+
pathItem,
|
|
14
21
|
operation
|
|
15
|
-
});
|
|
22
|
+
}, ctx);
|
|
23
|
+
}
|
|
24
|
+
function renderRequestTabsDefault(options) {
|
|
25
|
+
return /* @__PURE__ */ jsx(RequestTabsDefaultContent, { options });
|
|
16
26
|
}
|
|
17
|
-
function
|
|
27
|
+
function RequestTabsDefaultContent({ options }) {
|
|
28
|
+
const t = useTranslations({ note: "operation page" });
|
|
29
|
+
const { items } = options;
|
|
18
30
|
let children;
|
|
19
31
|
if (items.length > 1) children = /* @__PURE__ */ jsxs(Tabs, {
|
|
20
32
|
defaultValue: items[0].id,
|
|
21
33
|
children: [/* @__PURE__ */ jsx(TabsList, { children: items.map((item) => /* @__PURE__ */ jsx(TabsTrigger, {
|
|
22
34
|
value: item.id,
|
|
23
|
-
children: item.id === "_default" ?
|
|
35
|
+
children: item.id === "_default" ? t("Default") : item.name
|
|
24
36
|
}, item.id)) }), items.map((item) => /* @__PURE__ */ jsx(TabsContent, {
|
|
25
37
|
value: item.id,
|
|
26
38
|
children: /* @__PURE__ */ jsx(RequestTabsItem, {
|
|
27
39
|
item,
|
|
28
|
-
|
|
40
|
+
options
|
|
29
41
|
})
|
|
30
42
|
}, item.id))]
|
|
31
43
|
});
|
|
32
44
|
else if (items.length === 1) children = /* @__PURE__ */ jsx(RequestTabsItem, {
|
|
33
45
|
item: items[0],
|
|
34
|
-
|
|
46
|
+
options
|
|
35
47
|
});
|
|
36
48
|
else children = /* @__PURE__ */ jsx("p", {
|
|
37
49
|
className: "text-fd-muted-foreground text-xs",
|
|
38
|
-
children:
|
|
50
|
+
children: t("Empty")
|
|
39
51
|
});
|
|
40
52
|
return /* @__PURE__ */ jsxs("div", {
|
|
41
53
|
className: "p-3 rounded-xl border prose-no-margin bg-fd-card text-fd-card-foreground shadow-md",
|
|
42
54
|
children: [/* @__PURE__ */ jsx("p", {
|
|
43
55
|
className: "font-semibold border-b pb-2",
|
|
44
|
-
children:
|
|
56
|
+
children: t("Example Requests")
|
|
45
57
|
}), children]
|
|
46
58
|
});
|
|
47
59
|
}
|
|
48
|
-
function RequestTabsItem({ item,
|
|
60
|
+
function RequestTabsItem({ item, options }) {
|
|
61
|
+
const t = useTranslations({ note: "operation page" });
|
|
49
62
|
const requestData = item.data;
|
|
50
63
|
const displayNames = {
|
|
51
|
-
body: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
|
+
body: /* @__PURE__ */ jsxs(Fragment, { children: [t("Request Body"), /* @__PURE__ */ jsx("code", {
|
|
52
65
|
className: "text-xs text-fd-muted-foreground ms-auto",
|
|
53
66
|
children: requestData.bodyMediaType
|
|
54
67
|
})] }),
|
|
55
|
-
cookie:
|
|
56
|
-
header:
|
|
57
|
-
query:
|
|
58
|
-
path:
|
|
68
|
+
cookie: t("Cookie Parameters"),
|
|
69
|
+
header: t("Header Parameters"),
|
|
70
|
+
query: t("Query Parameters"),
|
|
71
|
+
path: t("Path Parameters")
|
|
59
72
|
};
|
|
60
73
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
|
-
item.description &&
|
|
74
|
+
item.description && /* @__PURE__ */ jsx(Markdown, { md: item.description }),
|
|
62
75
|
/* @__PURE__ */ jsxs("div", {
|
|
63
76
|
className: "flex flex-row gap-2 items-center justify-between",
|
|
64
|
-
children: [/* @__PURE__ */ jsx(MethodLabel, { children: requestData.method }), /* @__PURE__ */ jsx("code", { children:
|
|
77
|
+
children: [/* @__PURE__ */ jsx(MethodLabel, { children: requestData.method }), /* @__PURE__ */ jsx("code", { children: pathnameFromRequest(options.route, item.encoded) })]
|
|
65
78
|
}),
|
|
66
79
|
/* @__PURE__ */ jsx(Accordions, {
|
|
67
80
|
type: "multiple",
|
|
@@ -73,7 +86,7 @@ function RequestTabsItem({ item, ctx }) {
|
|
|
73
86
|
value: k,
|
|
74
87
|
children: [/* @__PURE__ */ jsx(AccordionHeader, { children: /* @__PURE__ */ jsx(AccordionTrigger, { children: v }) }), /* @__PURE__ */ jsx(AccordionContent, {
|
|
75
88
|
className: "prose-no-margin",
|
|
76
|
-
children:
|
|
89
|
+
children: /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
77
90
|
lang: "json",
|
|
78
91
|
code: JSON.stringify(data, null, 2)
|
|
79
92
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ResponseObject } from "../../types.js";
|
|
2
|
-
import { NoReference } from "../../utils/schema/index.js";
|
|
3
2
|
import { ReactNode } from "react";
|
|
3
|
+
import { NoReference } from "@fumadocs/api-docs/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/ui/operation/response-tabs.d.ts
|
|
6
6
|
interface ResponseTab {
|
|
@@ -26,5 +26,8 @@ interface ResponseExample {
|
|
|
26
26
|
*/
|
|
27
27
|
description?: string;
|
|
28
28
|
}
|
|
29
|
+
interface ResponseTabsRenderOptions {
|
|
30
|
+
tabs: ResponseTab[];
|
|
31
|
+
}
|
|
29
32
|
//#endregion
|
|
30
|
-
export {
|
|
33
|
+
export { ResponseTabsRenderOptions };
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { getPreferredType } from "../../utils/schema.js";
|
|
3
|
+
import { useRenderContext } from "../contexts/api.js";
|
|
4
|
+
import { ClientCodeBlock } from "../components/codeblock.js";
|
|
5
|
+
import { Markdown } from "../components/markdown.js";
|
|
5
6
|
import { useMemo } from "react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useTranslations } from "@fuma-translate/react";
|
|
9
|
+
import { AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger, Accordions } from "@fumadocs/api-docs/components/accordion";
|
|
7
10
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
11
|
+
import { sample } from "@fumadocs/api-docs/schema/sample";
|
|
8
12
|
//#region src/ui/operation/response-tabs.tsx
|
|
9
|
-
function ResponseTabs({ operation
|
|
13
|
+
function ResponseTabs({ operation }) {
|
|
14
|
+
const ctx = useRenderContext();
|
|
15
|
+
const t = useTranslations({ note: "operation page" });
|
|
10
16
|
const tabs = useMemo(() => {
|
|
11
17
|
const tabs = [];
|
|
12
18
|
if (!operation.responses) return tabs;
|
|
@@ -21,31 +27,32 @@ function ResponseTabs({ operation, ctx }) {
|
|
|
21
27
|
if (responseOfType?.examples) {
|
|
22
28
|
tab.examples ??= [];
|
|
23
29
|
for (const [key, sample] of Object.entries(responseOfType.examples)) tab.examples.push({
|
|
24
|
-
label: sample?.summary ??
|
|
25
|
-
label: "responseTabName",
|
|
26
|
-
replacements: { key }
|
|
27
|
-
}),
|
|
30
|
+
label: sample?.summary ?? t("Example {key}", { variables: { key } }),
|
|
28
31
|
sample: sample.value,
|
|
29
32
|
description: sample?.description
|
|
30
33
|
});
|
|
31
34
|
} else if (responseOfType?.example || responseOfType?.schema) {
|
|
32
35
|
tab.examples ??= [];
|
|
33
36
|
tab.examples.push({
|
|
34
|
-
label:
|
|
37
|
+
label: t("Example"),
|
|
35
38
|
sample: responseOfType.example ?? sample(responseOfType.schema)
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
tabs.push(tab);
|
|
39
42
|
}
|
|
40
43
|
return tabs;
|
|
41
|
-
}, [operation.responses]);
|
|
44
|
+
}, [operation.responses, t]);
|
|
42
45
|
if (tabs.length === 0) return null;
|
|
43
46
|
const { renderResponseTabs = renderResponseTabsDefault } = ctx.content ?? {};
|
|
44
|
-
return renderResponseTabs(tabs, ctx);
|
|
47
|
+
return renderResponseTabs({ tabs }, ctx);
|
|
45
48
|
}
|
|
46
|
-
function renderResponseTabsDefault(tabs
|
|
49
|
+
function renderResponseTabsDefault({ tabs }) {
|
|
50
|
+
return /* @__PURE__ */ jsx(ResponseTabsDefaultContent, { tabs });
|
|
51
|
+
}
|
|
52
|
+
function ResponseTabsDefaultContent({ tabs }) {
|
|
53
|
+
const t = useTranslations({ note: "operation page" });
|
|
47
54
|
function renderExampleContent(example) {
|
|
48
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description &&
|
|
55
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [example.description && /* @__PURE__ */ jsx(Markdown, { md: example.description }), /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
49
56
|
lang: "json",
|
|
50
57
|
code: JSON.stringify(example.sample, null, 2)
|
|
51
58
|
})] });
|
|
@@ -55,7 +62,7 @@ function renderResponseTabsDefault(tabs, ctx) {
|
|
|
55
62
|
items: tabs.map((tab) => tab.code),
|
|
56
63
|
children: tabs.map((tab) => {
|
|
57
64
|
const { examples = [] } = tab;
|
|
58
|
-
let slot =
|
|
65
|
+
let slot = t("Empty");
|
|
59
66
|
if (examples.length > 1) slot = /* @__PURE__ */ jsx(Accordions, {
|
|
60
67
|
type: "single",
|
|
61
68
|
className: "pt-2",
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRenderContext, useServerContext } from "../contexts/api.js";
|
|
3
|
+
import { ClientCodeBlock } from "../components/codeblock.js";
|
|
4
|
+
import { createCodeUsageGeneratorRegistry, pathnameFromRequest } from "../../requests/generators/index.js";
|
|
5
|
+
import { useOperationContext } from "./context.js";
|
|
6
|
+
import { ResponseTabs } from "./response-tabs.js";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@fumadocs/api-docs/components/select";
|
|
10
|
+
import { joinURL, resolveServerUrl } from "@fumadocs/api-docs/utils/url";
|
|
11
|
+
import { CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger } from "fumadocs-ui/components/codeblock";
|
|
12
|
+
//#region src/ui/operation/usage-tabs.tsx
|
|
13
|
+
function UsageTabs({ method, operation, pathItem }) {
|
|
14
|
+
const ctx = useRenderContext();
|
|
15
|
+
let { renderAPIExampleUsageTabs, renderAPIExampleLayout } = ctx.content ?? {};
|
|
16
|
+
renderAPIExampleLayout ??= (slots) => {
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
18
|
+
className: "prose-no-margin",
|
|
19
|
+
children: [
|
|
20
|
+
slots.selector,
|
|
21
|
+
slots.usageTabs,
|
|
22
|
+
slots.responseTabs
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
renderAPIExampleUsageTabs ??= (registry) => {
|
|
27
|
+
const map = Array.from(registry.map().entries());
|
|
28
|
+
if (map.length === 0) return null;
|
|
29
|
+
return /* @__PURE__ */ jsxs(CodeBlockTabs, {
|
|
30
|
+
groupId: "fumadocs_openapi_requests",
|
|
31
|
+
defaultValue: map[0][0],
|
|
32
|
+
children: [/* @__PURE__ */ jsx(CodeBlockTabsList, { children: map.map(([id, item]) => /* @__PURE__ */ jsx(CodeBlockTabsTrigger, {
|
|
33
|
+
value: id,
|
|
34
|
+
children: item.label ?? item.lang
|
|
35
|
+
}, id)) }), map.map(([id, item]) => /* @__PURE__ */ jsx(CodeBlockTab, {
|
|
36
|
+
value: id,
|
|
37
|
+
children: /* @__PURE__ */ jsx(UsageTab, {
|
|
38
|
+
id,
|
|
39
|
+
lang: item.lang
|
|
40
|
+
})
|
|
41
|
+
}, id))]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const registry = useMemo(() => {
|
|
45
|
+
const registry = createCodeUsageGeneratorRegistry(ctx.codeUsages);
|
|
46
|
+
if (ctx.generateCodeSamples) for (const gen of ctx.generateCodeSamples({
|
|
47
|
+
operation,
|
|
48
|
+
method,
|
|
49
|
+
pathItem
|
|
50
|
+
})) registry.addInline(gen);
|
|
51
|
+
if (operation["x-codeSamples"]) for (const sample of operation["x-codeSamples"]) registry.addInline(sample);
|
|
52
|
+
return registry;
|
|
53
|
+
}, [
|
|
54
|
+
ctx,
|
|
55
|
+
operation,
|
|
56
|
+
method,
|
|
57
|
+
pathItem
|
|
58
|
+
]);
|
|
59
|
+
return renderAPIExampleLayout({
|
|
60
|
+
selector: operation["x-exclusiveCodeSample"] ? null : /* @__PURE__ */ jsx(UsageTabsSelector, {}),
|
|
61
|
+
usageTabs: renderAPIExampleUsageTabs(registry, ctx),
|
|
62
|
+
responseTabs: /* @__PURE__ */ jsx(ResponseTabs, {
|
|
63
|
+
operation,
|
|
64
|
+
method,
|
|
65
|
+
pathItem
|
|
66
|
+
})
|
|
67
|
+
}, ctx);
|
|
68
|
+
}
|
|
69
|
+
function UsageTabsSelector() {
|
|
70
|
+
const { example: key, setExample: setKey, examples } = useOperationContext();
|
|
71
|
+
const { APIExampleSelector: Override } = useRenderContext().operation ?? {};
|
|
72
|
+
if (Override) return /* @__PURE__ */ jsx(Override, {
|
|
73
|
+
items: examples,
|
|
74
|
+
value: key,
|
|
75
|
+
onValueChange: setKey
|
|
76
|
+
});
|
|
77
|
+
function renderItem(item) {
|
|
78
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: "font-medium text-sm",
|
|
80
|
+
children: item.name
|
|
81
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
82
|
+
className: "text-fd-muted-foreground",
|
|
83
|
+
children: item.description
|
|
84
|
+
})] });
|
|
85
|
+
}
|
|
86
|
+
if (examples.length === 1) return null;
|
|
87
|
+
const selected = examples.find((item) => item.id === key);
|
|
88
|
+
return /* @__PURE__ */ jsxs(Select, {
|
|
89
|
+
value: key,
|
|
90
|
+
onValueChange: setKey,
|
|
91
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
92
|
+
className: "not-prose mb-2",
|
|
93
|
+
children: selected && /* @__PURE__ */ jsx(SelectValue, {
|
|
94
|
+
asChild: true,
|
|
95
|
+
children: renderItem(selected)
|
|
96
|
+
})
|
|
97
|
+
}), /* @__PURE__ */ jsx(SelectContent, { children: examples.map((item) => /* @__PURE__ */ jsx(SelectItem, {
|
|
98
|
+
value: item.id,
|
|
99
|
+
children: renderItem(item)
|
|
100
|
+
}, item.id)) })]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function UsageTab({ id, lang }) {
|
|
104
|
+
const { mediaAdapters, codeUsages } = useRenderContext();
|
|
105
|
+
const { examples, example: selectedExampleId, route, addListener, removeListener } = useOperationContext();
|
|
106
|
+
const { server } = useServerContext();
|
|
107
|
+
const codegen = codeUsages.get(id);
|
|
108
|
+
const [mounted, setMounted] = useState(false);
|
|
109
|
+
const [data, setData] = useState(() => examples.find((example) => example.id === selectedExampleId)?.encoded);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const listener = (_, encoded) => setData(encoded);
|
|
112
|
+
addListener(listener);
|
|
113
|
+
setMounted(true);
|
|
114
|
+
return () => {
|
|
115
|
+
removeListener(listener);
|
|
116
|
+
};
|
|
117
|
+
}, [addListener, removeListener]);
|
|
118
|
+
const code = useMemo(() => {
|
|
119
|
+
if (!data) return;
|
|
120
|
+
const url = joinURL(server && mounted ? new URL(resolveServerUrl(server.url, server.variables), window.location.origin).href : "https://example.com", pathnameFromRequest(route, data));
|
|
121
|
+
if (!codegen) return;
|
|
122
|
+
return codegen.generate({
|
|
123
|
+
...data,
|
|
124
|
+
url
|
|
125
|
+
}, {
|
|
126
|
+
mediaAdapters,
|
|
127
|
+
custom: null
|
|
128
|
+
});
|
|
129
|
+
}, [
|
|
130
|
+
data,
|
|
131
|
+
server,
|
|
132
|
+
route,
|
|
133
|
+
mounted,
|
|
134
|
+
codegen,
|
|
135
|
+
mediaAdapters
|
|
136
|
+
]);
|
|
137
|
+
if (!code) return null;
|
|
138
|
+
return /* @__PURE__ */ jsx(ClientCodeBlock, {
|
|
139
|
+
lang,
|
|
140
|
+
code
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { UsageTabs };
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { dereferenceSync } from "
|
|
1
|
+
import { dereferenceSync } from "@fumadocs/api-docs/schema/dereference";
|
|
2
2
|
//#region src/utils/document/dereference.ts
|
|
3
|
-
function
|
|
4
|
-
/**
|
|
5
|
-
* Dereferenced value and its original `$ref` value
|
|
6
|
-
*/
|
|
3
|
+
function dereferenceBundledDocument(bundled) {
|
|
7
4
|
const dereferenceMap = /* @__PURE__ */ new Map();
|
|
8
5
|
return {
|
|
9
6
|
bundled,
|
|
10
|
-
dereferenced: dereferenceSync(bundled, (schema, ref)
|
|
7
|
+
dereferenced: dereferenceSync(bundled, { setOriginalRef(schema, ref) {
|
|
11
8
|
dereferenceMap.set(schema, ref);
|
|
12
|
-
}),
|
|
9
|
+
} }),
|
|
13
10
|
getRawRef(obj) {
|
|
14
11
|
return dereferenceMap.get(obj);
|
|
15
12
|
}
|
|
16
13
|
};
|
|
17
14
|
}
|
|
18
15
|
//#endregion
|
|
19
|
-
export {
|
|
16
|
+
export { dereferenceBundledDocument };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { upgrade } from "../../node_modules/.pnpm/@scalar_openapi-upgrader@0.2.9/node_modules/@scalar/openapi-upgrader/dist/upgrade.js";
|
|
2
|
+
import { bundle } from "@fumadocs/api-docs/schema/bundle";
|
|
3
|
+
//#region src/utils/document/load.ts
|
|
4
|
+
/**
|
|
5
|
+
* Process input document to a Fumadocs OpenAPI compatible format
|
|
6
|
+
*/
|
|
7
|
+
async function loadDocument(input) {
|
|
8
|
+
try {
|
|
9
|
+
let bundled = await bundle(input);
|
|
10
|
+
bundled = upgrade(bundled, "3.2");
|
|
11
|
+
return { bundled };
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { loadDocument };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RawRequestData, RequestData } from "../requests/types.js";
|
|
2
|
+
import { NoReference } from "@fumadocs/api-docs/schema";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/get-example-requests.d.ts
|
|
5
|
+
interface ExampleRequestItem {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
data: RawRequestData;
|
|
10
|
+
encoded: RequestData;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ExampleRequestItem };
|
|
@@ -1,50 +1,62 @@
|
|
|
1
|
-
import { getPreferredType, pickExample } from "
|
|
2
|
-
import { encodeRequestData } from "
|
|
3
|
-
import { sample } from "
|
|
4
|
-
//#region src/
|
|
5
|
-
function getExampleRequests(path, operation,
|
|
1
|
+
import { getPreferredType, pickExample } from "./schema.js";
|
|
2
|
+
import { encodeRequestData } from "../requests/media/encode.js";
|
|
3
|
+
import { sample } from "@fumadocs/api-docs/schema/sample";
|
|
4
|
+
//#region src/utils/get-example-requests.ts
|
|
5
|
+
function getExampleRequests({ path, method, ctx, operation, pathItem }) {
|
|
6
6
|
const requestBody = operation.requestBody;
|
|
7
7
|
const media = requestBody?.content ? getPreferredType(requestBody.content) : null;
|
|
8
8
|
const bodyOfType = media ? requestBody.content[media] : null;
|
|
9
|
+
const parameters = [...operation.parameters ?? [], ...pathItem.parameters ?? []];
|
|
9
10
|
if (bodyOfType?.examples) {
|
|
10
11
|
const result = [];
|
|
11
12
|
for (const [key, value] of Object.entries(bodyOfType.examples)) {
|
|
12
|
-
const data = getRequestData(
|
|
13
|
+
const data = getRequestData({
|
|
14
|
+
path,
|
|
15
|
+
body: operation.requestBody,
|
|
16
|
+
parameters,
|
|
17
|
+
sampleKey: key,
|
|
18
|
+
method
|
|
19
|
+
});
|
|
13
20
|
result.push({
|
|
14
21
|
id: key,
|
|
15
22
|
name: value.summary || key,
|
|
16
23
|
description: value.description,
|
|
17
24
|
data,
|
|
18
|
-
encoded: encodeRequestData(data, ctx.mediaAdapters,
|
|
25
|
+
encoded: encodeRequestData(data, ctx.mediaAdapters, parameters)
|
|
19
26
|
});
|
|
20
27
|
}
|
|
21
28
|
if (result.length > 0) return result;
|
|
22
29
|
}
|
|
23
|
-
const data = getRequestData(
|
|
30
|
+
const data = getRequestData({
|
|
31
|
+
path,
|
|
32
|
+
body: operation.requestBody,
|
|
33
|
+
method,
|
|
34
|
+
parameters
|
|
35
|
+
});
|
|
24
36
|
return [{
|
|
25
37
|
id: "_default",
|
|
26
38
|
name: "Default",
|
|
27
39
|
description: typeof bodyOfType?.schema === "object" ? bodyOfType.schema.description : void 0,
|
|
28
40
|
data,
|
|
29
|
-
encoded: encodeRequestData(data, ctx.mediaAdapters,
|
|
41
|
+
encoded: encodeRequestData(data, ctx.mediaAdapters, parameters)
|
|
30
42
|
}];
|
|
31
43
|
}
|
|
32
|
-
function getRequestData(path,
|
|
44
|
+
function getRequestData({ method, path, parameters, sampleKey, body }) {
|
|
33
45
|
const result = {
|
|
34
46
|
path: {},
|
|
35
47
|
cookie: {},
|
|
36
48
|
header: {},
|
|
37
49
|
query: {},
|
|
38
|
-
method
|
|
50
|
+
method
|
|
39
51
|
};
|
|
40
|
-
for (const param of
|
|
52
|
+
for (const param of parameters) {
|
|
41
53
|
let value = pickExample(param);
|
|
42
54
|
if (value === void 0 && param.required) {
|
|
43
55
|
if (param.schema) value = sample(param.schema);
|
|
44
56
|
else if (param.content) {
|
|
45
57
|
const type = getPreferredType(param.content);
|
|
46
58
|
const content = type ? param.content[type] : void 0;
|
|
47
|
-
if (!content || !content.schema) throw new Error(`Cannot find "${param.name}" parameter info for media type "${type}" in ${path} ${method
|
|
59
|
+
if (!content || !content.schema) throw new Error(`Cannot find "${param.name}" parameter info for media type "${type}" in ${path} ${method}`);
|
|
48
60
|
value = sample(content.schema);
|
|
49
61
|
}
|
|
50
62
|
}
|
|
@@ -61,17 +73,16 @@ function getRequestData(path, method, sampleKey, _ctx) {
|
|
|
61
73
|
default: result.path[param.name] = value;
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
|
-
if (
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
if (!type) throw new Error(`Cannot find body schema for ${path} ${method.method}: missing media type`);
|
|
76
|
+
if (body?.content) {
|
|
77
|
+
const type = getPreferredType(body.content);
|
|
78
|
+
if (!type) throw new Error(`Cannot find body schema for ${path} ${method}: missing media type`);
|
|
68
79
|
result.bodyMediaType = type;
|
|
69
|
-
const bodyOfType = body[type];
|
|
80
|
+
const bodyOfType = body.content[type];
|
|
70
81
|
if (bodyOfType.examples && sampleKey) result.body = bodyOfType.examples[sampleKey].value;
|
|
71
82
|
else if (bodyOfType.example) result.body = bodyOfType.example;
|
|
72
83
|
else result.body = sample(bodyOfType?.schema ?? {}, {
|
|
73
|
-
skipReadOnly: method
|
|
74
|
-
skipWriteOnly: method
|
|
84
|
+
skipReadOnly: method !== "get",
|
|
85
|
+
skipWriteOnly: method === "get",
|
|
75
86
|
skipNonRequired: true
|
|
76
87
|
});
|
|
77
88
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { NoReference } from "../schema/index.js";
|
|
4
|
-
import { DereferencedDocument } from "../document/dereference.js";
|
|
1
|
+
import { Document, HttpMethods, OperationObject, PathItemObject, TagObject } from "../../types.js";
|
|
2
|
+
import { NoReferenceSwallow } from "@fumadocs/api-docs/schema";
|
|
5
3
|
|
|
6
4
|
//#region src/utils/pages/builder.d.ts
|
|
7
5
|
interface BaseEntry {
|
|
@@ -34,6 +32,23 @@ interface OutputGroup extends BaseEntry {
|
|
|
34
32
|
/** tag info if the group is generated from a tag. */
|
|
35
33
|
tag?: TagObject;
|
|
36
34
|
}
|
|
35
|
+
interface WebhookItem {
|
|
36
|
+
/**
|
|
37
|
+
* webhook name in `webhooks`
|
|
38
|
+
*/
|
|
39
|
+
name: string;
|
|
40
|
+
method: HttpMethods;
|
|
41
|
+
}
|
|
42
|
+
interface OperationItem {
|
|
43
|
+
/**
|
|
44
|
+
* the path of operation in `paths`
|
|
45
|
+
*/
|
|
46
|
+
path: string;
|
|
47
|
+
/**
|
|
48
|
+
* the HTTP method of operation
|
|
49
|
+
*/
|
|
50
|
+
method: HttpMethods;
|
|
51
|
+
}
|
|
37
52
|
type OutputEntry = PageOutput | OperationOutput | WebhookOutput | OutputGroup;
|
|
38
53
|
interface PagesBuilderConfig {
|
|
39
54
|
toPages: (builder: PagesBuilder) => void;
|
|
@@ -43,7 +58,9 @@ interface PagesBuilder {
|
|
|
43
58
|
* the input ID in OpenAPI server
|
|
44
59
|
*/
|
|
45
60
|
id: string;
|
|
46
|
-
document
|
|
61
|
+
/** bundled OpenAPI document (not dereferenced) */
|
|
62
|
+
document: Document;
|
|
63
|
+
dereferenceShallow: <T>(schema: T) => NoReferenceSwallow<T>;
|
|
47
64
|
/**
|
|
48
65
|
* add output entry.
|
|
49
66
|
*/
|
|
@@ -58,13 +75,13 @@ interface PagesBuilder {
|
|
|
58
75
|
extract: () => ExtractedInfo;
|
|
59
76
|
fromExtractedWebhook: (item: WebhookItem) => {
|
|
60
77
|
get displayName(): string;
|
|
61
|
-
pathItem:
|
|
62
|
-
operation:
|
|
78
|
+
pathItem: PathItemObject;
|
|
79
|
+
operation: OperationObject;
|
|
63
80
|
} | undefined;
|
|
64
81
|
fromExtractedOperation: (item: OperationItem) => {
|
|
65
82
|
get displayName(): string;
|
|
66
|
-
pathItem:
|
|
67
|
-
operation:
|
|
83
|
+
pathItem: PathItemObject;
|
|
84
|
+
operation: OperationObject;
|
|
68
85
|
} | undefined;
|
|
69
86
|
fromTag: (tag: TagObject) => {
|
|
70
87
|
get displayName(): string;
|
|
@@ -82,5 +99,16 @@ interface ExtractedInfo {
|
|
|
82
99
|
tags?: string[];
|
|
83
100
|
})[];
|
|
84
101
|
}
|
|
102
|
+
interface GeneratedPageProps {
|
|
103
|
+
/** schema ID */
|
|
104
|
+
document: string;
|
|
105
|
+
showTitle?: boolean;
|
|
106
|
+
showDescription?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* An array of operations
|
|
109
|
+
*/
|
|
110
|
+
operations?: OperationItem[];
|
|
111
|
+
webhooks?: WebhookItem[];
|
|
112
|
+
}
|
|
85
113
|
//#endregion
|
|
86
|
-
export { OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookOutput };
|
|
114
|
+
export { GeneratedPageProps, OperationItem, OperationOutput, OutputEntry, OutputGroup, PageOutput, PagesBuilder, PagesBuilderConfig, WebhookItem, WebhookOutput };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getTagDisplayName, methodKeys } from "../schema.js";
|
|
2
|
+
import { idToTitle } from "@fumadocs/api-docs/utils/id-to-title";
|
|
3
|
+
import { dereferenceShallow } from "@fumadocs/api-docs/schema/dereference";
|
|
3
4
|
//#region src/utils/pages/builder.ts
|
|
4
|
-
function fromSchema(schemaId,
|
|
5
|
+
function fromSchema(schemaId, bundled, config) {
|
|
5
6
|
const files = [];
|
|
6
7
|
const { toPages } = config;
|
|
7
|
-
const { dereferenced } = processed;
|
|
8
8
|
toPages({
|
|
9
9
|
id: schemaId,
|
|
10
|
-
document:
|
|
10
|
+
document: bundled,
|
|
11
|
+
dereferenceShallow: (s) => dereferenceShallow(s, bundled),
|
|
11
12
|
create(entry) {
|
|
12
13
|
files.push(entry);
|
|
13
14
|
},
|
|
@@ -16,7 +17,7 @@ function fromSchema(schemaId, processed, config) {
|
|
|
16
17
|
webhooks: [],
|
|
17
18
|
operations: []
|
|
18
19
|
};
|
|
19
|
-
for (const [path, pathItem] of Object.entries(
|
|
20
|
+
for (const [path, pathItem] of Object.entries(bundled.paths ?? {})) {
|
|
20
21
|
if (!pathItem) continue;
|
|
21
22
|
for (const methodKey of methodKeys) {
|
|
22
23
|
if (!pathItem[methodKey]) continue;
|
|
@@ -27,7 +28,8 @@ function fromSchema(schemaId, processed, config) {
|
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
for (const [name,
|
|
31
|
+
for (const [name, _pathItem] of Object.entries(bundled.webhooks ?? {})) {
|
|
32
|
+
const pathItem = dereferenceShallow(_pathItem, bundled);
|
|
31
33
|
if (!pathItem) continue;
|
|
32
34
|
for (const methodKey of methodKeys) {
|
|
33
35
|
if (!pathItem[methodKey]) continue;
|
|
@@ -48,7 +50,7 @@ function fromSchema(schemaId, processed, config) {
|
|
|
48
50
|
}).join("/");
|
|
49
51
|
},
|
|
50
52
|
fromExtractedWebhook(item) {
|
|
51
|
-
const pathItem =
|
|
53
|
+
const pathItem = dereferenceShallow(bundled.webhooks?.[item.name], bundled);
|
|
52
54
|
if (!pathItem) return;
|
|
53
55
|
const operation = pathItem?.[item.method];
|
|
54
56
|
if (!operation) return;
|
|
@@ -61,7 +63,7 @@ function fromSchema(schemaId, processed, config) {
|
|
|
61
63
|
};
|
|
62
64
|
},
|
|
63
65
|
fromExtractedOperation(item) {
|
|
64
|
-
const pathItem =
|
|
66
|
+
const pathItem = dereferenceShallow(bundled.paths?.[item.path], bundled);
|
|
65
67
|
if (!pathItem) return;
|
|
66
68
|
const operation = pathItem?.[item.method];
|
|
67
69
|
if (!operation) return;
|
|
@@ -79,7 +81,7 @@ function fromSchema(schemaId, processed, config) {
|
|
|
79
81
|
} };
|
|
80
82
|
},
|
|
81
83
|
fromTagName(name) {
|
|
82
|
-
const tag =
|
|
84
|
+
const tag = bundled.tags?.find((item) => item.name === name);
|
|
83
85
|
if (!tag) return;
|
|
84
86
|
return {
|
|
85
87
|
info: tag,
|