openapi-typesafe 1.0.0-rc.3 → 1.0.0-rc.5
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/CHANGELOG.md +1972 -0
- package/dist/adapters/node-file-system/file-claims.cjs +105 -0
- package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-claims.mjs +95 -0
- package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.cjs +82 -0
- package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.mjs +74 -0
- package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +97 -14
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
- package/dist/adapters/node-file-system/node-file-system.mjs +97 -14
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +48 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +45 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
- package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
- package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
- package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
- package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +40 -29
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +38 -27
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.mjs +53 -12
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
- package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.cjs +61 -0
- package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs +58 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.cjs +18 -9
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.mjs +20 -11
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +10 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +10 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/api/default-ports.cjs +14 -2
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +14 -2
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-enum-parent.cjs +2 -2
- package/dist/api/discriminator-enum-parent.cjs.map +1 -1
- package/dist/api/discriminator-enum-parent.mjs +3 -3
- package/dist/api/discriminator-enum-parent.mjs.map +1 -1
- package/dist/api/discriminator-other-owners.cjs +5 -3
- package/dist/api/discriminator-other-owners.cjs.map +1 -1
- package/dist/api/discriminator-other-owners.mjs +5 -3
- package/dist/api/discriminator-other-owners.mjs.map +1 -1
- package/dist/api/discriminator-patch.cjs +5 -1
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +5 -1
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +15 -8
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +15 -8
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-refs.cjs +16 -1
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +16 -1
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +6 -12
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +6 -12
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +9 -6
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +10 -8
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/ref-limit-options.cjs +63 -0
- package/dist/api/ref-limit-options.cjs.map +1 -0
- package/dist/api/ref-limit-options.mjs +57 -0
- package/dist/api/ref-limit-options.mjs.map +1 -0
- package/dist/api/schema-callbacks.cjs +36 -12
- package/dist/api/schema-callbacks.cjs.map +1 -1
- package/dist/api/schema-callbacks.mjs +36 -12
- package/dist/api/schema-callbacks.mjs.map +1 -1
- package/dist/api/transform-context.cjs +7 -3
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +7 -3
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +47 -10
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +48 -11
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/application/print/text-writer.cjs +10 -3
- package/dist/application/print/text-writer.cjs.map +1 -1
- package/dist/application/print/text-writer.mjs +10 -3
- package/dist/application/print/text-writer.mjs.map +1 -1
- package/dist/application/stack-overflow.cjs +2 -1
- package/dist/application/stack-overflow.cjs.map +1 -1
- package/dist/application/stack-overflow.mjs +2 -1
- package/dist/application/stack-overflow.mjs.map +1 -1
- package/dist/application/transform/declared-value-types.cjs +36 -0
- package/dist/application/transform/declared-value-types.cjs.map +1 -0
- package/dist/application/transform/declared-value-types.mjs +34 -0
- package/dist/application/transform/declared-value-types.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +1 -1
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +2 -2
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/declared-type-names.cjs +23 -0
- package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
- package/dist/application/transform/document/declared-type-names.mjs +20 -0
- package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
- package/dist/application/transform/document/defs-root.cjs +1 -1
- package/dist/application/transform/document/defs-root.cjs.map +1 -1
- package/dist/application/transform/document/defs-root.mjs +2 -2
- package/dist/application/transform/document/defs-root.mjs.map +1 -1
- package/dist/application/transform/document/document.cjs +7 -2
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +6 -3
- package/dist/application/transform/document/document.mjs.map +1 -1
- package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
- package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
- package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
- package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
- package/dist/application/transform/document/exploded-query-values.cjs +63 -0
- package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
- package/dist/application/transform/document/exploded-query-values.mjs +59 -0
- package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
- package/dist/application/transform/document/global-type-references.cjs +1 -0
- package/dist/application/transform/document/global-type-references.cjs.map +1 -1
- package/dist/application/transform/document/global-type-references.mjs +1 -1
- package/dist/application/transform/document/global-type-references.mjs.map +1 -1
- package/dist/application/transform/document/header.cjs +11 -3
- package/dist/application/transform/document/header.cjs.map +1 -1
- package/dist/application/transform/document/header.mjs +10 -2
- package/dist/application/transform/document/header.mjs.map +1 -1
- package/dist/application/transform/document/media-type.cjs +2 -2
- package/dist/application/transform/document/media-type.cjs.map +1 -1
- package/dist/application/transform/document/media-type.mjs +3 -3
- package/dist/application/transform/document/media-type.mjs.map +1 -1
- package/dist/application/transform/document/operation-keys-written.cjs +26 -0
- package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
- package/dist/application/transform/document/operation-keys-written.mjs +24 -0
- package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
- package/dist/application/transform/document/operation.cjs +1 -1
- package/dist/application/transform/document/operation.cjs.map +1 -1
- package/dist/application/transform/document/operation.mjs +2 -2
- package/dist/application/transform/document/operation.mjs.map +1 -1
- package/dist/application/transform/document/parameter-entries.cjs +34 -0
- package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
- package/dist/application/transform/document/parameter-entries.mjs +30 -0
- package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
- package/dist/application/transform/document/parameter.cjs +12 -4
- package/dist/application/transform/document/parameter.cjs.map +1 -1
- package/dist/application/transform/document/parameter.mjs +13 -5
- package/dist/application/transform/document/parameter.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +29 -34
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +29 -34
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-item.cjs +15 -17
- package/dist/application/transform/document/path-item.cjs.map +1 -1
- package/dist/application/transform/document/path-item.mjs +15 -19
- package/dist/application/transform/document/path-item.mjs.map +1 -1
- package/dist/application/transform/document/path-template-key.cjs +84 -0
- package/dist/application/transform/document/path-template-key.cjs.map +1 -0
- package/dist/application/transform/document/path-template-key.mjs +79 -0
- package/dist/application/transform/document/path-template-key.mjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.cjs +70 -0
- package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.mjs +67 -0
- package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
- package/dist/application/transform/document/paths-enum.cjs +8 -6
- package/dist/application/transform/document/paths-enum.cjs.map +1 -1
- package/dist/application/transform/document/paths-enum.mjs +8 -7
- package/dist/application/transform/document/paths-enum.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +43 -67
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +42 -68
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/document/referenced-parameter.cjs +80 -0
- package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
- package/dist/application/transform/document/referenced-parameter.mjs +78 -0
- package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
- package/dist/application/transform/document/request-body.cjs +1 -1
- package/dist/application/transform/document/request-body.cjs.map +1 -1
- package/dist/application/transform/document/request-body.mjs +2 -2
- package/dist/application/transform/document/request-body.mjs.map +1 -1
- package/dist/application/transform/document/response.cjs +2 -2
- package/dist/application/transform/document/response.cjs.map +1 -1
- package/dist/application/transform/document/response.mjs +3 -3
- package/dist/application/transform/document/response.mjs.map +1 -1
- package/dist/application/transform/document/responses.cjs +1 -1
- package/dist/application/transform/document/responses.cjs.map +1 -1
- package/dist/application/transform/document/responses.mjs +2 -2
- package/dist/application/transform/document/responses.mjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.cjs +8 -23
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.mjs +8 -24
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
- package/dist/application/transform/document/type-resolution.cjs +3 -1
- package/dist/application/transform/document/type-resolution.cjs.map +1 -1
- package/dist/application/transform/document/type-resolution.mjs +3 -1
- package/dist/application/transform/document/type-resolution.mjs.map +1 -1
- package/dist/application/transform/document/webhooks.cjs +10 -3
- package/dist/application/transform/document/webhooks.cjs.map +1 -1
- package/dist/application/transform/document/webhooks.mjs +10 -3
- package/dist/application/transform/document/webhooks.mjs.map +1 -1
- package/dist/application/transform/footer/document-footer.cjs +16 -5
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +16 -5
- package/dist/application/transform/footer/document-footer.mjs.map +1 -1
- package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
- package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
- package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
- package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.cjs +23 -0
- package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.mjs +21 -0
- package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.cjs +4 -4
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.mjs +4 -4
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
- package/dist/application/transform/helper-types.cjs +3 -3
- package/dist/application/transform/helper-types.cjs.map +1 -1
- package/dist/application/transform/helper-types.mjs +3 -3
- package/dist/application/transform/helper-types.mjs.map +1 -1
- package/dist/application/transform/numbered-names.cjs +9 -0
- package/dist/application/transform/numbered-names.cjs.map +1 -1
- package/dist/application/transform/numbered-names.mjs +9 -1
- package/dist/application/transform/numbered-names.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.cjs +5 -5
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.mjs +3 -3
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
- package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
- package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
- package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
- package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
- package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
- package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
- package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
- package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
- package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
- package/dist/application/transform/ref-type.cjs +2 -1
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +2 -1
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +1 -1
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +2 -2
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +1 -1
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +2 -2
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/index-signature-type.cjs +21 -0
- package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
- package/dist/application/transform/schema/index-signature-type.mjs +19 -0
- package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
- package/dist/application/transform/schema/input-location.cjs +23 -0
- package/dist/application/transform/schema/input-location.cjs.map +1 -0
- package/dist/application/transform/schema/input-location.mjs +21 -0
- package/dist/application/transform/schema/input-location.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +18 -8
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +19 -9
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/ref-siblings.cjs +47 -0
- package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
- package/dist/application/transform/schema/ref-siblings.mjs +45 -0
- package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +6 -3
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +6 -3
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +5 -1
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +5 -1
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/cli/api-logger.cjs +13 -0
- package/dist/cli/api-logger.cjs.map +1 -0
- package/dist/cli/api-logger.mjs +11 -0
- package/dist/cli/api-logger.mjs.map +1 -0
- package/dist/cli/api-settings.cjs +57 -9
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +56 -11
- package/dist/cli/api-settings.mjs.map +1 -1
- package/dist/cli/api-writes.cjs +72 -0
- package/dist/cli/api-writes.cjs.map +1 -0
- package/dist/cli/api-writes.mjs +69 -0
- package/dist/cli/api-writes.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +51 -11
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +51 -11
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +29 -1
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +29 -2
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +111 -4
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +104 -5
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +13 -3
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +14 -4
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +94 -37
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +99 -42
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/ref-limits.cjs +15 -1
- package/dist/cli/ref-limits.cjs.map +1 -1
- package/dist/cli/ref-limits.mjs +15 -2
- package/dist/cli/ref-limits.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +37 -14
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +39 -16
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/append-all.cjs +10 -0
- package/dist/domain/append-all.cjs.map +1 -0
- package/dist/domain/append-all.mjs +8 -0
- package/dist/domain/append-all.mjs.map +1 -0
- package/dist/domain/cause-secrets.cjs +52 -0
- package/dist/domain/cause-secrets.cjs.map +1 -0
- package/dist/domain/cause-secrets.mjs +50 -0
- package/dist/domain/cause-secrets.mjs.map +1 -0
- package/dist/domain/errors.cjs +11 -3
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +11 -3
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/identifier-text.cjs.map +1 -1
- package/dist/domain/ir/identifier-text.mjs +1 -1
- package/dist/domain/ir/identifier-text.mjs.map +1 -1
- package/dist/domain/ir/ir-shape.cjs +187 -0
- package/dist/domain/ir/ir-shape.cjs.map +1 -0
- package/dist/domain/ir/ir-shape.mjs +184 -0
- package/dist/domain/ir/ir-shape.mjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
- package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
- package/dist/domain/location-text.cjs +9 -0
- package/dist/domain/location-text.cjs.map +1 -0
- package/dist/domain/location-text.mjs +7 -0
- package/dist/domain/location-text.mjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.cjs +3 -1
- package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
- package/dist/domain/openapi/alias-expansion.mjs +3 -1
- package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.cjs +3 -3
- package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.mjs +4 -4
- package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
- package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
- package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
- package/dist/domain/openapi/document-places.cjs +55 -0
- package/dist/domain/openapi/document-places.cjs.map +1 -0
- package/dist/domain/openapi/document-places.mjs +53 -0
- package/dist/domain/openapi/document-places.mjs.map +1 -0
- package/dist/domain/openapi/json-pointer.cjs +43 -1
- package/dist/domain/openapi/json-pointer.cjs.map +1 -1
- package/dist/domain/openapi/json-pointer.mjs +40 -2
- package/dist/domain/openapi/json-pointer.mjs.map +1 -1
- package/dist/domain/openapi/schema-dialect.cjs +15 -0
- package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
- package/dist/domain/openapi/schema-dialect.mjs +12 -0
- package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.cjs +1 -1
- package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
- package/dist/domain/openapi/unsupported-features.mjs +2 -2
- package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
- package/dist/domain/output-fixes.cjs +20 -0
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +20 -0
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/terminal-text.cjs +31 -0
- package/dist/domain/terminal-text.cjs.map +1 -0
- package/dist/domain/terminal-text.mjs +29 -0
- package/dist/domain/terminal-text.mjs.map +1 -0
- package/dist/domain/url-secrets.cjs +48 -0
- package/dist/domain/url-secrets.cjs.map +1 -0
- package/dist/domain/url-secrets.mjs +45 -0
- package/dist/domain/url-secrets.mjs.map +1 -0
- package/dist/domain/warnings.cjs +1 -0
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +1 -0
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.d.cts +46 -20
- package/dist/index.d.mts +46 -20
- package/dist/index.d.ts +46 -20
- package/package.json +4 -5
- package/src/adapters/node-file-system/file-claims.ts +138 -0
- package/src/adapters/node-file-system/file-identity.ts +137 -0
- package/src/adapters/node-file-system/node-file-system.ts +158 -18
- package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
- package/src/adapters/redocly-loader/bundled-mapping-copies.ts +60 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
- package/src/adapters/redocly-loader/component-schemas.ts +19 -0
- package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
- package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
- package/src/adapters/redocly-loader/query-named-components.ts +201 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +64 -38
- package/src/adapters/redocly-loader/ref-access.ts +51 -4
- package/src/adapters/redocly-loader/ref-holders.ts +76 -15
- package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +85 -13
- package/src/adapters/redocly-loader/remote-node-limit.ts +102 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
- package/src/adapters/redocly-loader/schema-source.ts +35 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
- package/src/adapters/terminal-logger/terminal-logger.ts +17 -6
- package/src/api/default-ports.ts +33 -4
- package/src/api/discriminator-enum-parent.ts +3 -3
- package/src/api/discriminator-other-owners.ts +5 -3
- package/src/api/discriminator-patch.ts +5 -1
- package/src/api/discriminator-scan.ts +16 -8
- package/src/api/document-refs.ts +29 -1
- package/src/api/document-run.ts +10 -19
- package/src/api/legacy-utils.ts +5 -1
- package/src/api/openapi-ts.ts +26 -8
- package/src/api/ref-limit-options.ts +76 -0
- package/src/api/run-context.ts +3 -0
- package/src/api/schema-callbacks.ts +60 -17
- package/src/api/transform-context.ts +7 -3
- package/src/api/transform-schema.ts +79 -12
- package/src/application/ports/file-system.ts +47 -0
- package/src/application/ports/schema-loader.ts +11 -1
- package/src/application/print/text-writer.ts +10 -3
- package/src/application/stack-overflow.ts +9 -5
- package/src/application/transform/declared-value-types.ts +42 -0
- package/src/application/transform/document/components.ts +2 -2
- package/src/application/transform/document/declared-type-names.ts +36 -0
- package/src/application/transform/document/defs-root.ts +2 -2
- package/src/application/transform/document/document.ts +8 -5
- package/src/application/transform/document/enum-names-given-back.ts +91 -0
- package/src/application/transform/document/exploded-query-values.ts +88 -0
- package/src/application/transform/document/global-type-references.ts +1 -1
- package/src/application/transform/document/header.ts +25 -5
- package/src/application/transform/document/media-type.ts +4 -3
- package/src/application/transform/document/operation-keys-written.ts +27 -0
- package/src/application/transform/document/operation.ts +2 -2
- package/src/application/transform/document/parameter-entries.ts +70 -0
- package/src/application/transform/document/parameter.ts +21 -9
- package/src/application/transform/document/parameters.ts +56 -66
- package/src/application/transform/document/path-item.ts +16 -34
- package/src/application/transform/document/path-template-key.ts +152 -0
- package/src/application/transform/document/path-template-refs.ts +106 -0
- package/src/application/transform/document/paths-enum.ts +24 -10
- package/src/application/transform/document/paths.ts +59 -125
- package/src/application/transform/document/referenced-parameter.ts +146 -0
- package/src/application/transform/document/request-body.ts +2 -2
- package/src/application/transform/document/response.ts +3 -3
- package/src/application/transform/document/responses.ts +2 -2
- package/src/application/transform/document/root-type-aliases.ts +17 -38
- package/src/application/transform/document/type-resolution.ts +2 -1
- package/src/application/transform/document/webhooks.ts +19 -6
- package/src/application/transform/footer/document-footer.ts +36 -9
- package/src/application/transform/footer/enum-name-claims.ts +62 -0
- package/src/application/transform/footer/operation-keys.ts +28 -0
- package/src/application/transform/footer/type-evaluation.ts +4 -4
- package/src/application/transform/helper-types.ts +8 -7
- package/src/application/transform/numbered-names.ts +15 -0
- package/src/application/transform/ref-pointer/generated-location.ts +3 -3
- package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
- package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
- package/src/application/transform/ref-pointer/located-node.ts +38 -0
- package/src/application/transform/ref-pointer/original-index.ts +100 -17
- package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
- package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
- package/src/application/transform/ref-pointer/property-shape.ts +97 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
- package/src/application/transform/ref-type.ts +2 -1
- package/src/application/transform/schema/access-flags.ts +5 -2
- package/src/application/transform/schema/composition-type.ts +2 -2
- package/src/application/transform/schema/enum-rule.ts +6 -2
- package/src/application/transform/schema/index-signature-type.ts +31 -0
- package/src/application/transform/schema/input-location.ts +35 -0
- package/src/application/transform/schema/object-type.ts +22 -12
- package/src/application/transform/schema/ref-siblings.ts +76 -0
- package/src/application/transform/schema/schema-context.ts +3 -0
- package/src/application/transform/schema/schema-transform.ts +6 -3
- package/src/application/transform/schema/unevaluated-properties.ts +4 -44
- package/src/application/transform/schema-comment.ts +5 -1
- package/src/application/transform/transform-context.ts +5 -0
- package/src/cli/api-logger.ts +17 -0
- package/src/cli/api-settings.ts +80 -13
- package/src/cli/api-writes.ts +117 -0
- package/src/cli/cli-arguments.ts +90 -14
- package/src/cli/cli-dependencies.ts +26 -4
- package/src/cli/cli-errors.ts +42 -1
- package/src/cli/cli-output.ts +195 -15
- package/src/cli/main.ts +14 -5
- package/src/cli/redocly-apis.ts +177 -52
- package/src/cli/ref-limits.ts +21 -2
- package/src/cli/run-cli.ts +76 -15
- package/src/domain/append-all.ts +10 -0
- package/src/domain/cause-secrets.ts +86 -0
- package/src/domain/errors.ts +16 -5
- package/src/domain/ir/identifier-text.ts +6 -5
- package/src/domain/ir/ir-shape.ts +299 -0
- package/src/domain/ir/newer-identifier-ranges.ts +183 -30
- package/src/domain/location-text.ts +12 -0
- package/src/domain/openapi/alias-expansion.ts +4 -1
- package/src/domain/openapi/discriminated-union.ts +6 -4
- package/src/domain/openapi/discriminator-conflicts.ts +21 -7
- package/src/domain/openapi/document-object.ts +2 -0
- package/src/domain/openapi/document-places.ts +78 -0
- package/src/domain/openapi/json-pointer.ts +96 -7
- package/src/domain/openapi/schema-dialect.ts +22 -0
- package/src/domain/openapi/unsupported-features.ts +2 -2
- package/src/domain/output-fixes.ts +28 -2
- package/src/domain/terminal-text.ts +44 -0
- package/src/domain/url-secrets.ts +72 -0
- package/src/domain/warnings.ts +1 -0
- package/src/types/generator-options.ts +1 -1
- package/dist/cli/main.d.cts +0 -2
- package/dist/cli/main.d.mts +0 -2
- package/dist/cli/main.d.ts +0 -2
- package/dist/domain/url-credentials.cjs +0 -10
- package/dist/domain/url-credentials.cjs.map +0 -1
- package/dist/domain/url-credentials.mjs +0 -8
- package/dist/domain/url-credentials.mjs.map +0 -1
- package/src/domain/url-credentials.ts +0 -18
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import colors from "ansi-colors";
|
|
2
2
|
import type { DebugGroup, Logger } from "../../application/ports/logger.js";
|
|
3
|
-
import {
|
|
3
|
+
import { terminalSafeText } from "../../domain/terminal-text.js";
|
|
4
|
+
import { redactUrlSecrets } from "../../domain/url-secrets.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The Logger port on a terminal, with the original output format: ` ⚠ ` warnings, ` ✘ `
|
|
7
8
|
* errors, and `openapi-ts:<group>` debug lines filtered by `DEBUG` (ENGINEERING_PLAN 4.5). No
|
|
8
|
-
* line shows the
|
|
9
|
+
* line shows the secrets of a URL, and each message prints as one line: a message quotes the
|
|
10
|
+
* document, whose control characters could forge CI commands (terminal-text.ts).
|
|
9
11
|
*/
|
|
10
12
|
|
|
13
|
+
function shownText(message: string): string {
|
|
14
|
+
return terminalSafeText(redactUrlSecrets(message));
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
/** Where the lines go: `console` in production, a recording sink in tests. */
|
|
12
18
|
export interface TerminalSink {
|
|
13
19
|
debug(line: string): void;
|
|
@@ -16,7 +22,10 @@ export interface TerminalSink {
|
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export interface TerminalLoggerOptions {
|
|
19
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Drop warnings and error lines; debug lines, which `DEBUG` asks for, are still written. The
|
|
27
|
+
* error lines are the problems of a document that fails to load, which the thrown error lists.
|
|
28
|
+
*/
|
|
20
29
|
readonly silent: boolean;
|
|
21
30
|
/** The value of `DEBUG`: `*`, `openapi-ts:*` or `openapi-ts:<group>` turn debug lines on. */
|
|
22
31
|
readonly debugFilter: string | undefined;
|
|
@@ -81,18 +90,20 @@ class TerminalLogger implements Logger {
|
|
|
81
90
|
// The original wrote no space without a duration (`openapi-ts:lintIgnored …`).
|
|
82
91
|
const time =
|
|
83
92
|
durationMs === undefined ? " " : this.#palette.green(` ${formatDuration(durationMs)} `);
|
|
84
|
-
const text =
|
|
93
|
+
const text = shownText(message);
|
|
85
94
|
this.#options.sink.debug(` ${this.#palette.bold(name)}${time}${text}`);
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
warn(message: string): void {
|
|
89
98
|
if (!this.#options.silent) {
|
|
90
|
-
this.#options.sink.warn(this.#palette.yellow(` ⚠ ${
|
|
99
|
+
this.#options.sink.warn(this.#palette.yellow(` ⚠ ${shownText(message)}`));
|
|
91
100
|
}
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
error(message: string): void {
|
|
95
|
-
this.#options.
|
|
104
|
+
if (!this.#options.silent) {
|
|
105
|
+
this.#options.sink.error(this.#palette.red(` ✘ ${shownText(message)}`));
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
|
package/src/api/default-ports.ts
CHANGED
|
@@ -3,7 +3,10 @@ import { createConfig, type Config as RedoclyConfig } from "@redocly/openapi-cor
|
|
|
3
3
|
import supportsColor from "supports-color";
|
|
4
4
|
import { createNodeDeprecationReporter } from "../adapters/node-deprecations/node-deprecations.js";
|
|
5
5
|
import type { RemoteDocumentLimits } from "../adapters/redocly-loader/remote-fetch.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
createTerminalLogger,
|
|
8
|
+
type TerminalSink,
|
|
9
|
+
} from "../adapters/terminal-logger/terminal-logger.js";
|
|
7
10
|
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
8
11
|
import type { Logger } from "../application/ports/logger.js";
|
|
9
12
|
|
|
@@ -18,13 +21,26 @@ export function terminalSupportsColor(): boolean {
|
|
|
18
21
|
return Boolean(stdout) && stdout !== false && stdout.hasBasic !== false;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Every line of the logger goes to stderr: the CLI writes the types to stdout, and `console.debug`
|
|
26
|
+
* writes there too, so debug lines would end up inside the generated file.
|
|
27
|
+
*/
|
|
28
|
+
const STDERR_SINK: TerminalSink = {
|
|
29
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
30
|
+
debug: (line) => console.error(line),
|
|
31
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
32
|
+
warn: (line) => console.warn(line),
|
|
33
|
+
// biome-ignore lint/suspicious/noConsole: the terminal logger's own channel
|
|
34
|
+
error: (line) => console.error(line),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** The terminal logger with `DEBUG` from the environment, writing to stderr. */
|
|
22
38
|
export function defaultLogger(silent: boolean): Logger {
|
|
23
39
|
return createTerminalLogger({
|
|
24
40
|
silent,
|
|
25
41
|
debugFilter: process.env.DEBUG,
|
|
26
42
|
useColors: terminalSupportsColor(),
|
|
27
|
-
sink:
|
|
43
|
+
sink: STDERR_SINK,
|
|
28
44
|
});
|
|
29
45
|
}
|
|
30
46
|
|
|
@@ -40,14 +56,27 @@ export function defaultDeprecationReporter(): DeprecationReporter {
|
|
|
40
56
|
*/
|
|
41
57
|
export const REMOTE_REF_TIMEOUT_MS = 60_000;
|
|
42
58
|
|
|
59
|
+
const MEBIBYTE = 1024 * 1024;
|
|
60
|
+
|
|
43
61
|
/**
|
|
44
|
-
* Bounds on the remote documents of one
|
|
62
|
+
* Bounds on the remote documents of one schema (ADR-033). Large split documents have a few thousand
|
|
45
63
|
* files, so 10,000 leaves room and still ends an endless fan-out. 16 parallel fetches keep a
|
|
46
64
|
* multi-file document fast without exhausting local ports.
|
|
65
|
+
*
|
|
66
|
+
* The size limits count decoded bytes and parsed nodes (threat model T2, ADR-033 decision 6).
|
|
67
|
+
* The largest document of the 1,820-entry compatibility corpus is Microsoft Graph beta: 71 MiB,
|
|
68
|
+
* 2.65 million nodes (keys and values), 1.6 GB peak memory when loaded from a URL. A remote body
|
|
69
|
+
* took about 7 bytes of memory per byte of text and 110 per node in our measurements, so 128 MiB
|
|
70
|
+
* per document (1.8 times Graph beta), 256 MiB per schema (a split document may be twice as
|
|
71
|
+
* large) and 8 million nodes per schema (3 times Graph beta) let crafted documents finish within
|
|
72
|
+
* a heap of 2 GB; with the default heap of 4 GB they peak at about 1.2 to 2.3 GB.
|
|
47
73
|
*/
|
|
48
74
|
export const DEFAULT_REMOTE_DOCUMENT_LIMITS: RemoteDocumentLimits = {
|
|
49
75
|
maxDocuments: 10_000,
|
|
50
76
|
maxParallelFetches: 16,
|
|
77
|
+
maxDocumentBytes: 128 * MEBIBYTE,
|
|
78
|
+
maxTotalBytes: 256 * MEBIBYTE,
|
|
79
|
+
maxNodes: 8_000_000,
|
|
51
80
|
};
|
|
52
81
|
|
|
53
82
|
/** The working directory of the process: the default `cwd` of an inline source. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { appendPointer, parseRefPointer, ROOT_POINTER } from "../domain/openapi/json-pointer.js";
|
|
2
2
|
import type { SchemaObject } from "../types.js";
|
|
3
3
|
import type { EnumPatch } from "./discriminator-enum.js";
|
|
4
4
|
|
|
@@ -31,7 +31,7 @@ const ROOT_SEGMENTS = 3;
|
|
|
31
31
|
function typedAt(ref: string): string {
|
|
32
32
|
const segments = parseRefPointer(ref);
|
|
33
33
|
const nested = segments.slice(ROOT_SEGMENTS).filter((segment) => segment !== PROPERTIES_KEYWORD);
|
|
34
|
-
return
|
|
34
|
+
return appendPointer(ROOT_POINTER, [...segments.slice(0, ROOT_SEGMENTS), ...nested]);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function isSchemaObject(value: unknown): value is SchemaObject {
|
|
@@ -41,7 +41,7 @@ function isSchemaObject(value: unknown): value is SchemaObject {
|
|
|
41
41
|
/** The property `name` of a schema object typed at `ref`. */
|
|
42
42
|
function ownProperty(item: SchemaObject, ref: string, name: string): DeclaredProperty | undefined {
|
|
43
43
|
const property = ("properties" in item ? item.properties : undefined)?.[name];
|
|
44
|
-
return property === undefined ? undefined : { property, path:
|
|
44
|
+
return property === undefined ? undefined : { property, path: appendPointer(ref, [name]) };
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/** The property `name` of the schema at `ref`, its own or from an `allOf` item, depth first. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { appendAll } from "../domain/append-all.js";
|
|
2
|
+
import { canonicalRef } from "../domain/openapi/json-pointer.js";
|
|
1
3
|
import type { DiscriminatorObject, ReferenceObject, SchemaObject } from "../types.js";
|
|
2
4
|
import type { EnumPatch } from "./discriminator-enum.js";
|
|
3
5
|
import { enumKey, patchDiscriminatorEnum, type ScanState } from "./discriminator-patch.js";
|
|
@@ -22,7 +24,7 @@ function allOfRefs(state: ScanState, ref: string): string[] {
|
|
|
22
24
|
const schema = resolveDocumentRef<SchemaObject>(state.schema, ref, { silent, logger });
|
|
23
25
|
const items = (schema?.allOf ?? []) as (SchemaObject | ReferenceObject)[];
|
|
24
26
|
return items.flatMap((item) =>
|
|
25
|
-
"$ref" in item && typeof item.$ref === "string" ? [item.$ref] : [],
|
|
27
|
+
"$ref" in item && typeof item.$ref === "string" ? [canonicalRef(item.$ref)] : [],
|
|
26
28
|
);
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -45,7 +47,7 @@ function otherOwners(state: ScanState, parentRef: string): OtherOwner[] {
|
|
|
45
47
|
if (discriminator && name !== undefined && name !== own && !found.has(name)) {
|
|
46
48
|
found.set(name, { discriminator, ownerRef: ref });
|
|
47
49
|
}
|
|
48
|
-
queue
|
|
50
|
+
appendAll(queue, allOfRefs(state, ref));
|
|
49
51
|
}
|
|
50
52
|
return [...found.values()];
|
|
51
53
|
}
|
|
@@ -75,7 +77,7 @@ export function inheritOtherOwners(state: ScanState, parentRef: string, ref: str
|
|
|
75
77
|
}
|
|
76
78
|
recordOtherProperty(state, ref, discriminator.propertyName);
|
|
77
79
|
const mapped = Object.entries(discriminator.mapping ?? {})
|
|
78
|
-
.filter(([, target]) => target === ref)
|
|
80
|
+
.filter(([, target]) => canonicalRef(target) === ref)
|
|
79
81
|
.map(([value]) => value);
|
|
80
82
|
const name = ref.slice(ref.lastIndexOf("/") + 1);
|
|
81
83
|
const patch: EnumPatch = { ref, values: mapped, discriminator, discriminatorRef: ownerRef };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from "../application/ports/logger.js";
|
|
2
|
+
import { appendAll } from "../domain/append-all.js";
|
|
2
3
|
import { FIX, type OutputFix } from "../domain/output-fixes.js";
|
|
3
4
|
import { WARNING_CODES, warningText } from "../domain/warnings.js";
|
|
4
5
|
import type { DiscriminatorObject, OpenAPI3, SchemaObject } from "../types.js";
|
|
@@ -104,7 +105,10 @@ function mergeIntoPatchedEnum(state: ScanState, key: string, values: readonly st
|
|
|
104
105
|
return false;
|
|
105
106
|
}
|
|
106
107
|
const merged = patched.enum as unknown[];
|
|
107
|
-
|
|
108
|
+
appendAll(
|
|
109
|
+
merged,
|
|
110
|
+
values.filter((value) => !merged.includes(value)),
|
|
111
|
+
);
|
|
108
112
|
return true;
|
|
109
113
|
}
|
|
110
114
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Logger } from "../application/ports/logger.js";
|
|
2
2
|
import { isUnionMember, unionAt } from "../domain/openapi/discriminated-union.js";
|
|
3
|
+
import { appendPointer, canonicalRef, ROOT_POINTER } from "../domain/openapi/json-pointer.js";
|
|
3
4
|
import { FIX } from "../domain/output-fixes.js";
|
|
4
5
|
import type {
|
|
5
6
|
DiscriminatorObject,
|
|
@@ -22,7 +23,6 @@ import {
|
|
|
22
23
|
type ScanState,
|
|
23
24
|
} from "./discriminator-patch.js";
|
|
24
25
|
import { resolveDocumentRef, walkDocument } from "./document-refs.js";
|
|
25
|
-
import { createRef } from "./legacy-utils.js";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* The inherited discriminator pre-pass. It finds every discriminator in the bundled document and
|
|
@@ -39,9 +39,11 @@ function inferredMapping(oneOf: (SchemaObject | ReferenceObject)[]): Discriminat
|
|
|
39
39
|
if (!("$ref" in item)) {
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
+
// The value is the name as the `$ref` writes it, as in the original.
|
|
42
43
|
const value = item.$ref.split("/").pop();
|
|
44
|
+
const ref = canonicalRef(item.$ref);
|
|
43
45
|
if (value) {
|
|
44
|
-
mapping[
|
|
46
|
+
mapping[ref] = { ...mapping[ref], inferred: value };
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
return mapping;
|
|
@@ -52,10 +54,11 @@ function addDefinedMapping(
|
|
|
52
54
|
mapping: DiscriminatorMapping,
|
|
53
55
|
defined: Readonly<Record<string, string>>,
|
|
54
56
|
): void {
|
|
55
|
-
for (const [mappedValue,
|
|
56
|
-
if (!
|
|
57
|
+
for (const [mappedValue, target] of Object.entries(defined)) {
|
|
58
|
+
if (!target) {
|
|
57
59
|
continue;
|
|
58
60
|
}
|
|
61
|
+
const mappedRef = canonicalRef(target);
|
|
59
62
|
if (!mapping[mappedRef]?.defined) {
|
|
60
63
|
mapping[mappedRef] = { defined: [] };
|
|
61
64
|
}
|
|
@@ -94,7 +97,7 @@ function collectDiscriminator(
|
|
|
94
97
|
if (!discriminator?.propertyName) {
|
|
95
98
|
return;
|
|
96
99
|
}
|
|
97
|
-
const discriminatorRef =
|
|
100
|
+
const discriminatorRef = appendPointer(ROOT_POINTER, path);
|
|
98
101
|
state.objects[discriminatorRef] = discriminator;
|
|
99
102
|
state.owners.add(discriminatorRef);
|
|
100
103
|
if (!Array.isArray(value.oneOf)) {
|
|
@@ -110,7 +113,7 @@ function collectDiscriminator(
|
|
|
110
113
|
/** The mapping keys of `discriminator` that point at `ref`. */
|
|
111
114
|
function valuesMappedTo(discriminator: DiscriminatorObject, ref: string): string[] {
|
|
112
115
|
return Object.entries(discriminator.mapping ?? {})
|
|
113
|
-
.filter(([, mappedRef]) => mappedRef === ref)
|
|
116
|
+
.filter(([, mappedRef]) => canonicalRef(mappedRef) === ref)
|
|
114
117
|
.map(([mappedValue]) => mappedValue);
|
|
115
118
|
}
|
|
116
119
|
|
|
@@ -184,12 +187,17 @@ function inheritDiscriminators(
|
|
|
184
187
|
}
|
|
185
188
|
for (const item of value.allOf as (SchemaObject | ReferenceObject)[]) {
|
|
186
189
|
if ("$ref" in item) {
|
|
187
|
-
if (!inheritFromRef(state, item.$ref,
|
|
190
|
+
if (!inheritFromRef(state, canonicalRef(item.$ref), appendPointer(ROOT_POINTER, path))) {
|
|
188
191
|
return;
|
|
189
192
|
}
|
|
190
193
|
} else if (item.discriminator?.propertyName) {
|
|
191
194
|
// The inline item is typed at the schema's own location.
|
|
192
|
-
recordInherited(
|
|
195
|
+
recordInherited(
|
|
196
|
+
state,
|
|
197
|
+
appendPointer(ROOT_POINTER, path),
|
|
198
|
+
item.discriminator,
|
|
199
|
+
appendPointer(ROOT_POINTER, path),
|
|
200
|
+
);
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
}
|
package/src/api/document-refs.ts
CHANGED
|
@@ -16,6 +16,34 @@ function isObject(value: unknown): value is Record<string, unknown> {
|
|
|
16
16
|
return typeof value === "object" && value !== null;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The child of a node under a pointer key. A pointer may pass through a `$ref`
|
|
21
|
+
* (`#/components/schemas/Wrap/properties/o/properties/v`, where `o` is a `$ref`): a key the node
|
|
22
|
+
* does not have is read from the node's target, as the generated types index it (ADR-026). A key
|
|
23
|
+
* the node has is read from it, so a pointer to a sibling of a `$ref` (OpenAPI 3.1) stays as
|
|
24
|
+
* written.
|
|
25
|
+
*/
|
|
26
|
+
function childOf(
|
|
27
|
+
schema: unknown,
|
|
28
|
+
node: unknown,
|
|
29
|
+
key: string,
|
|
30
|
+
options: ResolveRefOptions & { logger: Logger },
|
|
31
|
+
): unknown {
|
|
32
|
+
if (!isObject(node)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const { visited = [] } = options;
|
|
36
|
+
const target = node.$ref;
|
|
37
|
+
if (node[key] || typeof target !== "string" || visited.includes(target)) {
|
|
38
|
+
return node[key];
|
|
39
|
+
}
|
|
40
|
+
const resolved = resolveDocumentRef(schema, target, {
|
|
41
|
+
...options,
|
|
42
|
+
visited: [...visited, target],
|
|
43
|
+
});
|
|
44
|
+
return isObject(resolved) ? resolved[key] : undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
19
47
|
/** Resolve a `$ref` in a document; warns and returns undefined when it cannot. */
|
|
20
48
|
export function resolveDocumentRef<T>(
|
|
21
49
|
schema: unknown,
|
|
@@ -30,7 +58,7 @@ export function resolveDocumentRef<T>(
|
|
|
30
58
|
}
|
|
31
59
|
let node: unknown = schema;
|
|
32
60
|
for (const key of pointer) {
|
|
33
|
-
const child =
|
|
61
|
+
const child = childOf(schema, node, key, { ...options, logger });
|
|
34
62
|
if (!child) {
|
|
35
63
|
logger.warn(warningText(`Could not resolve $ref "${$ref}"`, WARNING_CODES.REF_NOT_FOUND));
|
|
36
64
|
return undefined;
|
package/src/api/document-run.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
3
|
import type { Config as RedoclyConfig } from "@redocly/openapi-core";
|
|
4
4
|
import { sourceEmptyError } from "../adapters/redocly-loader/schema-load-errors.js";
|
|
5
5
|
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
6
6
|
import type { Logger } from "../application/ports/logger.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { SchemaLoader } from "../application/ports/schema-loader.js";
|
|
8
8
|
import { withStackOverflowReported } from "../application/stack-overflow.js";
|
|
9
9
|
import {
|
|
10
10
|
ineffectiveFixNotices,
|
|
@@ -19,6 +19,7 @@ import { warnDiscriminatorValueConflicts } from "./discriminator-conflict-warnin
|
|
|
19
19
|
import { findDiscriminators } from "./discriminator-scan.js";
|
|
20
20
|
import { resolveDocumentRef } from "./document-refs.js";
|
|
21
21
|
import { warnIdenticalPathTemplates } from "./path-template-warnings.js";
|
|
22
|
+
import { refAccessOf } from "./ref-limit-options.js";
|
|
22
23
|
import type { RunContext } from "./run-context.js";
|
|
23
24
|
import { warnUnsupportedFeatures } from "./unsupported-feature-warnings.js";
|
|
24
25
|
|
|
@@ -34,9 +35,10 @@ export interface GeneratorPorts {
|
|
|
34
35
|
readonly now: () => number;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
/** A validated, bundled document
|
|
38
|
+
/** A validated, bundled document, the local files it was read from, and the run's context. */
|
|
38
39
|
export interface DocumentRun {
|
|
39
40
|
readonly schema: OpenAPI3;
|
|
41
|
+
readonly localFiles: readonly URL[];
|
|
40
42
|
readonly ctx: RunContext;
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -67,19 +69,6 @@ function sourceCwd(options: GeneratorOptions): URL {
|
|
|
67
69
|
return pathToFileURL(path.join(directory, path.sep));
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
/** The `$ref` limits of the options; a relative local root resolves against the cwd. */
|
|
71
|
-
function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {
|
|
72
|
-
const { localRefRoot, remoteRefHosts } = options;
|
|
73
|
-
const localRoot =
|
|
74
|
-
typeof localRefRoot === "string"
|
|
75
|
-
? pathToFileURL(path.resolve(fileURLToPath(cwd), localRefRoot))
|
|
76
|
-
: localRefRoot;
|
|
77
|
-
return {
|
|
78
|
-
...(localRoot === undefined ? {} : { localRoot }),
|
|
79
|
-
...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteRefHosts }),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
72
|
function callbackOptions(options: GeneratorOptions) {
|
|
84
73
|
return {
|
|
85
74
|
irCallbacks: options.irCallbacks === true,
|
|
@@ -125,7 +114,9 @@ function contextFlags(options: GeneratorOptions): ContextFlags {
|
|
|
125
114
|
*/
|
|
126
115
|
function outputFixesOf(options: GeneratorOptions, logger: Logger): readonly OutputFix[] {
|
|
127
116
|
const names = outputFixNamesOf(options.fix ?? []);
|
|
128
|
-
|
|
117
|
+
// The options with their defaults: `defaultNonNullable` is on unless set to false.
|
|
118
|
+
const flags = contextFlags(options);
|
|
119
|
+
for (const notice of ineffectiveFixNotices(names, (option) => flags[option])) {
|
|
129
120
|
logger.warn(warningText(notice, WARNING_CODES.FIX_NEEDS_OPTION));
|
|
130
121
|
}
|
|
131
122
|
return [...resolveOutputFixes(names)];
|
|
@@ -156,7 +147,7 @@ export async function createDocumentRun(
|
|
|
156
147
|
const fix = outputFixesOf(options, logger);
|
|
157
148
|
const silent = options.silent ?? false;
|
|
158
149
|
const cwd = sourceCwd(options);
|
|
159
|
-
const schema = await ports.loader.load({
|
|
150
|
+
const { document: schema, localFiles } = await ports.loader.load({
|
|
160
151
|
source,
|
|
161
152
|
cwd,
|
|
162
153
|
shouldLint: options.lint ?? true,
|
|
@@ -181,5 +172,5 @@ export async function createDocumentRun(
|
|
|
181
172
|
logger,
|
|
182
173
|
deprecations: ports.deprecations,
|
|
183
174
|
};
|
|
184
|
-
return { schema, ctx };
|
|
175
|
+
return { schema, localFiles, ctx };
|
|
185
176
|
}
|
package/src/api/legacy-utils.ts
CHANGED
|
@@ -36,7 +36,11 @@ export function createDiscriminatorProperty(
|
|
|
36
36
|
return discriminatorProperty(discriminator, path, readonly);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Create a $ref pointer (even from other $refs). A part that contains `#/` is read as a `$ref`
|
|
41
|
+
* and contributes its decoded segments, so it throws URIError for a malformed percent escape; any
|
|
42
|
+
* other part is one segment. To append raw document keys, escape each one instead.
|
|
43
|
+
*/
|
|
40
44
|
export function createRef(parts: (number | string | undefined | null)[]): string {
|
|
41
45
|
return createDomainRef(parts);
|
|
42
46
|
}
|
package/src/api/openapi-ts.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createRedoclySchemaLoader } from "../adapters/redocly-loader/redocly-schema-loader.js";
|
|
2
|
+
import type { Logger } from "../application/ports/logger.js";
|
|
2
3
|
import { withStackOverflowReported } from "../application/stack-overflow.js";
|
|
3
4
|
import type { IrDeclaration } from "../domain/ir/nodes.js";
|
|
4
5
|
import type { GeneratorOptions, SchemaSource } from "../types.js";
|
|
@@ -18,29 +19,46 @@ import transformSchema from "./transform-schema.js";
|
|
|
18
19
|
* `generateDeclarations` runs with any ports, which is how the CLI calls it.
|
|
19
20
|
*/
|
|
20
21
|
|
|
22
|
+
/** The declarations of one document, and the local files it was read from. */
|
|
23
|
+
export interface GeneratedDocument {
|
|
24
|
+
readonly declarations: IrDeclaration[];
|
|
25
|
+
readonly localFiles: readonly URL[];
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
/** Load, validate and bundle the source, then transform it into IR declarations. */
|
|
22
|
-
export async function
|
|
29
|
+
export async function generateDocument(
|
|
23
30
|
source: SchemaSource,
|
|
24
31
|
options: GeneratorOptions,
|
|
25
32
|
ports: GeneratorPorts,
|
|
26
|
-
): Promise<
|
|
27
|
-
const { schema, ctx } = await createDocumentRun(source, options, ports);
|
|
33
|
+
): Promise<GeneratedDocument> {
|
|
34
|
+
const { schema, localFiles, ctx } = await createDocumentRun(source, options, ports);
|
|
28
35
|
const startedAt = ports.now();
|
|
29
|
-
const
|
|
36
|
+
const declarations = withStackOverflowReported("transform", () => transformSchema(schema, ctx));
|
|
30
37
|
ports.logger.debug(
|
|
31
38
|
"Completed AST transformation for entire document",
|
|
32
39
|
"ts",
|
|
33
40
|
ports.now() - startedAt,
|
|
34
41
|
);
|
|
35
|
-
return
|
|
42
|
+
return { declarations, localFiles };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** As `generateDocument`, the declarations only. */
|
|
46
|
+
export async function generateDeclarations(
|
|
47
|
+
source: SchemaSource,
|
|
48
|
+
options: GeneratorOptions,
|
|
49
|
+
ports: GeneratorPorts,
|
|
50
|
+
): Promise<IrDeclaration[]> {
|
|
51
|
+
return (await generateDocument(source, options, ports)).declarations;
|
|
36
52
|
}
|
|
37
53
|
|
|
38
54
|
/**
|
|
39
55
|
* The default ports: the terminal logger, Node.js deprecation warnings, the given or default
|
|
40
|
-
* Redocly config, Redocly loading.
|
|
56
|
+
* Redocly config, Redocly loading. A given `logger` takes every line, the loader's included.
|
|
41
57
|
*/
|
|
42
|
-
export async function defaultGeneratorPorts(
|
|
43
|
-
|
|
58
|
+
export async function defaultGeneratorPorts(
|
|
59
|
+
options: GeneratorOptions,
|
|
60
|
+
logger: Logger = defaultLogger(options.silent ?? false),
|
|
61
|
+
): Promise<GeneratorPorts> {
|
|
44
62
|
const redoc = options.redocly ?? (await defaultRedoclyConfig());
|
|
45
63
|
const loader = createRedoclySchemaLoader({
|
|
46
64
|
redoc,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import type { RefAccess } from "../application/ports/schema-loader.js";
|
|
4
|
+
import { ERROR_CODES, OpenAPITypesafeError } from "../domain/errors.js";
|
|
5
|
+
import { hasUrlScheme } from "../domain/location-text.js";
|
|
6
|
+
import type { GeneratorOptions } from "../types.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The `$ref` limits of the options (threat model R1, R2, ADR-017), checked before anything loads.
|
|
10
|
+
* A value of another type from JavaScript (`remoteRefHosts: "a.com"`, `localRefRoot: new
|
|
11
|
+
* URL("https://…")`) used to fail later as an error of the document.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const FILE_PROTOCOL = "file:";
|
|
15
|
+
|
|
16
|
+
/** What a value is, for the error; a URL is named by its protocol only, as it may hold secrets. */
|
|
17
|
+
function kindOf(value: unknown): string {
|
|
18
|
+
if (value instanceof URL) {
|
|
19
|
+
return `a ${value.protocol} URL`;
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return "a list";
|
|
23
|
+
}
|
|
24
|
+
return value === null ? "null" : `a ${typeof value}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function optionInvalid(option: string, expected: string, got: string): OpenAPITypesafeError {
|
|
28
|
+
return new OpenAPITypesafeError({
|
|
29
|
+
code: ERROR_CODES.OPTION_INVALID,
|
|
30
|
+
message: `The ${option} option must be ${expected}; got ${got}.`,
|
|
31
|
+
details: { option },
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const LOCAL_ROOT_EXPECTED = "a directory path or a file: URL";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A string as the CLI reads `--local-ref-root`: a URL when it has a scheme (`file:///specs/`),
|
|
39
|
+
* else a path that resolves against the cwd. Undefined when it does not parse as a URL.
|
|
40
|
+
*/
|
|
41
|
+
function localRootUrlOf(value: string, cwd: URL): URL | undefined {
|
|
42
|
+
if (!hasUrlScheme(value)) {
|
|
43
|
+
return pathToFileURL(path.resolve(fileURLToPath(cwd), value));
|
|
44
|
+
}
|
|
45
|
+
return URL.parse(value, cwd.href) ?? undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The local root as a `file:` URL; the option is set, so it is not undefined. */
|
|
49
|
+
function localRootOf(value: unknown, cwd: URL): URL {
|
|
50
|
+
const root = typeof value === "string" ? localRootUrlOf(value, cwd) : value;
|
|
51
|
+
if (root instanceof URL && root.protocol === FILE_PROTOCOL) {
|
|
52
|
+
return root;
|
|
53
|
+
}
|
|
54
|
+
const got = root === undefined ? "a string that is no valid URL" : kindOf(root);
|
|
55
|
+
throw optionInvalid("localRefRoot", LOCAL_ROOT_EXPECTED, got);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function remoteHostsOf(value: unknown): readonly string[] {
|
|
59
|
+
if (!Array.isArray(value)) {
|
|
60
|
+
throw optionInvalid("remoteRefHosts", "a list of hosts", kindOf(value));
|
|
61
|
+
}
|
|
62
|
+
const other = value.find((entry) => typeof entry !== "string");
|
|
63
|
+
if (other !== undefined) {
|
|
64
|
+
throw optionInvalid("remoteRefHosts", "a list of hosts", `a list with ${kindOf(other)}`);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The limits of the options; fails with `OPTION_INVALID` for a value of another type. */
|
|
70
|
+
export function refAccessOf(options: GeneratorOptions, cwd: URL): RefAccess {
|
|
71
|
+
const { localRefRoot, remoteRefHosts } = options;
|
|
72
|
+
return {
|
|
73
|
+
...(localRefRoot === undefined ? {} : { localRoot: localRootOf(localRefRoot, cwd) }),
|
|
74
|
+
...(remoteRefHosts === undefined ? {} : { remoteHosts: remoteHostsOf(remoteRefHosts) }),
|
|
75
|
+
};
|
|
76
|
+
}
|
package/src/api/run-context.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
2
2
|
import type { Logger } from "../application/ports/logger.js";
|
|
3
3
|
import type { DocumentFooter } from "../application/transform/transform-context.js";
|
|
4
|
+
import type { SchemaDialect } from "../domain/openapi/schema-dialect.js";
|
|
4
5
|
import type { GlobalContext, LegacyCallbackName, SchemaObject } from "../types.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -26,6 +27,8 @@ export interface RunContext extends GlobalContext {
|
|
|
26
27
|
*/
|
|
27
28
|
readonly otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
28
29
|
};
|
|
30
|
+
/** The schema dialect of the run's document; without it, OpenAPI 3.0 (`schemaDialectOf`). */
|
|
31
|
+
schemaDialect?: SchemaDialect;
|
|
29
32
|
/** Footer state of this run (enum registry and enum naming), created on first use. */
|
|
30
33
|
runFooter?: DocumentFooter;
|
|
31
34
|
/** The deprecated callback forms this run has warned about (once each). */
|