fumadocs-openapi 10.10.2 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/generated/shared.css +1 -1151
- package/css/preset.css +1 -0
- package/dist/.translations/index.d.ts +80 -0
- package/dist/.translations/keys.js +80 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -10
- package/dist/generate-file.d.ts +0 -4
- package/dist/generate-file.js +4 -5
- package/dist/i18n.d.ts +5 -100
- package/dist/i18n.js +8 -108
- package/dist/index.d.ts +4 -4
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/2.0-to-3.0/upgrade-from-two-to-three.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.0-to-3.1/upgrade-from-three-to-three-one.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/3.1-to-3.2/upgrade-from-three-one-to-three-two.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/helpers/traverse.js +1 -1
- package/dist/node_modules/.pnpm/{@scalar_openapi-upgrader@0.2.8 → @scalar_openapi-upgrader@0.2.9}/node_modules/@scalar/openapi-upgrader/dist/upgrade.js +1 -1
- package/dist/playground/auth.js +4 -4
- package/dist/playground/client.d.ts +12 -21
- package/dist/playground/client.js +80 -59
- package/dist/playground/components/oauth-dialog.js +33 -33
- package/dist/playground/components/result-display.d.ts +1 -2
- package/dist/playground/components/result-display.js +7 -8
- package/dist/playground/components/server-select.js +11 -11
- package/dist/playground/status-info.js +29 -37
- package/dist/requests/generators/csharp.js +3 -3
- package/dist/requests/generators/curl.js +2 -2
- package/dist/requests/generators/go.js +2 -2
- package/dist/requests/generators/index.d.ts +28 -41
- package/dist/requests/generators/index.js +18 -35
- package/dist/requests/generators/java.js +2 -2
- package/dist/requests/generators/javascript.js +2 -2
- package/dist/requests/generators/python.js +2 -2
- package/dist/scalar/client.js +3 -2
- package/dist/scalar/index.d.ts +2 -2
- package/dist/scalar/index.js +10 -9
- package/dist/server/index.d.ts +23 -27
- package/dist/server/index.js +42 -38
- package/dist/server/proxy.d.ts +0 -6
- package/dist/server/proxy.js +2 -4
- package/dist/{_openapi/types.d.ts → types/openapi.d.ts} +127 -136
- package/dist/types.d.ts +14 -18
- package/dist/ui/base.d.ts +15 -162
- package/dist/ui/base.js +148 -107
- package/dist/ui/components/codeblock.js +6 -14
- package/dist/ui/components/heading.js +8 -4
- package/dist/ui/components/markdown.js +12 -0
- package/dist/ui/contexts/api.js +8 -26
- package/dist/ui/index.d.ts +204 -7
- package/dist/ui/index.js +10 -15
- package/dist/ui/operation/context.js +48 -0
- package/dist/ui/operation/index.js +168 -126
- package/dist/ui/operation/request-tabs.d.ts +10 -5
- package/dist/ui/operation/request-tabs.js +35 -22
- package/dist/ui/operation/response-tabs.d.ts +5 -2
- package/dist/ui/operation/response-tabs.js +22 -15
- package/dist/ui/operation/usage-tabs.js +144 -0
- package/dist/utils/document/dereference.d.ts +1 -1
- package/dist/utils/document/dereference.js +5 -8
- package/dist/utils/document/load.js +17 -0
- package/dist/utils/get-example-requests.d.ts +13 -0
- package/dist/{ui/operation → utils}/get-example-requests.js +31 -20
- package/dist/utils/pages/builder.d.ts +38 -10
- package/dist/utils/pages/builder.js +12 -10
- package/dist/utils/pages/preset-auto.d.ts +1 -2
- package/dist/utils/pages/preset-auto.js +15 -15
- package/dist/utils/pages/to-static-data.js +5 -4
- package/dist/utils/pages/to-text.d.ts +1 -0
- package/dist/utils/pages/to-text.js +21 -11
- package/dist/utils/remove-undefined.js +14 -9
- package/dist/utils/schema.d.ts +2 -0
- package/dist/utils/{schema/index.js → schema.js} +3 -30
- package/dist/{ui/client → utils}/storage-key.js +3 -3
- package/package.json +16 -29
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/bundle.js +0 -239
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/dereference.js +0 -187
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js +0 -136
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js +0 -41
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js +0 -124
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parse.js +0 -109
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/binary.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js +0 -46
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js +0 -36
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/yaml.js +0 -49
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/pointer.js +0 -242
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/ref.js +0 -247
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/refs.js +0 -210
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolve-external.js +0 -100
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js +0 -41
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/http.js +0 -112
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js +0 -8
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js +0 -146
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/is-windows.js +0 -5
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/maybe.js +0 -18
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/next.js +0 -11
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/plugins.js +0 -99
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/schema-resources.js +0 -30
- package/dist/node_modules/.pnpm/@apidevtools_json-schema-ref-parser@15.3.5_@types_json-schema@7.0.15/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js +0 -315
- package/dist/node_modules/.pnpm/@fastify_deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js +0 -108
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +0 -110
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +0 -138
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +0 -674
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +0 -141
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +0 -102
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +0 -223
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +0 -133
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +0 -146
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +0 -172
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +0 -433
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +0 -113
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +0 -583
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +0 -42
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +0 -50
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +0 -36
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +0 -85
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +0 -25
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +0 -12
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -57
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -96
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -29
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -89
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -87
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +0 -16
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -62
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -60
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -34
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -31
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -51
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -61
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -52
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -41
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +0 -130
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +0 -112
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -101
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -14
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +0 -35
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +0 -45
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +0 -22
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +0 -20
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +0 -15
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +0 -10
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +0 -23
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +0 -19
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +0 -13
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +0 -46
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +0 -59
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +0 -17
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -49
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +0 -48
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +0 -18
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -33
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -47
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -28
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -27
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -38
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +0 -72
- package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -70
- package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +0 -33
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/index.js +0 -236
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/schemes.js +0 -187
- package/dist/node_modules/.pnpm/fast-uri@3.1.0/node_modules/fast-uri/lib/utils.js +0 -282
- package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +0 -78
- package/dist/playground/components/inputs.js +0 -419
- package/dist/playground/components/spinner.js +0 -15
- package/dist/playground/schema.d.ts +0 -15
- package/dist/playground/schema.js +0 -144
- package/dist/ui/api-page.d.ts +0 -31
- package/dist/ui/api-page.js +0 -59
- package/dist/ui/client/boundary.d.ts +0 -11
- package/dist/ui/client/boundary.js +0 -17
- package/dist/ui/client/boundary.lazy.js +0 -19
- package/dist/ui/client/full.js +0 -13
- package/dist/ui/client/i18n.js +0 -16
- package/dist/ui/client/index.d.ts +0 -42
- package/dist/ui/client/index.js +0 -7
- package/dist/ui/components/accordion.js +0 -67
- package/dist/ui/components/codeblock.d.ts +0 -14
- package/dist/ui/components/dialog.js +0 -56
- package/dist/ui/components/input.js +0 -17
- package/dist/ui/components/select-tab.js +0 -56
- package/dist/ui/components/select.js +0 -71
- package/dist/ui/contexts/api.d.ts +0 -29
- package/dist/ui/create-client.d.ts +0 -26
- package/dist/ui/create-client.js +0 -125
- package/dist/ui/operation/client.js +0 -78
- package/dist/ui/operation/get-example-requests.d.ts +0 -11
- package/dist/ui/operation/usage-tabs/client.d.ts +0 -14
- package/dist/ui/operation/usage-tabs/client.js +0 -91
- package/dist/ui/operation/usage-tabs/index.js +0 -54
- package/dist/ui/schema/client.d.ts +0 -18
- package/dist/ui/schema/client.js +0 -409
- package/dist/ui/schema/index.d.ts +0 -61
- package/dist/ui/schema/index.js +0 -256
- package/dist/utils/auto-anchor.client.js +0 -20
- package/dist/utils/auto-anchor.js +0 -17
- package/dist/utils/deep-equal.js +0 -21
- package/dist/utils/document/process.d.ts +0 -6
- package/dist/utils/document/process.js +0 -18
- package/dist/utils/id-to-title.js +0 -12
- package/dist/utils/is-plain-object.js +0 -8
- package/dist/utils/merge-refs.js +0 -11
- package/dist/utils/schema/dereference.js +0 -45
- package/dist/utils/schema/index.d.ts +0 -18
- package/dist/utils/schema/merge.js +0 -156
- package/dist/utils/schema/pick.js +0 -44
- package/dist/utils/schema/ref.js +0 -35
- package/dist/utils/schema/resolve-ref.js +0 -11
- package/dist/utils/schema/sample.js +0 -442
- package/dist/utils/schema/to-string.d.ts +0 -1
- package/dist/utils/schema/to-string.js +0 -53
- package/dist/utils/url.js +0 -39
package/dist/ui/schema/index.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { I18nLabel } from "../client/i18n.js";
|
|
2
|
-
import { mergeAllOf } from "../../utils/schema/merge.js";
|
|
3
|
-
import { schemaToString } from "../../utils/schema/to-string.js";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
//#region src/ui/schema/index.tsx
|
|
7
|
-
function Schema({ ctx, client, root, readOnly, writeOnly }) {
|
|
8
|
-
const generated = useMemo(() => generateSchemaUI(root, readOnly, writeOnly, ctx), [
|
|
9
|
-
root,
|
|
10
|
-
readOnly,
|
|
11
|
-
writeOnly,
|
|
12
|
-
ctx
|
|
13
|
-
]);
|
|
14
|
-
if (ctx.schemaUI?.render) return ctx.schemaUI.render({
|
|
15
|
-
client,
|
|
16
|
-
root,
|
|
17
|
-
readOnly,
|
|
18
|
-
writeOnly
|
|
19
|
-
}, ctx);
|
|
20
|
-
return /* @__PURE__ */ jsx(ctx.clientBoundary.SchemaUI, {
|
|
21
|
-
...client,
|
|
22
|
-
generated
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function generateSchemaUI(root, readOnly = false, writeOnly = false, ctx) {
|
|
26
|
-
const refs = {};
|
|
27
|
-
const { showExample = false } = ctx.schemaUI ?? {};
|
|
28
|
-
function generateInfoTags(schema) {
|
|
29
|
-
const fields = [];
|
|
30
|
-
if (schema.default !== void 0) fields.push({
|
|
31
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaDefault" }),
|
|
32
|
-
value: JSON.stringify(schema.default)
|
|
33
|
-
});
|
|
34
|
-
if (schema.pattern) fields.push({
|
|
35
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaMatch" }),
|
|
36
|
-
value: schema.pattern
|
|
37
|
-
});
|
|
38
|
-
if (schema.format) fields.push({
|
|
39
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaFormat" }),
|
|
40
|
-
value: schema.format
|
|
41
|
-
});
|
|
42
|
-
if (schema.multipleOf) fields.push({
|
|
43
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaMultipleOf" }),
|
|
44
|
-
value: schema.multipleOf.toString()
|
|
45
|
-
});
|
|
46
|
-
let range = formatRange("value", schema.minimum, schema.exclusiveMinimum, schema.maximum, schema.exclusiveMaximum);
|
|
47
|
-
if (range) fields.push({
|
|
48
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaRange" }),
|
|
49
|
-
value: range
|
|
50
|
-
});
|
|
51
|
-
range = formatRange("length", schema.minLength, void 0, schema.maxLength, void 0);
|
|
52
|
-
if (range) fields.push({
|
|
53
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaLength" }),
|
|
54
|
-
value: range
|
|
55
|
-
});
|
|
56
|
-
range = formatRange("properties", schema.minProperties, void 0, schema.maxProperties, void 0);
|
|
57
|
-
if (range) fields.push({
|
|
58
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaProperties" }),
|
|
59
|
-
value: range
|
|
60
|
-
});
|
|
61
|
-
range = formatRange("items", schema.minItems, void 0, schema.maxItems, void 0);
|
|
62
|
-
if (range) fields.push({
|
|
63
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaItems" }),
|
|
64
|
-
value: range
|
|
65
|
-
});
|
|
66
|
-
if (schema.enum) fields.push({
|
|
67
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaValueIn" }),
|
|
68
|
-
value: schema.enum.map((value) => JSON.stringify(value)).join(" | ")
|
|
69
|
-
});
|
|
70
|
-
if (showExample && schema.examples) for (const example of schema.examples) fields.push({
|
|
71
|
-
label: /* @__PURE__ */ jsx(I18nLabel, { label: "schemaExample" }),
|
|
72
|
-
value: JSON.stringify(example, null, 2)
|
|
73
|
-
});
|
|
74
|
-
return fields;
|
|
75
|
-
}
|
|
76
|
-
let _counter = 0;
|
|
77
|
-
const autoIds = /* @__PURE__ */ new WeakMap();
|
|
78
|
-
function getSchemaId(schema) {
|
|
79
|
-
if (typeof schema === "boolean") return String(schema);
|
|
80
|
-
const raw = ctx.schema.getRawRef(schema);
|
|
81
|
-
if (raw) return raw;
|
|
82
|
-
const prev = autoIds.get(schema);
|
|
83
|
-
if (prev) return prev;
|
|
84
|
-
const generated = `__${_counter++}`;
|
|
85
|
-
autoIds.set(schema, generated);
|
|
86
|
-
return generated;
|
|
87
|
-
}
|
|
88
|
-
function isVisible(schema) {
|
|
89
|
-
if (typeof schema === "boolean") return true;
|
|
90
|
-
if (schema.writeOnly) return writeOnly;
|
|
91
|
-
if (schema.readOnly) return readOnly;
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
function base(schema) {
|
|
95
|
-
if (typeof schema === "boolean") {
|
|
96
|
-
const name = schema ? "any" : "never";
|
|
97
|
-
return {
|
|
98
|
-
typeName: name,
|
|
99
|
-
aliasName: name
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
description: schema.description ? ctx.renderMarkdown(schema.description) : void 0,
|
|
104
|
-
infoTags: generateInfoTags(schema),
|
|
105
|
-
typeName: schemaToString(schema, ctx.schema),
|
|
106
|
-
aliasName: schemaToString(schema, ctx.schema, 1),
|
|
107
|
-
deprecated: schema.deprecated
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function scanRefs(id, schema) {
|
|
111
|
-
if (id in refs) return;
|
|
112
|
-
if (typeof schema === "boolean") {
|
|
113
|
-
refs[id] = {
|
|
114
|
-
type: "primitive",
|
|
115
|
-
...base(schema)
|
|
116
|
-
};
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (Array.isArray(schema.type)) {
|
|
120
|
-
const out = {
|
|
121
|
-
type: "or",
|
|
122
|
-
items: [],
|
|
123
|
-
...base(schema)
|
|
124
|
-
};
|
|
125
|
-
refs[id] = out;
|
|
126
|
-
for (const type of schema.type) {
|
|
127
|
-
const key = `${id}_type:${type}`;
|
|
128
|
-
scanRefs(key, {
|
|
129
|
-
...schema,
|
|
130
|
-
type
|
|
131
|
-
});
|
|
132
|
-
out.items.push({
|
|
133
|
-
name: type,
|
|
134
|
-
$type: key
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (schema.oneOf && schema.anyOf) {
|
|
140
|
-
const out = {
|
|
141
|
-
type: "and",
|
|
142
|
-
items: [],
|
|
143
|
-
...base(schema)
|
|
144
|
-
};
|
|
145
|
-
refs[id] = out;
|
|
146
|
-
for (const omit of ["anyOf", "oneOf"]) {
|
|
147
|
-
const $type = `${id}_omit:${omit}`;
|
|
148
|
-
scanRefs($type, {
|
|
149
|
-
...schema,
|
|
150
|
-
[omit]: void 0
|
|
151
|
-
});
|
|
152
|
-
out.items.push({
|
|
153
|
-
name: refs[$type].aliasName,
|
|
154
|
-
$type
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const union = schema.oneOf ?? schema.anyOf;
|
|
160
|
-
if (union) {
|
|
161
|
-
const out = {
|
|
162
|
-
type: "or",
|
|
163
|
-
items: [],
|
|
164
|
-
...base(schema)
|
|
165
|
-
};
|
|
166
|
-
refs[id] = out;
|
|
167
|
-
for (const item of union) {
|
|
168
|
-
if (!item || typeof item !== "object" || !isVisible(item)) continue;
|
|
169
|
-
const itemId = getSchemaId(item);
|
|
170
|
-
const key = `${id}_extends:${itemId}`;
|
|
171
|
-
scanRefs(key, {
|
|
172
|
-
...schema,
|
|
173
|
-
oneOf: void 0,
|
|
174
|
-
anyOf: void 0,
|
|
175
|
-
...item,
|
|
176
|
-
properties: {
|
|
177
|
-
...schema.properties,
|
|
178
|
-
...item.properties
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
out.items.push({
|
|
182
|
-
$type: key,
|
|
183
|
-
name: refs[itemId]?.aliasName ?? schemaToString(item, ctx.schema, 1)
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
if (schema.allOf) {
|
|
189
|
-
scanRefs(id, mergeAllOf(schema));
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (schema.type === "object") {
|
|
193
|
-
const out = {
|
|
194
|
-
type: "object",
|
|
195
|
-
props: [],
|
|
196
|
-
...base(schema)
|
|
197
|
-
};
|
|
198
|
-
refs[id] = out;
|
|
199
|
-
const { properties = {}, patternProperties, additionalProperties } = schema;
|
|
200
|
-
const props = Object.entries(properties);
|
|
201
|
-
if (patternProperties) props.push(...Object.entries(patternProperties));
|
|
202
|
-
for (const [key, prop] of props) {
|
|
203
|
-
if (!prop || !isVisible(prop)) continue;
|
|
204
|
-
const $type = getSchemaId(prop);
|
|
205
|
-
scanRefs($type, prop);
|
|
206
|
-
out.props.push({
|
|
207
|
-
$type,
|
|
208
|
-
name: key,
|
|
209
|
-
required: schema.required?.includes(key) ?? false
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (additionalProperties && isVisible(additionalProperties)) {
|
|
213
|
-
const $type = getSchemaId(additionalProperties);
|
|
214
|
-
scanRefs($type, additionalProperties);
|
|
215
|
-
out.props.push({
|
|
216
|
-
$type,
|
|
217
|
-
name: "[key: string]",
|
|
218
|
-
required: false
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
if (schema.type === "array") {
|
|
224
|
-
const items = schema.items ?? true;
|
|
225
|
-
const $type = getSchemaId(items);
|
|
226
|
-
refs[id] = {
|
|
227
|
-
type: "array",
|
|
228
|
-
item: { $type },
|
|
229
|
-
...base(schema)
|
|
230
|
-
};
|
|
231
|
-
scanRefs($type, items);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
refs[id] = {
|
|
235
|
-
type: "primitive",
|
|
236
|
-
...base(schema)
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
const $root = getSchemaId(root);
|
|
240
|
-
scanRefs($root, root);
|
|
241
|
-
return {
|
|
242
|
-
refs,
|
|
243
|
-
$root
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
function formatRange(value, min, exclusiveMin, max, exclusiveMax) {
|
|
247
|
-
const out = [];
|
|
248
|
-
if (min !== void 0) out.push(`${min} <=`);
|
|
249
|
-
else if (exclusiveMin !== void 0) out.push(`${exclusiveMin} <`);
|
|
250
|
-
out.push(value);
|
|
251
|
-
if (max !== void 0) out.push(`<= ${max}`);
|
|
252
|
-
else if (exclusiveMax !== void 0) out.push(`< ${exclusiveMax}`);
|
|
253
|
-
if (out.length > 1) return out.join(" ");
|
|
254
|
-
}
|
|
255
|
-
//#endregion
|
|
256
|
-
export { Schema };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { anchorSegments } from "./auto-anchor.js";
|
|
3
|
-
import { createContext, use, useMemo } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/utils/auto-anchor.client.tsx
|
|
6
|
-
const AnchorContext = createContext([]);
|
|
7
|
-
/** Append segment to anchor IDs */
|
|
8
|
-
function AnchorSection({ segments, children }) {
|
|
9
|
-
const v = use(AnchorContext);
|
|
10
|
-
return /* @__PURE__ */ jsx(AnchorContext, {
|
|
11
|
-
value: useMemo(() => [...v, ...segments], [v, segments]),
|
|
12
|
-
children
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function useAnchorId(segments) {
|
|
16
|
-
if (!segments) return null;
|
|
17
|
-
return anchorSegments(...use(AnchorContext), ...segments);
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
export { AnchorSection, useAnchorId };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { slug } from "github-slugger";
|
|
2
|
-
//#region src/utils/auto-anchor.ts
|
|
3
|
-
/** slugify segments, append `\0` to keep segment as-is */
|
|
4
|
-
function anchorSegments(...segs) {
|
|
5
|
-
const mapped = [];
|
|
6
|
-
for (const seg of segs) if (seg.startsWith("\0")) mapped.push(seg.slice(1));
|
|
7
|
-
else if (seg.length > 0) mapped.push(slug(seg));
|
|
8
|
-
return mapped.join(".");
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Check if `id1` starts with `id2`
|
|
12
|
-
*/
|
|
13
|
-
function anchorIdStartsWith(id1, id2) {
|
|
14
|
-
return id1 === id2 || id1.startsWith(`${id2}.`);
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { anchorIdStartsWith, anchorSegments };
|
package/dist/utils/deep-equal.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "./is-plain-object.js";
|
|
2
|
-
//#region src/utils/deep-equal.ts
|
|
3
|
-
function deepEqual(a, b) {
|
|
4
|
-
if (a === b) return true;
|
|
5
|
-
if (a == null || b == null) return false;
|
|
6
|
-
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
7
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
8
|
-
if (a.length !== b.length) return false;
|
|
9
|
-
return a.every((item, index) => deepEqual(item, b[index]));
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(a) || Array.isArray(b)) return false;
|
|
12
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
13
|
-
const keysA = Object.keys(a);
|
|
14
|
-
const keysB = Object.keys(b);
|
|
15
|
-
if (keysA.length !== keysB.length) return false;
|
|
16
|
-
return keysA.every((key) => key in b && deepEqual(a[key], b[key]));
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { deepEqual };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { upgrade } from "../../node_modules/.pnpm/@scalar_openapi-upgrader@0.2.8/node_modules/@scalar/openapi-upgrader/dist/upgrade.js";
|
|
2
|
-
import { dereferenceDocument } from "./dereference.js";
|
|
3
|
-
import { bundle } from "../../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";
|
|
4
|
-
//#region src/utils/document/process.ts
|
|
5
|
-
/**
|
|
6
|
-
* process & reference input document to a Fumadocs OpenAPI compatible format
|
|
7
|
-
*/
|
|
8
|
-
async function processDocument(input) {
|
|
9
|
-
try {
|
|
10
|
-
let bundled = await bundle(input);
|
|
11
|
-
bundled = upgrade(bundled, "3.2");
|
|
12
|
-
return dereferenceDocument(bundled);
|
|
13
|
-
} catch (e) {
|
|
14
|
-
throw new Error(`[OpenAPI] Failed to resolve input: ${input}`, { cause: e });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { processDocument };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/utils/id-to-title.ts
|
|
2
|
-
function idToTitle(id) {
|
|
3
|
-
let result = [];
|
|
4
|
-
for (const c of id) if (result.length === 0) result.push(c.toLocaleUpperCase());
|
|
5
|
-
else if (c === ".") result = [];
|
|
6
|
-
else if (/^[A-Z]$/.test(c) && result.at(-1) !== " ") result.push(" ", c);
|
|
7
|
-
else if (c === "-") result.push(" ");
|
|
8
|
-
else result.push(c);
|
|
9
|
-
return result.join("");
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { idToTitle };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/utils/is-plain-object.ts
|
|
2
|
-
function isPlainObject(value) {
|
|
3
|
-
if (typeof value !== "object" || value === null) return false;
|
|
4
|
-
const prototype = Object.getPrototypeOf(value);
|
|
5
|
-
return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { isPlainObject };
|
package/dist/utils/merge-refs.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region src/utils/merge-refs.ts
|
|
2
|
-
function mergeRefs(...refs) {
|
|
3
|
-
return (value) => {
|
|
4
|
-
refs.forEach((ref) => {
|
|
5
|
-
if (typeof ref === "function") ref(value);
|
|
6
|
-
else if (ref != null) ref.current = value;
|
|
7
|
-
});
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { mergeRefs };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "../is-plain-object.js";
|
|
2
|
-
import { resolveRefSync } from "./resolve-ref.js";
|
|
3
|
-
//#region src/utils/schema/dereference.ts
|
|
4
|
-
/**
|
|
5
|
-
* Resolves all $ref pointers in a schema and returns a new schema without any $ref pointers.
|
|
6
|
-
*/
|
|
7
|
-
function dereferenceSync(schema, setOriginalRef) {
|
|
8
|
-
if (typeof schema === "boolean") return schema;
|
|
9
|
-
const visitedNodes = /* @__PURE__ */ new Set();
|
|
10
|
-
const cloned = structuredClone(schema);
|
|
11
|
-
function resolve(current) {
|
|
12
|
-
if (visitedNodes.has(current)) return current;
|
|
13
|
-
visitedNodes.add(current);
|
|
14
|
-
if (Array.isArray(current)) for (let index = 0; index < current.length; index++) current[index] = resolve(current[index]);
|
|
15
|
-
else if (isPlainObject(current)) {
|
|
16
|
-
if (typeof current.$ref === "string") {
|
|
17
|
-
const ref = current["$ref"];
|
|
18
|
-
delete current["$ref"];
|
|
19
|
-
const resolved = resolve(resolveRefSync(ref, cloned));
|
|
20
|
-
setOriginalRef(resolved, ref);
|
|
21
|
-
setOriginalRef(current, ref);
|
|
22
|
-
if (typeof resolved === "boolean") throw new Error("invalid schema");
|
|
23
|
-
for (const k in resolved) if (!(k in current)) current[k] = resolved[k];
|
|
24
|
-
}
|
|
25
|
-
for (const key in current) current[key] = resolve(current[key]);
|
|
26
|
-
}
|
|
27
|
-
return current;
|
|
28
|
-
}
|
|
29
|
-
return resolve(cloned);
|
|
30
|
-
}
|
|
31
|
-
function dereferenceSwallow(schema, full) {
|
|
32
|
-
if (isPlainObject(schema)) {
|
|
33
|
-
if (typeof schema.$ref !== "string") return schema;
|
|
34
|
-
const { $ref, ...rest } = schema;
|
|
35
|
-
const resolved = dereferenceSwallow(resolveRefSync($ref, full), full);
|
|
36
|
-
if (typeof resolved !== "object") throw new Error(`invalid schema referenced via "${$ref}"`);
|
|
37
|
-
return {
|
|
38
|
-
...resolved,
|
|
39
|
-
...rest
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return schema;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { dereferenceSwallow, dereferenceSync };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ReferenceObject } from "../../types.js";
|
|
2
|
-
import { JSONSchema } from "json-schema-typed/draft-2020-12";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/schema/index.d.ts
|
|
5
|
-
type NoReference<T> = T extends (infer I)[] ? NoReference<I>[] : T extends ReferenceObject ? Exclude<T, ReferenceObject> : T extends object ? { [K in keyof T]: NoReference<T[K]> } : T;
|
|
6
|
-
type ParsedSchema = (JSONSchema & {
|
|
7
|
-
'x-playground-lazy'?: boolean;
|
|
8
|
-
discriminator?: {
|
|
9
|
-
propertyName?: string;
|
|
10
|
-
mapping?: Record<string, string>;
|
|
11
|
-
};
|
|
12
|
-
}) | boolean;
|
|
13
|
-
interface SecurityEntry {
|
|
14
|
-
scopes: string[];
|
|
15
|
-
id: string;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { NoReference, ParsedSchema, SecurityEntry };
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { deepEqual } from "../deep-equal.js";
|
|
2
|
-
//#region src/utils/schema/merge.ts
|
|
3
|
-
/**
|
|
4
|
-
* Merge `allOf` object schema
|
|
5
|
-
*/
|
|
6
|
-
function mergeAllOf(schema, options = {}) {
|
|
7
|
-
if (typeof schema === "boolean") return schema;
|
|
8
|
-
const { dereference } = options;
|
|
9
|
-
if (dereference && "$ref" in schema && typeof schema.$ref === "string") schema = dereference(schema) ?? schema;
|
|
10
|
-
if (typeof schema === "boolean" || !schema.allOf) return schema;
|
|
11
|
-
const { allOf, ...rest } = schema;
|
|
12
|
-
let result = rest;
|
|
13
|
-
for (const item of allOf) result = intersection(result, item, options);
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
function intersection(a, b, options) {
|
|
17
|
-
a = mergeAllOf(a, options);
|
|
18
|
-
b = mergeAllOf(b, options);
|
|
19
|
-
if (typeof a === "boolean" && typeof b === "boolean") return a && b;
|
|
20
|
-
if (typeof a === "boolean") return a;
|
|
21
|
-
if (typeof b === "boolean") return b;
|
|
22
|
-
for (const unionField of ["anyOf", "oneOf"]) {
|
|
23
|
-
if (a[unionField] === void 0 && b[unionField] !== void 0) return {
|
|
24
|
-
...b,
|
|
25
|
-
[unionField]: b[unionField].map((item) => intersection(item, a, options))
|
|
26
|
-
};
|
|
27
|
-
if (a[unionField] !== void 0 && b[unionField] === void 0) return {
|
|
28
|
-
...a,
|
|
29
|
-
[unionField]: a[unionField].map((item) => intersection(item, b, options))
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const result = { ...a };
|
|
33
|
-
for (const _k in b) {
|
|
34
|
-
const key = _k;
|
|
35
|
-
switch (key) {
|
|
36
|
-
case "$id":
|
|
37
|
-
case "$comment":
|
|
38
|
-
case "description":
|
|
39
|
-
case "examples":
|
|
40
|
-
case "allOf":
|
|
41
|
-
case "writeOnly":
|
|
42
|
-
case "readOnly": break;
|
|
43
|
-
case "title": {
|
|
44
|
-
const value = b[key];
|
|
45
|
-
if (value === void 0) break;
|
|
46
|
-
if (result[key]) result[key] = `${result[key]} & ${value}`;
|
|
47
|
-
else result[key] = value;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case "minItems":
|
|
51
|
-
case "minimum":
|
|
52
|
-
case "exclusiveMinimum":
|
|
53
|
-
case "minProperties":
|
|
54
|
-
case "minContains":
|
|
55
|
-
case "minLength": {
|
|
56
|
-
const value = b[key];
|
|
57
|
-
if (value === void 0) break;
|
|
58
|
-
result[key] = result[key] === void 0 ? value : Math.max(result[key], value);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
case "maxContains":
|
|
62
|
-
case "maxItems":
|
|
63
|
-
case "maxLength":
|
|
64
|
-
case "maxProperties":
|
|
65
|
-
case "maximum":
|
|
66
|
-
case "exclusiveMaximum": {
|
|
67
|
-
const value = b[key];
|
|
68
|
-
if (value === void 0) break;
|
|
69
|
-
result[key] = result[key] === void 0 ? value : Math.min(result[key], value);
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "enum": {
|
|
73
|
-
const value = b[key];
|
|
74
|
-
if (value === void 0) break;
|
|
75
|
-
result[key] = result[key] === void 0 ? value : intersectArray(result[key], value);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case "anyOf":
|
|
79
|
-
case "oneOf": {
|
|
80
|
-
const value = b[key];
|
|
81
|
-
if (value !== void 0 && result[key] !== void 0) {
|
|
82
|
-
const product = [];
|
|
83
|
-
for (const aItem of result[key]) for (const bItem of value) {
|
|
84
|
-
const merged = intersection(aItem, bItem, options);
|
|
85
|
-
if (merged !== false) product.push(merged);
|
|
86
|
-
}
|
|
87
|
-
result[key] = product;
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case "format":
|
|
92
|
-
case "const":
|
|
93
|
-
case "type": {
|
|
94
|
-
const value = b[key];
|
|
95
|
-
if (value === void 0) break;
|
|
96
|
-
result[key] ??= value;
|
|
97
|
-
if (!deepEqual(result[key], value)) return false;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
case "required": {
|
|
101
|
-
const value = b[key];
|
|
102
|
-
if (value === void 0) break;
|
|
103
|
-
result[key] = [...result[key] ?? [], ...value];
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case "properties":
|
|
107
|
-
case "patternProperties": {
|
|
108
|
-
const value = b[key];
|
|
109
|
-
if (value === void 0) break;
|
|
110
|
-
if (result[key] === void 0) {
|
|
111
|
-
result[key] = value;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
const out = {};
|
|
115
|
-
const allProps = /* @__PURE__ */ new Set();
|
|
116
|
-
for (const k in result[key]) allProps.add(k);
|
|
117
|
-
for (const k in value) allProps.add(k);
|
|
118
|
-
for (const prop of allProps) {
|
|
119
|
-
const aProp = result[key][prop];
|
|
120
|
-
const bProp = value[prop];
|
|
121
|
-
if (aProp === void 0) out[prop] = bProp;
|
|
122
|
-
else if (bProp === void 0) out[prop] = aProp;
|
|
123
|
-
else out[prop] = intersection(aProp, bProp, options);
|
|
124
|
-
}
|
|
125
|
-
result[key] = out;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
case "additionalProperties":
|
|
129
|
-
case "additionalItems":
|
|
130
|
-
case "contains":
|
|
131
|
-
case "items": {
|
|
132
|
-
const value = b[key];
|
|
133
|
-
if (value === void 0) break;
|
|
134
|
-
result[key] = result[key] === void 0 ? value : intersection(result[key], value, options);
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
case "not": {
|
|
138
|
-
const value = b[key];
|
|
139
|
-
if (value === void 0) break;
|
|
140
|
-
if (result[key] && value) result.not = { anyOf: [result[key], value] };
|
|
141
|
-
else if (value) result.not = value;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
default: result[key] = b[key];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
function intersectArray(a, b) {
|
|
150
|
-
const out = /* @__PURE__ */ new Set();
|
|
151
|
-
for (const item of a) if (b.includes(item)) out.add(item);
|
|
152
|
-
for (const item of b) if (a.includes(item)) out.add(item);
|
|
153
|
-
return Array.from(out);
|
|
154
|
-
}
|
|
155
|
-
//#endregion
|
|
156
|
-
export { mergeAllOf };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "../is-plain-object.js";
|
|
2
|
-
import { decodeInternalRef } from "./ref.js";
|
|
3
|
-
import { resolveRefSync } from "./resolve-ref.js";
|
|
4
|
-
//#region src/utils/schema/pick.ts
|
|
5
|
-
/**
|
|
6
|
-
* return a filtered object that only contains the given `$ref` & its referenced fields.
|
|
7
|
-
*/
|
|
8
|
-
function pickSchema(root, $ref) {
|
|
9
|
-
const out = {};
|
|
10
|
-
const scanned = /* @__PURE__ */ new Set();
|
|
11
|
-
function scan(next) {
|
|
12
|
-
if (isPlainObject(next)) {
|
|
13
|
-
if (typeof next.$ref === "string") {
|
|
14
|
-
if (scanned.has(next.$ref)) return;
|
|
15
|
-
const resolved = resolveRefSync(next.$ref, root);
|
|
16
|
-
scanned.add(next.$ref);
|
|
17
|
-
scan(resolved);
|
|
18
|
-
setField(out, decodeInternalRef(next.$ref), resolved);
|
|
19
|
-
}
|
|
20
|
-
for (const k in next) scan(next[k]);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (Array.isArray(next)) for (const item of next) scan(item);
|
|
24
|
-
}
|
|
25
|
-
scan({ $ref });
|
|
26
|
-
return out;
|
|
27
|
-
}
|
|
28
|
-
function setField(obj, field, value) {
|
|
29
|
-
if (field.length === 0) return value;
|
|
30
|
-
const out = isPlainObject(obj) ? obj : {};
|
|
31
|
-
let current = out;
|
|
32
|
-
for (let i = 0; i < field.length; i++) {
|
|
33
|
-
const k = field[i];
|
|
34
|
-
if (i === field.length - 1) current[k] = value;
|
|
35
|
-
else {
|
|
36
|
-
const v = current[k];
|
|
37
|
-
if (isPlainObject(v)) current = v;
|
|
38
|
-
else current = current[k] = {};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
export { pickSchema };
|
package/dist/utils/schema/ref.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//#region src/utils/schema/ref.ts
|
|
2
|
-
/**
|
|
3
|
-
* RFC 6901 reference-token encoding for JSON Pointer fragments used in in-document `$ref` (`#/…`).
|
|
4
|
-
*
|
|
5
|
-
* @see https://datatracker.ietf.org/doc/html/rfc6901
|
|
6
|
-
*/
|
|
7
|
-
function encodeSegment(segment) {
|
|
8
|
-
return segment.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
9
|
-
}
|
|
10
|
-
function decodeSegment(segment) {
|
|
11
|
-
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Build an in-document `$ref` string from logical path segments (e.g. `['components','schemas','Pet']` → `#/components/schemas/Pet`).
|
|
15
|
-
*/
|
|
16
|
-
function encodeInternalRef(segments) {
|
|
17
|
-
if (segments.length === 0) return "#/";
|
|
18
|
-
return `#/${segments.map(encodeSegment).join("/")}`;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Parse an in-document `$ref` (`#/…`) into decoded path segments for walking the root document.
|
|
22
|
-
*/
|
|
23
|
-
function decodeInternalRef(ref) {
|
|
24
|
-
if (!ref.startsWith("#")) throw new Error("expected in-document $ref starting with `#`");
|
|
25
|
-
const raw = ref.slice(1);
|
|
26
|
-
const out = [];
|
|
27
|
-
if (raw.length === 0) return out;
|
|
28
|
-
for (const token of raw.split("/")) {
|
|
29
|
-
if (token.length === 0) continue;
|
|
30
|
-
out.push(decodeSegment(token));
|
|
31
|
-
}
|
|
32
|
-
return out;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { decodeInternalRef, encodeInternalRef };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "../is-plain-object.js";
|
|
2
|
-
import { decodeInternalRef } from "./ref.js";
|
|
3
|
-
//#region src/utils/schema/resolve-ref.ts
|
|
4
|
-
function resolveRefSync(ref, schema) {
|
|
5
|
-
let current = schema;
|
|
6
|
-
for (const seg of decodeInternalRef(ref)) if (isPlainObject(current)) current = current[seg];
|
|
7
|
-
else return;
|
|
8
|
-
return current;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { resolveRefSync };
|