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
|
@@ -12,12 +12,14 @@ import type {
|
|
|
12
12
|
EnumValuesRequest,
|
|
13
13
|
} from "../schema/schema-context.js";
|
|
14
14
|
import type { DocumentFooter } from "../transform-context.js";
|
|
15
|
+
import { EnumNameClaims } from "./enum-name-claims.js";
|
|
15
16
|
import {
|
|
16
17
|
type DeclaredMembers,
|
|
17
18
|
EnumNaming,
|
|
18
19
|
enumDeclaration,
|
|
19
20
|
withoutDeclaredMembers,
|
|
20
21
|
} from "./enum-naming.js";
|
|
22
|
+
import { OperationKeys } from "./operation-keys.js";
|
|
21
23
|
import { FIRST_SCHEMA_NAMES, type SharedEnumNames } from "./shared-enum-names.js";
|
|
22
24
|
|
|
23
25
|
/** Where footer declarations go, in order: the run's `ctx.injectFooter`, open to user code. */
|
|
@@ -30,14 +32,23 @@ export interface FooterSink {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
|
-
* The `--dedupe-enums` key
|
|
34
|
-
* the
|
|
35
|
+
* The `--dedupe-enums` key. Two enums share a declaration only when the original shares it and
|
|
36
|
+
* each value has the same name and description in both. The original key pairs the values in
|
|
37
|
+
* default sort order with the metadata at the sorted position, not with the value's own metadata,
|
|
38
|
+
* so `[desc, asc]` and `[asc, desc]`, both named `[Desc, Asc]`, shared one declaration, and one of
|
|
39
|
+
* them typed `asc` as `Desc = "desc"`. The original also joined `name:description` texts with
|
|
40
|
+
* `,`, and a member name stood in for its value, so enums with other values (`"1"` and `1`, `A`
|
|
41
|
+
* and `1` both named `Active`, `["a", "b"]` and `["a:,b"]`) shared one key. As JSON, an equal key
|
|
42
|
+
* means the same values and metadata; enums the original kept apart still are.
|
|
35
43
|
*/
|
|
36
44
|
function dedupeKey(request: EnumDeclarationRequest): string {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
.
|
|
45
|
+
const sorted = [...request.values].sort(compareAsStrings);
|
|
46
|
+
const originalPairs = sorted.map((value, index) => memberKey(value, request.metadata[index]));
|
|
47
|
+
const ownPairs = request.values
|
|
48
|
+
.map((value, index) => ({ value, member: memberKey(value, request.metadata[index]) }))
|
|
49
|
+
.sort((left, right) => compareAsStrings(left.value, right.value))
|
|
50
|
+
.map(({ member }) => member);
|
|
51
|
+
return JSON.stringify([originalPairs, ownPairs]);
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
/** `Array.prototype.sort` without a comparator: compares the values as strings. */
|
|
@@ -50,8 +61,9 @@ function compareAsStrings(left: string | number, right: string | number): number
|
|
|
50
61
|
return leftText < rightText ? -1 : 1;
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
/** One member: the value (JSON keeps `"1"` and `1` apart), its name and its description. */
|
|
65
|
+
function memberKey(value: string | number, metadata: EnumMemberMetadata | undefined) {
|
|
66
|
+
return [value, metadata?.name ?? null, metadata?.description || null];
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
/** Separates a repeated `--enum-values` array name from its number, as root type aliases do. */
|
|
@@ -62,6 +74,12 @@ function declarationKey(name: string, request: EnumDeclarationRequest): string {
|
|
|
62
74
|
return JSON.stringify([name, request.values, request.metadata]);
|
|
63
75
|
}
|
|
64
76
|
|
|
77
|
+
/** The naming state a run's footer shares with the rest of the run. */
|
|
78
|
+
export interface RunFooterNames {
|
|
79
|
+
readonly enums: EnumNameClaims;
|
|
80
|
+
readonly operations: OperationKeys;
|
|
81
|
+
}
|
|
82
|
+
|
|
65
83
|
/**
|
|
66
84
|
* The footer of one run: enums (deduplicated with `--dedupe-enums`), `--enum-values` arrays, the
|
|
67
85
|
* helper types they need, and the `operations` interface. Replaces the original's module-level
|
|
@@ -83,15 +101,18 @@ export class RunFooter implements DocumentFooter {
|
|
|
83
101
|
private readonly sink: FooterSink;
|
|
84
102
|
private readonly isDedupingEnums: boolean;
|
|
85
103
|
private readonly sharedNames: SharedEnumNames;
|
|
104
|
+
private readonly names: RunFooterNames;
|
|
86
105
|
|
|
87
106
|
constructor(
|
|
88
107
|
sink: FooterSink,
|
|
89
108
|
isDedupingEnums: boolean,
|
|
90
109
|
sharedNames: SharedEnumNames = FIRST_SCHEMA_NAMES,
|
|
110
|
+
names: RunFooterNames = { enums: new EnumNameClaims(), operations: new OperationKeys() },
|
|
91
111
|
) {
|
|
92
112
|
this.sink = sink;
|
|
93
113
|
this.isDedupingEnums = isDedupingEnums;
|
|
94
114
|
this.sharedNames = sharedNames;
|
|
115
|
+
this.names = names;
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
addEnum(request: EnumDeclarationRequest): string {
|
|
@@ -99,11 +120,13 @@ export class RunFooter implements DocumentFooter {
|
|
|
99
120
|
const ownName = this.naming.enumName(request.name);
|
|
100
121
|
const key = this.isDedupingEnums ? dedupeKey(request) : null;
|
|
101
122
|
// Every schema of a shared enum goes to `sharedNames`, the later ones too.
|
|
102
|
-
const
|
|
123
|
+
const sharedName = key === null ? ownName : this.sharedNames.nameOf(key, ownName, request);
|
|
103
124
|
const known = key === null ? undefined : this.enumNamesByKey.get(key);
|
|
104
125
|
if (known !== undefined) {
|
|
105
126
|
return known;
|
|
106
127
|
}
|
|
128
|
+
// The owner is the schema location: its requests share one enum, with `--dedupe-enums` too.
|
|
129
|
+
const name = this.names.enums.nameFor(sharedName, request.name);
|
|
107
130
|
// Only a repeated member fails to compile; two empty declarations merge, so they stay.
|
|
108
131
|
const declared = request.values.length > 0 ? declarationKey(name, request) : null;
|
|
109
132
|
if (declared !== null && this.declaredEnums.has(declared)) {
|
|
@@ -200,6 +223,10 @@ export class RunFooter implements DocumentFooter {
|
|
|
200
223
|
this.sink.addOperation(build);
|
|
201
224
|
}
|
|
202
225
|
|
|
226
|
+
operationKey(operationId: string): string {
|
|
227
|
+
return this.names.operations.keyFor(operationId);
|
|
228
|
+
}
|
|
229
|
+
|
|
203
230
|
private require(helper: HelperType): void {
|
|
204
231
|
if (!this.sink.hasTypeAlias(helper.name)) {
|
|
205
232
|
this.sink.add({ kind: "rawDeclaration", name: helper.name, text: helper.text });
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { freeNumberedName } from "../numbered-names.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The names of the `--enum` declarations of one run, unique across the enums and apart from the
|
|
5
|
+
* names the rest of the output may need.
|
|
6
|
+
*
|
|
7
|
+
* Every enum has an owner: the schema location it is named after, or with `--dedupe-enums` its
|
|
8
|
+
* members. Two owners whose names come out the same (`status` and `Status`) merged into one enum
|
|
9
|
+
* before, so each accepted the values of the other (upstream behavior). Now the first owner keeps
|
|
10
|
+
* the name and each later one gets the next free `Name_2`, `Name_3`, …; requests of one owner (a
|
|
11
|
+
* property and an inline `allOf` item of one schema) still share one enum.
|
|
12
|
+
*
|
|
13
|
+
* An enum also gives way to a name the output may need, which is only known at the end: a global
|
|
14
|
+
* type the output refers to (the `Blob` of `--binary-as-blob`, the `Record` of
|
|
15
|
+
* `Record<string, never>`), a helper type, or `ApiPaths`. Until then it takes the numbered name;
|
|
16
|
+
* `givenBack` lists the ones whose own name the output turned out not to need, so output that
|
|
17
|
+
* compiled before keeps its names (ADR-021).
|
|
18
|
+
*/
|
|
19
|
+
export class EnumNameClaims {
|
|
20
|
+
private readonly mayBeNeeded: ReadonlySet<string>;
|
|
21
|
+
/** The first owner of each name an enum asked for. */
|
|
22
|
+
private readonly owners = new Map<string, string>();
|
|
23
|
+
/** The name given to each owner, by name asked for and owner. */
|
|
24
|
+
private readonly given = new Map<string, string>();
|
|
25
|
+
/** Every name given, and every name the output may need. */
|
|
26
|
+
private readonly taken: Set<string>;
|
|
27
|
+
/** A numbered name given only because the output may need the name asked for: that name. */
|
|
28
|
+
private readonly standIns = new Map<string, string>();
|
|
29
|
+
|
|
30
|
+
/** `mayBeNeeded`: the names an enum avoids until the end of the run; empty outside a run. */
|
|
31
|
+
constructor(mayBeNeeded: ReadonlySet<string> = new Set()) {
|
|
32
|
+
this.mayBeNeeded = mayBeNeeded;
|
|
33
|
+
this.taken = new Set(mayBeNeeded);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The declaration name of the enum `owner` asks to name `name`; the same for every request. */
|
|
37
|
+
nameFor(name: string, owner: string): string {
|
|
38
|
+
const key = JSON.stringify([name, owner]);
|
|
39
|
+
const known = this.given.get(key);
|
|
40
|
+
if (known !== undefined) {
|
|
41
|
+
return known;
|
|
42
|
+
}
|
|
43
|
+
const isFirstOwner = (this.owners.get(name) ?? owner) === owner;
|
|
44
|
+
this.owners.set(name, this.owners.get(name) ?? owner);
|
|
45
|
+
const isFree = isFirstOwner && !this.taken.has(name);
|
|
46
|
+
const declared = isFree ? name : freeNumberedName(name, this.taken);
|
|
47
|
+
if (isFirstOwner && this.mayBeNeeded.has(name)) {
|
|
48
|
+
this.standIns.set(declared, name);
|
|
49
|
+
}
|
|
50
|
+
this.taken.add(declared);
|
|
51
|
+
this.given.set(key, declared);
|
|
52
|
+
return declared;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The numbered names to rename back to the name asked for, because `needed` (the names the
|
|
57
|
+
* finished output declares or refers to) does not hold that name.
|
|
58
|
+
*/
|
|
59
|
+
givenBack(needed: ReadonlySet<string>): ReadonlyMap<string, string> {
|
|
60
|
+
return new Map([...this.standIns].filter(([, name]) => !needed.has(name)));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keys of the `operations` interface in one run. A repeated `operationId` (Redocly warns
|
|
3
|
+
* about it) gave the interface two members of one name, which did not compile (TS2300). Now the
|
|
4
|
+
* first operation with an ID keeps it, and each later one gets the lowest number from 2 whose key
|
|
5
|
+
* no operation of the document has: the second `listItems` is `listItems2`, the name
|
|
6
|
+
* `--make-paths-enum` gives it in `ApiPaths` too. Keys follow the order the operations are
|
|
7
|
+
* transformed in, which is the document order (or the `--alphabetize` order).
|
|
8
|
+
*/
|
|
9
|
+
export class OperationKeys {
|
|
10
|
+
private readonly written: ReadonlySet<string>;
|
|
11
|
+
private readonly taken = new Set<string>();
|
|
12
|
+
|
|
13
|
+
/** `written`: every operation key of the document; empty outside a document run. */
|
|
14
|
+
constructor(written: ReadonlySet<string> = new Set()) {
|
|
15
|
+
this.written = written;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The key of the next operation with this key, written or numbered. */
|
|
19
|
+
keyFor(key: string): string {
|
|
20
|
+
let unique = key;
|
|
21
|
+
for (let count = 2; this.taken.has(unique); count += 1) {
|
|
22
|
+
const candidate = `${key}${count}`;
|
|
23
|
+
unique = this.written.has(candidate) ? unique : candidate;
|
|
24
|
+
}
|
|
25
|
+
this.taken.add(unique);
|
|
26
|
+
return unique;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -22,7 +22,7 @@ import { extracted, markerObject, omitted } from "./type-rules.js";
|
|
|
22
22
|
|
|
23
23
|
/** How many references one evaluation expands; a deeper one is opaque. */
|
|
24
24
|
const MAX_EXPANSIONS = 200;
|
|
25
|
-
const
|
|
25
|
+
const DEEP_HELPER = "FlattenedDeepRequired";
|
|
26
26
|
/** How many members distributing an intersection may give; more is opaque. */
|
|
27
27
|
const MAX_DISTRIBUTED = 64;
|
|
28
28
|
|
|
@@ -75,15 +75,15 @@ export class TypeEvaluator {
|
|
|
75
75
|
if (this.expansions++ > MAX_EXPANSIONS) {
|
|
76
76
|
return OPAQUE;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
const [first, second] = args;
|
|
79
|
+
if (name === DEEP_HELPER && first?.kind === "reference" && first.typeArguments.length === 0) {
|
|
80
|
+
const root = this.declared.get(first.name);
|
|
80
81
|
return root === undefined ? OPAQUE : this.expand({ kind: "type", type: root, deep: true });
|
|
81
82
|
}
|
|
82
83
|
const declared = args.length === 0 ? this.declared.get(name) : undefined;
|
|
83
84
|
if (declared !== undefined) {
|
|
84
85
|
return this.expand({ ...value, type: declared });
|
|
85
86
|
}
|
|
86
|
-
const [first, second] = args;
|
|
87
87
|
if (first === undefined) {
|
|
88
88
|
return OPAQUE;
|
|
89
89
|
}
|
|
@@ -51,9 +51,10 @@ export const HELPER_TYPES = {
|
|
|
51
51
|
/**
|
|
52
52
|
* The `--read-write-markers` helper types, written before the root types. Task 7.6 replaces the
|
|
53
53
|
* original text on purpose (ADR-014): primitives (also branded), readonly arrays, tuples,
|
|
54
|
-
* intersected arrays
|
|
55
|
-
* #2717, #2765). The declarations equal `Readable` / `Writable`
|
|
56
|
-
* (`test/api/read-write-marker-types.test.ts`); the text is what
|
|
54
|
+
* intersected arrays, null-only and `any` properties keep their types (upstream #2615, #2620,
|
|
55
|
+
* #2632, #2717, #2765). The declarations equal the `Readable` / `Writable` that
|
|
56
|
+
* openapi-typesafe-fetch declares (`test/api/read-write-marker-types.test.ts`); the text is what
|
|
57
|
+
* the TypeScript printer prints.
|
|
57
58
|
*/
|
|
58
59
|
export const READ_WRITE_MARKER_TYPES = lines(
|
|
59
60
|
"export type $Read<T> = {",
|
|
@@ -64,10 +65,10 @@ export const READ_WRITE_MARKER_TYPES = lines(
|
|
|
64
65
|
"};",
|
|
65
66
|
"type ReadWritePrimitive = string | number | boolean | bigint | symbol | null | undefined;",
|
|
66
67
|
"type ReadWriteLeaf = ReadWritePrimitive | ((...args: never) => unknown);",
|
|
67
|
-
"type ReadWriteMarkedKeys<T, Marker> = {",
|
|
68
|
-
" [K in keyof T]
|
|
69
|
-
"extends Marker ? K : never;",
|
|
70
|
-
"}
|
|
68
|
+
"type ReadWriteMarkedKeys<T, Marker> = keyof {",
|
|
69
|
+
" [K in keyof T as 0 extends 1 & T[K] ? never : NonNullable<T[K]> extends never ? never : " +
|
|
70
|
+
"NonNullable<T[K]> extends Marker ? K : never]: never;",
|
|
71
|
+
"};",
|
|
71
72
|
'type ReadWriteResolveArray<T extends readonly unknown[], Resolved extends "read" | ' +
|
|
72
73
|
'"write"> = T[number][] extends T ? T extends unknown[] ? ReadWriteResolve<T[number], ' +
|
|
73
74
|
"Resolved>[] : readonly ReadWriteResolve<T[number], Resolved>[] : {",
|
|
@@ -18,3 +18,18 @@ export function withNumberedRepeats(names: readonly string[], numbered: Numbered
|
|
|
18
18
|
return unique;
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
/** Separates a repeated declaration name from its number: `Status` → `Status_2`. */
|
|
23
|
+
const DECLARATION_NUMBER_SEPARATOR = "_";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The first of `Name_2`, `Name_3`, … that `taken` does not hold: the suffix `--root-types` uses for
|
|
27
|
+
* its own conflicts, and every other declaration that must give way to another name.
|
|
28
|
+
*/
|
|
29
|
+
export function freeNumberedName(name: string, taken: ReadonlySet<string>): string {
|
|
30
|
+
let count = 2;
|
|
31
|
+
while (taken.has(`${name}${DECLARATION_NUMBER_SEPARATOR}${count}`)) {
|
|
32
|
+
count += 1;
|
|
33
|
+
}
|
|
34
|
+
return `${name}${DECLARATION_NUMBER_SEPARATOR}${count}`;
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
2
2
|
import type { RefResolver } from "../schema/schema-context.js";
|
|
3
|
-
import { isJsonObject } from "./
|
|
3
|
+
import { isJsonObject } from "./located-node.js";
|
|
4
4
|
import {
|
|
5
5
|
leadingSegmentsOf,
|
|
6
6
|
type RefPointer,
|
|
@@ -205,7 +205,7 @@ function walkTo(ref: string, refs: RefResolver, seen: readonly string[]): Locati
|
|
|
205
205
|
export function generatedLocationOf(ref: string, refs: RefResolver): GeneratedLocation {
|
|
206
206
|
const walk = walkTo(ref, refs, []);
|
|
207
207
|
return {
|
|
208
|
-
path: walk === null ? ref :
|
|
208
|
+
path: walk === null ? ref : appendPointer(ROOT_POINTER, walk.path),
|
|
209
209
|
isFromAdditionalProperties: walk?.isFromAdditionalProperties ?? false,
|
|
210
210
|
};
|
|
211
211
|
}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { isRawBinarySchema } from "../../../domain/openapi/binary-content.js";
|
|
2
2
|
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
3
|
+
import {
|
|
4
|
+
childLocation,
|
|
5
|
+
followLocated,
|
|
6
|
+
isJsonObject,
|
|
7
|
+
type JsonObject,
|
|
8
|
+
type LocatedNode,
|
|
9
|
+
} from "./located-node.js";
|
|
10
|
+
import {
|
|
11
|
+
isExcludedProperty,
|
|
12
|
+
isMarkedProperty,
|
|
13
|
+
isNullableSchema,
|
|
14
|
+
isOptionalProperty,
|
|
15
|
+
} from "./property-shape.js";
|
|
3
16
|
|
|
4
17
|
/**
|
|
5
18
|
* What the generated type of a schema has under a key, read from the schema itself. It answers the
|
|
@@ -8,14 +21,19 @@ import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
|
8
21
|
*/
|
|
9
22
|
|
|
10
23
|
export type GeneratedMember =
|
|
11
|
-
| {
|
|
24
|
+
| {
|
|
25
|
+
readonly kind: "property";
|
|
26
|
+
readonly node: unknown;
|
|
27
|
+
readonly location: string | undefined;
|
|
28
|
+
readonly isOptional: boolean;
|
|
29
|
+
/** `$Read<T>` or `$Write<T>` (`isMarkedProperty`): no member but the marker's own. */
|
|
30
|
+
readonly isMarked: boolean;
|
|
31
|
+
}
|
|
12
32
|
/** An index signature; `node` is undefined when its value type is `unknown`. */
|
|
13
|
-
| { readonly kind: "index"; readonly node: unknown }
|
|
33
|
+
| { readonly kind: "index"; readonly node: unknown; readonly location: string | undefined }
|
|
14
34
|
| { readonly kind: "missing" }
|
|
15
35
|
| { readonly kind: "opaque" };
|
|
16
36
|
|
|
17
|
-
type JsonObject = Readonly<Record<string, unknown>>;
|
|
18
|
-
|
|
19
37
|
const OPAQUE_KEYS = ["not", "enum", "const", "$ref"] as const;
|
|
20
38
|
/** How deep `allOf`/`anyOf`/`oneOf` members are read; deeper shapes count as opaque. */
|
|
21
39
|
const MAX_DEPTH = 8;
|
|
@@ -23,23 +41,6 @@ const INDEX_RE = /^\d+$/;
|
|
|
23
41
|
const MISSING: GeneratedMember = { kind: "missing" };
|
|
24
42
|
const OPAQUE: GeneratedMember = { kind: "opaque" };
|
|
25
43
|
|
|
26
|
-
export function isJsonObject(value: unknown): value is JsonObject {
|
|
27
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** The schema a node stands for: a `$ref` is followed to its target. */
|
|
31
|
-
export function followRefs(node: unknown, refs: RefResolver): unknown {
|
|
32
|
-
return isJsonObject(node) && typeof node.$ref === "string" ? refs.resolve(node.$ref) : node;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** `nullable: true` or a `type` list with `null`: the generated type includes `null`. */
|
|
36
|
-
export function isNullableSchema(node: unknown): boolean {
|
|
37
|
-
if (!isJsonObject(node)) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return node.nullable === true || (Array.isArray(node.type) && node.type.includes("null"));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
44
|
function typeNames(node: JsonObject): readonly unknown[] {
|
|
44
45
|
return Array.isArray(node.type) ? node.type : [node.type];
|
|
45
46
|
}
|
|
@@ -90,39 +91,37 @@ function isBuiltInMember(key: string, prototype: object): boolean {
|
|
|
90
91
|
return key in prototype;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
function indexMember(node: JsonObject, options: SchemaOptions)
|
|
94
|
-
const { additionalProperties: values, patternProperties: patterns } = node;
|
|
94
|
+
function indexMember(owner: LocatedNode & { node: JsonObject }, options: SchemaOptions) {
|
|
95
|
+
const { additionalProperties: values, patternProperties: patterns } = owner.node;
|
|
95
96
|
if (isJsonObject(patterns) && Object.keys(patterns).length > 0) {
|
|
96
97
|
return OPAQUE;
|
|
97
98
|
}
|
|
98
99
|
if (isJsonObject(values) && Object.keys(values).length > 0) {
|
|
99
|
-
|
|
100
|
+
const location = childLocation(owner.location, "additionalProperties");
|
|
101
|
+
return { kind: "index", node: values, location } satisfies GeneratedMember;
|
|
100
102
|
}
|
|
101
103
|
const isImplicit = values === true || (isJsonObject(values) && Object.keys(values).length === 0);
|
|
102
104
|
return isImplicit || (!values && options.additionalProperties)
|
|
103
|
-
? { kind: "index", node: undefined }
|
|
105
|
+
? ({ kind: "index", node: undefined, location: undefined } satisfies GeneratedMember)
|
|
104
106
|
: null;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
(hasDefault && options.defaultNonNullable);
|
|
115
|
-
return !isRequired;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function objectMember(node: JsonObject, key: string, options: SchemaOptions): GeneratedMember {
|
|
109
|
+
function objectMember(
|
|
110
|
+
owner: LocatedNode & { node: JsonObject },
|
|
111
|
+
key: string,
|
|
112
|
+
input: MemberInput,
|
|
113
|
+
): GeneratedMember {
|
|
114
|
+
const { options } = input;
|
|
115
|
+
const { node } = owner;
|
|
119
116
|
const properties = isJsonObject(node.properties) ? node.properties : {};
|
|
120
|
-
if (Object.hasOwn(properties, key)) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
if (Object.hasOwn(properties, key) && !isExcludedProperty(properties[key], options, input.refs)) {
|
|
118
|
+
if (isJsonObject(node.discriminator)) {
|
|
119
|
+
return OPAQUE;
|
|
120
|
+
}
|
|
121
|
+
const location = childLocation(owner.location, "properties", key);
|
|
122
|
+
const isOptional = isOptionalProperty(owner, key, options);
|
|
123
|
+
const isMarked = isMarkedProperty(properties[key], options, input.refs);
|
|
124
|
+
return { kind: "property", node: properties[key], location, isOptional, isMarked };
|
|
126
125
|
}
|
|
127
126
|
// `unevaluatedProperties` adds an index signature with its fix, so it counts as opaque too.
|
|
128
127
|
const isUnknownShape =
|
|
@@ -131,38 +130,23 @@ function objectMember(node: JsonObject, key: string, options: SchemaOptions): Ge
|
|
|
131
130
|
return OPAQUE;
|
|
132
131
|
}
|
|
133
132
|
return hasObjectKeywords(node)
|
|
134
|
-
? (indexMember(
|
|
133
|
+
? (indexMember(owner, options) ?? MISSING)
|
|
135
134
|
: emptyObjectMember(node, options);
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
/** Whether a value is there: `present`, `absent` (may be `undefined` or `null`) or `unknown`. */
|
|
139
|
-
export type Presence = "present" | "absent" | "unknown";
|
|
140
|
-
|
|
141
|
-
/** The presence of a value of `schema` itself: `absent` when its type includes `null`. */
|
|
142
|
-
export function schemaPresence(schema: unknown, refs: RefResolver): Presence {
|
|
143
|
-
return isNullableSchema(followRefs(schema, refs)) ? "absent" : "present";
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/** The presence of property `key` of `schema`: optional or nullable is `absent`. */
|
|
147
|
-
export function propertyPresence(
|
|
148
|
-
schema: unknown,
|
|
149
|
-
key: string,
|
|
150
|
-
options: SchemaOptions,
|
|
151
|
-
refs: RefResolver,
|
|
152
|
-
): Presence {
|
|
153
|
-
const node = followRefs(schema, refs);
|
|
154
|
-
const properties = isJsonObject(node) && isJsonObject(node.properties) ? node.properties : {};
|
|
155
|
-
if (!isJsonObject(node) || !Object.hasOwn(properties, key)) {
|
|
156
|
-
return "unknown";
|
|
157
|
-
}
|
|
158
|
-
return isOptionalProperty(node, key, options) ? "absent" : schemaPresence(properties[key], refs);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
137
|
function membersOf(node: JsonObject, keyword: string): readonly unknown[] {
|
|
162
138
|
const members = node[keyword];
|
|
163
139
|
return Array.isArray(members) ? members : [];
|
|
164
140
|
}
|
|
165
141
|
|
|
142
|
+
/** The members of a composition keyword with their locations. */
|
|
143
|
+
function locatedMembers(owner: LocatedNode & { node: JsonObject }, keyword: string): LocatedNode[] {
|
|
144
|
+
return membersOf(owner.node, keyword).map((node, index) => ({
|
|
145
|
+
node,
|
|
146
|
+
location: childLocation(owner.location, keyword, String(index)),
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
|
|
166
150
|
function withoutComposition(node: JsonObject): JsonObject {
|
|
167
151
|
const { allOf: _allOf, anyOf: _anyOf, oneOf: _oneOf, ...own } = node;
|
|
168
152
|
return own;
|
|
@@ -178,8 +162,13 @@ function hasOwnObjectType(own: JsonObject): boolean {
|
|
|
178
162
|
* `anyOf` or `oneOf` alone is a union: a key is missing if one member misses it. A mix of both
|
|
179
163
|
* is written in more than one way (`anyof-properties`), so it counts as opaque.
|
|
180
164
|
*/
|
|
181
|
-
function composedMember(
|
|
182
|
-
|
|
165
|
+
function composedMember(
|
|
166
|
+
owner: LocatedNode & { node: JsonObject },
|
|
167
|
+
key: string,
|
|
168
|
+
input: MemberInput,
|
|
169
|
+
): GeneratedMember {
|
|
170
|
+
const { node } = owner;
|
|
171
|
+
const variants = [...locatedMembers(owner, "anyOf"), ...locatedMembers(owner, "oneOf")];
|
|
183
172
|
const own = withoutComposition(node);
|
|
184
173
|
const hasOwn = hasOwnObjectType(own);
|
|
185
174
|
if (variants.length > 0) {
|
|
@@ -187,7 +176,8 @@ function composedMember(node: JsonObject, key: string, input: MemberInput): Gene
|
|
|
187
176
|
const members = variants.map((variant) => memberAt(variant, key, input));
|
|
188
177
|
return isAlone && members.some((member) => member.kind === "missing") ? MISSING : OPAQUE;
|
|
189
178
|
}
|
|
190
|
-
const
|
|
179
|
+
const ownPart = { node: own, location: owner.location };
|
|
180
|
+
const parts = [...locatedMembers(owner, "allOf"), ...(hasOwn ? [ownPart] : [])];
|
|
191
181
|
return intersectionMember(parts.map((part) => memberAt(part, key, input)));
|
|
192
182
|
}
|
|
193
183
|
|
|
@@ -216,23 +206,22 @@ interface MemberInput {
|
|
|
216
206
|
readonly depth: number;
|
|
217
207
|
}
|
|
218
208
|
|
|
219
|
-
function memberAt(schema:
|
|
220
|
-
const
|
|
209
|
+
function memberAt(schema: LocatedNode, key: string, input: MemberInput): GeneratedMember {
|
|
210
|
+
const followed = followLocated(schema, input.refs);
|
|
211
|
+
const { node } = followed;
|
|
221
212
|
if (!isJsonObject(node) || OPAQUE_KEYS.some((name) => name in node) || input.depth > MAX_DEPTH) {
|
|
222
213
|
return OPAQUE;
|
|
223
214
|
}
|
|
215
|
+
const owner = { ...followed, node };
|
|
224
216
|
if (isNullableSchema(node)) {
|
|
225
217
|
// Every key of `T | null` is an error, unless `T` is unknown (then the type is `unknown`).
|
|
226
218
|
return isObjectShape(node) || isArrayShape(node) ? MISSING : OPAQUE;
|
|
227
219
|
}
|
|
228
|
-
if (input.options.readWriteMarkers) {
|
|
229
|
-
return OPAQUE;
|
|
230
|
-
}
|
|
231
220
|
if ("allOf" in node || "anyOf" in node || "oneOf" in node) {
|
|
232
|
-
return composedMember(
|
|
221
|
+
return composedMember(owner, key, { ...input, depth: input.depth + 1 });
|
|
233
222
|
}
|
|
234
223
|
if (isObjectShape(node)) {
|
|
235
|
-
return objectMember(
|
|
224
|
+
return objectMember(owner, key, input);
|
|
236
225
|
}
|
|
237
226
|
if (isArrayShape(node)) {
|
|
238
227
|
return INDEX_RE.test(key) || isBuiltInMember(key, []) ? OPAQUE : MISSING;
|
|
@@ -266,7 +255,7 @@ function primitiveMember(node: JsonObject, key: string): GeneratedMember {
|
|
|
266
255
|
|
|
267
256
|
/** The member `key` of the type generated for `schema` (a `$ref` is followed first). */
|
|
268
257
|
export function generatedMember(
|
|
269
|
-
schema:
|
|
258
|
+
schema: LocatedNode,
|
|
270
259
|
key: string,
|
|
271
260
|
options: SchemaOptions,
|
|
272
261
|
refs: RefResolver,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
2
|
-
import { isJsonObject } from "./
|
|
2
|
+
import { isJsonObject } from "./located-node.js";
|
|
3
3
|
import { pointerNode, refPointerOf } from "./pointer-walk.js";
|
|
4
4
|
import { typedWalk } from "./typed-walk.js";
|
|
5
5
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { appendPointer } from "../../../domain/openapi/json-pointer.js";
|
|
2
|
+
import type { RefResolver } from "../schema/schema-context.js";
|
|
3
|
+
|
|
4
|
+
/** Document nodes as the `$ref` pointer walks read them: with their place in the document. */
|
|
5
|
+
|
|
6
|
+
export type JsonObject = Readonly<Record<string, unknown>>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A schema node and its JSON Pointer in the document. The generator writes the type of a schema
|
|
10
|
+
* reached by a `$ref` at the target, and the location decides whether a property with a `default`
|
|
11
|
+
* is required (`isInputLocation`). Undefined for a node that is not in the document.
|
|
12
|
+
*/
|
|
13
|
+
export interface LocatedNode {
|
|
14
|
+
readonly node: unknown;
|
|
15
|
+
readonly location: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isJsonObject(value: unknown): value is JsonObject {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The schema a node stands for: a `$ref` is followed to its target. */
|
|
23
|
+
export function followRefs(node: unknown, refs: RefResolver): unknown {
|
|
24
|
+
return isJsonObject(node) && typeof node.$ref === "string" ? refs.resolve(node.$ref) : node;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** `followRefs` with the location: a `$ref` is followed to its target and the target's pointer. */
|
|
28
|
+
export function followLocated(located: LocatedNode, refs: RefResolver): LocatedNode {
|
|
29
|
+
const { node } = located;
|
|
30
|
+
return isJsonObject(node) && typeof node.$ref === "string"
|
|
31
|
+
? { node: refs.resolve(node.$ref), location: node.$ref }
|
|
32
|
+
: located;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The location of a child of a node at `location`, or undefined outside the document. */
|
|
36
|
+
export function childLocation(location: string | undefined, ...segments: string[]) {
|
|
37
|
+
return location === undefined ? undefined : appendPointer(location, segments);
|
|
38
|
+
}
|