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,20 +1,8 @@
|
|
|
1
1
|
import { irIntersection, irObject, irProperty, irRaw } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type { OperationObject } from "../../../domain/openapi/operation-object.js";
|
|
7
|
-
import type {
|
|
8
|
-
ParameterObject,
|
|
9
|
-
ParameterOrReference,
|
|
10
|
-
} from "../../../domain/openapi/parameter-object.js";
|
|
11
|
-
import {
|
|
12
|
-
type PathItemObject,
|
|
13
|
-
type PathsObject,
|
|
14
|
-
pathItemOperations,
|
|
15
|
-
} from "../../../domain/openapi/path-item-object.js";
|
|
16
|
-
import type { ReferenceSchema, SchemaObject } from "../../../domain/openapi/schema-object.js";
|
|
17
|
-
import { FIX } from "../../../domain/output-fixes.js";
|
|
4
|
+
import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import type { PathItemObject, PathsObject } from "../../../domain/openapi/path-item-object.js";
|
|
18
6
|
import { documentEntries } from "../document-entries.js";
|
|
19
7
|
import { refType } from "../ref-type.js";
|
|
20
8
|
import type { TransformContext } from "../transform-context.js";
|
|
@@ -26,143 +14,88 @@ import {
|
|
|
26
14
|
coveringTemplateKeys,
|
|
27
15
|
type PathKey,
|
|
28
16
|
type PathKeyPart,
|
|
29
|
-
type PathPlaceholder,
|
|
30
17
|
} from "./path-key-overlaps.js";
|
|
31
18
|
import {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
booleanExpandedKeys,
|
|
20
|
+
pathTemplateParts,
|
|
21
|
+
plainUrlOf,
|
|
22
|
+
templateText,
|
|
23
|
+
} from "./path-template-key.js";
|
|
36
24
|
import { assignabilityProof } from "./type-assignability.js";
|
|
37
25
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
["integer", "number"],
|
|
45
|
-
["boolean", "boolean"],
|
|
46
|
-
]);
|
|
47
|
-
const STRING_PLACEHOLDER: PathPlaceholder = "string";
|
|
48
|
-
|
|
49
|
-
function resolvedParameter(
|
|
50
|
-
parameter: ParameterOrReference,
|
|
51
|
-
context: TransformContext,
|
|
52
|
-
): ParameterObject | undefined {
|
|
53
|
-
return "$ref" in parameter && parameter.$ref
|
|
54
|
-
? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)
|
|
55
|
-
: (parameter as ParameterObject);
|
|
26
|
+
/** A path's member, its key and its path item type for the overlap check. */
|
|
27
|
+
export interface PathMember {
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly member: IrMember;
|
|
30
|
+
readonly key: PathKey;
|
|
31
|
+
readonly type: IrType;
|
|
56
32
|
}
|
|
57
33
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
): void {
|
|
63
|
-
for (const parameter of parameters) {
|
|
64
|
-
const resolved = resolvedParameter(parameter, context);
|
|
65
|
-
if (resolved && resolved.in === "path") {
|
|
66
|
-
byName.set(resolved.name, resolved);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
34
|
+
/** The key of the parts: a plain URL, or a template with placeholders left. */
|
|
35
|
+
export function pathKeyOf(parts: readonly PathKeyPart[]): PathKey {
|
|
36
|
+
const plainUrl = plainUrlOf(parts);
|
|
37
|
+
return plainUrl === null ? { kind: "template", parts } : literalKey(plainUrl);
|
|
69
38
|
}
|
|
70
39
|
|
|
71
|
-
/**
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
addPathParameters(pathItem.parameters ?? [], byName, context);
|
|
78
|
-
for (const { operation: entry } of pathItemOperations(pathItem)) {
|
|
79
|
-
const operation = (entry as ReferenceSchema).$ref
|
|
80
|
-
? (context.refs.resolve((entry as ReferenceSchema).$ref) as OperationObject | undefined)
|
|
81
|
-
: (entry as OperationObject);
|
|
82
|
-
addPathParameters(operation?.parameters ?? [], byName, context);
|
|
40
|
+
/** The member of one key of a path: a property for a plain URL, else an index signature. */
|
|
41
|
+
function keyMember(url: string, parts: readonly PathKeyPart[], type: IrType, isReadonly: boolean) {
|
|
42
|
+
const key = pathKeyOf(parts);
|
|
43
|
+
if (key.kind === "literal") {
|
|
44
|
+
const member = irProperty(toPropertyName(key.url), type, { isReadonly });
|
|
45
|
+
return { url, member, key, type };
|
|
83
46
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
47
|
+
const member: IrMember = {
|
|
48
|
+
kind: "indexSignature",
|
|
49
|
+
parameterName: "path",
|
|
50
|
+
parameterType: irRaw(templateText(parts)),
|
|
51
|
+
type,
|
|
52
|
+
isReadonly,
|
|
53
|
+
comments: [],
|
|
54
|
+
};
|
|
55
|
+
return { url, member, key, type };
|
|
94
56
|
}
|
|
95
57
|
|
|
96
58
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
59
|
+
* Whether a key of the path at `url` is written. A URL that `${boolean}` keys give is not when it
|
|
60
|
+
* is taken already: by a path of the document, which OpenAPI matches before a template (Paths
|
|
61
|
+
* Object), or by the keys of an earlier path. A property written twice does not compile (TS2300).
|
|
62
|
+
* `takenUrls` starts with the document's URLs and gets each expanded URL, in document order.
|
|
100
63
|
*/
|
|
101
|
-
function
|
|
102
|
-
url
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
): PathKeyPart[] | null {
|
|
106
|
-
const found = url.match(PATH_PARAMETER_RE);
|
|
107
|
-
if (!found) {
|
|
108
|
-
return null;
|
|
64
|
+
export function isUntakenKey(url: string, key: PathKey, takenUrls: Set<string>): boolean {
|
|
65
|
+
const isExpandedUrl = key.kind === "literal" && key.url !== url;
|
|
66
|
+
if (!isExpandedUrl) {
|
|
67
|
+
return true;
|
|
109
68
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return { match, type: PLACEHOLDERS.get(schema?.type) ?? STRING_PLACEHOLDER };
|
|
114
|
-
});
|
|
115
|
-
return context.options.fixes.has(FIX.PATH_PARAM_TYPE_NAMES)
|
|
116
|
-
? splitTemplateParts(url, matches)
|
|
117
|
-
: replacedTemplateParts(url, matches);
|
|
69
|
+
const isTaken = takenUrls.has(key.url);
|
|
70
|
+
takenUrls.add(key.url);
|
|
71
|
+
return !isTaken;
|
|
118
72
|
}
|
|
119
73
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
* `${` in the URL could end the literal or open a placeholder, and add code to the generated file
|
|
123
|
-
* (intentional fix). So the text parts are escaped.
|
|
124
|
-
*/
|
|
125
|
-
function templateText(parts: readonly PathKeyPart[]): string {
|
|
126
|
-
const text = parts
|
|
127
|
-
.map((part) =>
|
|
128
|
-
part.kind === "text" ? escapeTemplateText(part.text) : placeholderText(part.type),
|
|
129
|
-
)
|
|
130
|
-
.join("");
|
|
131
|
-
return `\`${text}\``;
|
|
74
|
+
function withoutTakenUrls(url: string, members: readonly PathMember[], takenUrls: Set<string>) {
|
|
75
|
+
return members.filter(({ key }) => isUntakenKey(url, key, takenUrls));
|
|
132
76
|
}
|
|
133
77
|
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
readonly url: string;
|
|
137
|
-
readonly member: IrMember;
|
|
138
|
-
readonly key: PathKey;
|
|
139
|
-
readonly type: IrType;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function pathItemMember(
|
|
78
|
+
/** The members of a path: one, or one per key of its `${boolean}` placeholders. */
|
|
79
|
+
function pathItemMembers(
|
|
143
80
|
url: string,
|
|
144
81
|
pathItem: PathItemObject,
|
|
145
82
|
context: TransformContext,
|
|
146
|
-
): PathMember {
|
|
83
|
+
): PathMember[] {
|
|
147
84
|
const isReadonly = context.options.immutable;
|
|
148
|
-
const type = pathItemType(
|
|
85
|
+
const type = pathItemType(
|
|
86
|
+
pathItem,
|
|
87
|
+
{ path: appendPointer(ROOT_POINTER, ["paths", url]) },
|
|
88
|
+
context,
|
|
89
|
+
);
|
|
149
90
|
const parts =
|
|
150
91
|
context.options.pathParamsAsTypes && url.includes("{")
|
|
151
92
|
? pathTemplateParts(url, pathItem, context)
|
|
152
93
|
: null;
|
|
153
94
|
if (parts === null) {
|
|
154
95
|
const member = irProperty(toPropertyName(url), type, { isReadonly });
|
|
155
|
-
return { url, member, key: literalKey(url), type };
|
|
96
|
+
return [{ url, member, key: literalKey(url), type }];
|
|
156
97
|
}
|
|
157
|
-
|
|
158
|
-
kind: "indexSignature",
|
|
159
|
-
parameterName: "path",
|
|
160
|
-
parameterType: irRaw(templateText(parts)),
|
|
161
|
-
type,
|
|
162
|
-
isReadonly,
|
|
163
|
-
comments: [],
|
|
164
|
-
};
|
|
165
|
-
return { url, member, key: { kind: "template", parts }, type };
|
|
98
|
+
return booleanExpandedKeys(parts).map((key) => keyMember(url, key, type, isReadonly));
|
|
166
99
|
}
|
|
167
100
|
|
|
168
101
|
function literalKey(url: string): PathKey {
|
|
@@ -244,6 +177,7 @@ export function pathsObjectType(
|
|
|
244
177
|
/** The members of the `paths` interface (OpenAPI 3.1 §4.8.8): one per path, by URL. */
|
|
245
178
|
export function pathMembers(paths: PathsObject, context: TransformContext): PathMember[] {
|
|
246
179
|
const members: PathMember[] = [];
|
|
180
|
+
const takenUrls = new Set(Object.keys(paths));
|
|
247
181
|
for (const [url, pathItem] of documentEntries(paths, context.options)) {
|
|
248
182
|
if (!pathItem || typeof pathItem !== "object") {
|
|
249
183
|
continue;
|
|
@@ -255,10 +189,10 @@ export function pathMembers(paths: PathsObject, context: TransformContext): Path
|
|
|
255
189
|
continue;
|
|
256
190
|
}
|
|
257
191
|
const startedAt = context.diagnostics.now();
|
|
258
|
-
const
|
|
259
|
-
members.push(
|
|
192
|
+
const pathMembersOfUrl = pathItemMembers(url, pathItem, context);
|
|
193
|
+
members.push(...withoutTakenUrls(url, pathMembersOfUrl, takenUrls));
|
|
260
194
|
// The original reports only paths written as properties.
|
|
261
|
-
if (
|
|
195
|
+
if (pathMembersOfUrl[0]?.key.kind === "literal" && pathMembersOfUrl[0].key.url === url) {
|
|
262
196
|
context.diagnostics.debug(`Transformed path "${url}"`, context.diagnostics.now() - startedAt);
|
|
263
197
|
}
|
|
264
198
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { irReference } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import {
|
|
4
|
+
appendPointer,
|
|
5
|
+
parseRefPointer,
|
|
6
|
+
ROOT_POINTER,
|
|
7
|
+
} from "../../../domain/openapi/json-pointer.js";
|
|
8
|
+
import type { OperationObject } from "../../../domain/openapi/operation-object.js";
|
|
9
|
+
import {
|
|
10
|
+
type ParameterObject,
|
|
11
|
+
type ParameterOrReference,
|
|
12
|
+
QUERYSTRING_LOCATION,
|
|
13
|
+
} from "../../../domain/openapi/parameter-object.js";
|
|
14
|
+
import {
|
|
15
|
+
ADDITIONAL_OPERATIONS_KEY,
|
|
16
|
+
HTTP_METHODS,
|
|
17
|
+
type PathItemObject,
|
|
18
|
+
QUERY_METHOD,
|
|
19
|
+
} from "../../../domain/openapi/path-item-object.js";
|
|
20
|
+
import { indexBy, refType } from "../ref-type.js";
|
|
21
|
+
import type { RefResolver } from "../schema/schema-context.js";
|
|
22
|
+
import type { TransformContext } from "../transform-context.js";
|
|
23
|
+
import { mergedParameters, type ParameterEntry, parameterEntries } from "./parameter-entries.js";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The type of a parameter `$ref`. The original indexed the parameter's location and name
|
|
27
|
+
* (`refType`): `#/paths/~1a/get/parameters/0` gave
|
|
28
|
+
* `paths["/a"]["get"]["parameters"]["query"]["q"]`.
|
|
29
|
+
* Where the generated type differs, that does not compile, and only there it changes:
|
|
30
|
+
*
|
|
31
|
+
* - A location whose parameters are all optional is an optional member (`query?:`), so indexing it
|
|
32
|
+
* fails (TS2339); it is wrapped in `NonNullable` before the name is indexed.
|
|
33
|
+
* - An OpenAPI 3.2 `in: querystring` parameter is the whole `query` member (ADR-020), not a member
|
|
34
|
+
* `querystring`, so the pointer reads `["query"]`.
|
|
35
|
+
*
|
|
36
|
+
* A `$ref` to a component parameter, or into a list the generator types elsewhere (a `$ref` path
|
|
37
|
+
* item or operation, a callback), keeps the original type.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const INDEX_RE = /^\d+$/;
|
|
41
|
+
const OPERATION_KEYS: ReadonlySet<string> = new Set([...HTTP_METHODS, QUERY_METHOD]);
|
|
42
|
+
|
|
43
|
+
/** A `parameters/N` pointer, split into its root and the segments of the list's owner. */
|
|
44
|
+
interface ParameterListPointer {
|
|
45
|
+
readonly root: string;
|
|
46
|
+
readonly owner: readonly string[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function listPointerOf(ref: string): ParameterListPointer | null {
|
|
50
|
+
if (!ref.startsWith(`${ROOT_POINTER}/`)) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const [root, ...segments] = parseRefPointer(ref);
|
|
54
|
+
const [list, position] = segments.slice(-2);
|
|
55
|
+
const isList = list === "parameters" && position !== undefined && INDEX_RE.test(position);
|
|
56
|
+
return root !== undefined && isList ? { root, owner: segments.slice(0, -2) } : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function pointerTo(root: string, segments: readonly string[]): string {
|
|
60
|
+
return appendPointer(ROOT_POINTER, [root, ...segments]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Whether the segments name a path item that `pathItemType` types in place. */
|
|
64
|
+
function isPathItemAt(root: string, segments: readonly string[]): boolean {
|
|
65
|
+
const isNamedRoot = root === "paths" || root === "webhooks";
|
|
66
|
+
return (
|
|
67
|
+
(isNamedRoot && segments.length === 1) ||
|
|
68
|
+
(root === "components" && segments[0] === "pathItems" && segments.length === 2)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The segments of the path item that holds the operation at `owner`, or null. */
|
|
73
|
+
function pathItemOfOperation(root: string, owner: readonly string[]): readonly string[] | null {
|
|
74
|
+
const method = owner.at(-1) ?? "";
|
|
75
|
+
if (OPERATION_KEYS.has(method) && isPathItemAt(root, owner.slice(0, -1))) {
|
|
76
|
+
return owner.slice(0, -1);
|
|
77
|
+
}
|
|
78
|
+
const isAdditional = owner.at(-2) === ADDITIONAL_OPERATIONS_KEY;
|
|
79
|
+
return isAdditional && isPathItemAt(root, owner.slice(0, -2)) ? owner.slice(0, -2) : null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function documentNode<T>(refs: RefResolver, root: string, segments: readonly string[]): T | null {
|
|
83
|
+
const node = refs.resolve(pointerTo(root, segments));
|
|
84
|
+
const isTypedHere = typeof node === "object" && node !== null && !("$ref" in node);
|
|
85
|
+
return isTypedHere ? (node as T) : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The parameters the generator types at the list's owner; null where it types them elsewhere. */
|
|
89
|
+
function typedParameters(
|
|
90
|
+
pointer: ParameterListPointer,
|
|
91
|
+
refs: RefResolver,
|
|
92
|
+
): readonly ParameterOrReference[] | null {
|
|
93
|
+
const { root, owner } = pointer;
|
|
94
|
+
if (isPathItemAt(root, owner)) {
|
|
95
|
+
return documentNode<PathItemObject>(refs, root, owner)?.parameters ?? null;
|
|
96
|
+
}
|
|
97
|
+
const pathItemSegments = pathItemOfOperation(root, owner);
|
|
98
|
+
const pathItem = pathItemSegments && documentNode<PathItemObject>(refs, root, pathItemSegments);
|
|
99
|
+
const operation = pathItem && documentNode<OperationObject>(refs, root, owner);
|
|
100
|
+
return pathItem && operation ? mergedParameters(pathItem, operation, refs) : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A location member is optional when none of its parameters is required (`locationParts`). */
|
|
104
|
+
function isLocationOptional(entries: readonly ParameterEntry[], location: string): boolean {
|
|
105
|
+
return entries
|
|
106
|
+
.filter((entry) => entry.resolved?.in === location)
|
|
107
|
+
.every((entry) => location !== "path" && !entry.resolved?.required);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The corrected type, or null where the original type compiles or no correction applies. */
|
|
111
|
+
function correctedType(
|
|
112
|
+
listType: IrType,
|
|
113
|
+
entries: readonly ParameterEntry[],
|
|
114
|
+
parameter: ParameterObject,
|
|
115
|
+
): IrType | null {
|
|
116
|
+
if (parameter.in === QUERYSTRING_LOCATION) {
|
|
117
|
+
// Next to `in: query` parameters it is not in the generated types (QUERYSTRING_NEXT_TO_QUERY).
|
|
118
|
+
const isTyped = !entries.some((entry) => entry.resolved?.in === "query");
|
|
119
|
+
return isTyped ? indexBy(listType, "query") : null;
|
|
120
|
+
}
|
|
121
|
+
if (!isLocationOptional(entries, parameter.in)) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const location = irReference("NonNullable", [indexBy(listType, parameter.in)]);
|
|
125
|
+
return indexBy(location, parameter.name);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The type of a parameter `$ref` whose target resolved to `resolved`; see the module comment. */
|
|
129
|
+
export function referencedParameterType(
|
|
130
|
+
ref: string,
|
|
131
|
+
resolved: ParameterObject,
|
|
132
|
+
context: TransformContext,
|
|
133
|
+
): IrType {
|
|
134
|
+
// A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.
|
|
135
|
+
if ((resolved as { $ref?: unknown }).$ref) {
|
|
136
|
+
return refType(ref, { parameter: null });
|
|
137
|
+
}
|
|
138
|
+
const original = refType(ref, { parameter: { in: resolved.in, name: resolved.name } });
|
|
139
|
+
const pointer = listPointerOf(ref);
|
|
140
|
+
const parameters = pointer && typedParameters(pointer, context.refs);
|
|
141
|
+
if (pointer === null || parameters === null) {
|
|
142
|
+
return original;
|
|
143
|
+
}
|
|
144
|
+
const listType = refType(pointerTo(pointer.root, [...pointer.owner, "parameters"]));
|
|
145
|
+
return correctedType(listType, parameterEntries(parameters, context), resolved) ?? original;
|
|
146
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { irKeyword, irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
-
import {
|
|
4
|
+
import { appendPointer } from "../../../domain/openapi/json-pointer.js";
|
|
5
5
|
import type { RequestBodyObject } from "../../../domain/openapi/request-body-object.js";
|
|
6
6
|
import { documentEntries } from "../document-entries.js";
|
|
7
7
|
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
@@ -18,7 +18,7 @@ function contentMembers(
|
|
|
18
18
|
): IrMember[] {
|
|
19
19
|
const entries = documentEntries(requestBody.content ?? {}, context.options);
|
|
20
20
|
return entries.map(([contentType, entry]) => {
|
|
21
|
-
const path =
|
|
21
|
+
const path = appendPointer(location.path, ["content", contentType]);
|
|
22
22
|
const type = contentEntryType(entry, { ...location, path }, context);
|
|
23
23
|
return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
|
|
24
24
|
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../../../domain/ir/constructors.js";
|
|
7
7
|
import type { IrMember, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
8
8
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
9
|
-
import {
|
|
9
|
+
import { appendPointer } from "../../../domain/openapi/json-pointer.js";
|
|
10
10
|
import {
|
|
11
11
|
isMediaTypeComponentRef,
|
|
12
12
|
type MediaTypeObject,
|
|
@@ -34,7 +34,7 @@ function headerMember(
|
|
|
34
34
|
? refType(header.$ref)
|
|
35
35
|
: headerType(
|
|
36
36
|
header,
|
|
37
|
-
{ ...location, path:
|
|
37
|
+
{ ...location, path: appendPointer(location.path, ["headers", name]) },
|
|
38
38
|
context,
|
|
39
39
|
);
|
|
40
40
|
return documentMember(name, type, header, {
|
|
@@ -79,7 +79,7 @@ function contentMember(
|
|
|
79
79
|
): IrPropertySignature {
|
|
80
80
|
const entries = documentEntries(response.content ?? {}, context.options);
|
|
81
81
|
const members = entries.map(([contentType, entry]) => {
|
|
82
|
-
const path =
|
|
82
|
+
const path = appendPointer(location.path, ["content", contentType]);
|
|
83
83
|
const type = mediaTypeEntryType(entry, { ...location, path }, context);
|
|
84
84
|
return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
|
|
85
85
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { irKeyword, irObject } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
-
import {
|
|
3
|
+
import { appendPointer } from "../../../domain/openapi/json-pointer.js";
|
|
4
4
|
import type { ResponsesObject } from "../../../domain/openapi/response-object.js";
|
|
5
5
|
import { documentEntries } from "../document-entries.js";
|
|
6
6
|
import { refType } from "../ref-type.js";
|
|
@@ -20,7 +20,7 @@ export function responsesType(
|
|
|
20
20
|
? refType(response.$ref)
|
|
21
21
|
: responseType(
|
|
22
22
|
response,
|
|
23
|
-
{ ...location, path:
|
|
23
|
+
{ ...location, path: appendPointer(location.path, ["responses", code]) },
|
|
24
24
|
context,
|
|
25
25
|
);
|
|
26
26
|
return documentMember(code, type, response, { isReadonly: context.options.immutable });
|
|
@@ -2,6 +2,8 @@ import { irRaw } from "../../../domain/ir/constructors.js";
|
|
|
2
2
|
import type { IrDeclaration, IrTypeAliasDeclaration } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { escapeSingleQuotedText } from "../../../domain/ir/raw-text-escapes.js";
|
|
4
4
|
import type { ComponentKind } from "../../../domain/openapi/components-object.js";
|
|
5
|
+
import { freeNumberedName } from "../numbered-names.js";
|
|
6
|
+
import { typeNamesDeclaredBy } from "./declared-type-names.js";
|
|
5
7
|
import { globalTypeReferences } from "./global-type-references.js";
|
|
6
8
|
|
|
7
9
|
/** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */
|
|
@@ -25,7 +27,8 @@ export function rootTypeAlias(
|
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
/** Whether the declaration is a `--root-types` alias, which gives way to every other name. */
|
|
31
|
+
export function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {
|
|
29
32
|
return (
|
|
30
33
|
declaration.kind === "typeAlias" &&
|
|
31
34
|
declaration.type.kind === "raw" &&
|
|
@@ -33,23 +36,6 @@ function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAlias
|
|
|
33
36
|
);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
/**
|
|
37
|
-
* The type names the footer declares that an alias must not take: enums, and helper types such as
|
|
38
|
-
* `WithRequired`. Value declarations (`--enum-values` arrays) live in another namespace.
|
|
39
|
-
*/
|
|
40
|
-
function footerTypeNames(declarations: readonly IrDeclaration[]): Set<string> {
|
|
41
|
-
return new Set(
|
|
42
|
-
declarations.flatMap((declaration) => {
|
|
43
|
-
if (declaration.kind === "enum") {
|
|
44
|
-
return [declaration.name];
|
|
45
|
-
}
|
|
46
|
-
return declaration.kind === "rawDeclaration" && declaration.name !== undefined
|
|
47
|
-
? [declaration.name]
|
|
48
|
-
: [];
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
39
|
function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
|
|
54
40
|
return new Set(
|
|
55
41
|
declarations.flatMap((declaration) =>
|
|
@@ -58,21 +44,15 @@ function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
|
|
|
58
44
|
);
|
|
59
45
|
}
|
|
60
46
|
|
|
61
|
-
function freeName(name: string, taken: ReadonlySet<string>): string {
|
|
62
|
-
let candidate = `${name}_2`;
|
|
63
|
-
for (let counter = 3; taken.has(candidate); counter++) {
|
|
64
|
-
candidate = `${name}_${counter}`;
|
|
65
|
-
}
|
|
66
|
-
return candidate;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
47
|
/**
|
|
70
|
-
* Rename each root alias whose name
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
48
|
+
* Rename each root alias whose name another declaration of the output also takes (an enum, a
|
|
49
|
+
* helper type, the `--make-paths-enum` enum `ApiPaths`, a root interface, `--read-write-markers`
|
|
50
|
+
* or `inject` types), or that shadows a TypeScript global type the output refers to (`Record` in
|
|
51
|
+
* `Record<string, never>`), to the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses
|
|
52
|
+
* for its own conflicts). The others and the globals keep their names, because the generated
|
|
53
|
+
* types refer to them. Before, the output did not compile (enums: upstream #2099, #2341, #2206;
|
|
54
|
+
* helpers: a schema named `WithRequired`, roadmap R11; globals: TS2315; `ApiPaths`: TS2567).
|
|
55
|
+
* Other declarations are returned unchanged.
|
|
76
56
|
*
|
|
77
57
|
* With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the
|
|
78
58
|
* aliases a later schema of one exported name took the name from, after the other aliases and
|
|
@@ -85,11 +65,10 @@ export function renameTakenAliases<T extends IrDeclaration>(
|
|
|
85
65
|
footer: readonly IrDeclaration[],
|
|
86
66
|
closing: readonly IrDeclaration[] = [],
|
|
87
67
|
): T[] {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const taken = declaredNames([...body, ...footer, ...closing]);
|
|
68
|
+
const all = [...body, ...footer, ...closing];
|
|
69
|
+
const others = all.filter((declaration) => !isRootTypeAlias(declaration));
|
|
70
|
+
const reserved = new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);
|
|
71
|
+
const taken = new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);
|
|
93
72
|
const aliasNames = new Set<string>();
|
|
94
73
|
return body.map((declaration) => {
|
|
95
74
|
if (!isRootTypeAlias(declaration)) {
|
|
@@ -100,7 +79,7 @@ export function renameTakenAliases<T extends IrDeclaration>(
|
|
|
100
79
|
if (!isRepeated && !reserved.has(declaration.name)) {
|
|
101
80
|
return declaration;
|
|
102
81
|
}
|
|
103
|
-
const name =
|
|
82
|
+
const name = freeNumberedName(declaration.name, taken);
|
|
104
83
|
taken.add(name);
|
|
105
84
|
return { ...declaration, name };
|
|
106
85
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appendAll } from "../../../domain/append-all.js";
|
|
1
2
|
import type {
|
|
2
3
|
IrIndexSignature,
|
|
3
4
|
IrMember,
|
|
@@ -156,7 +157,7 @@ export class TypeResolution {
|
|
|
156
157
|
if (objects === null) {
|
|
157
158
|
return null;
|
|
158
159
|
}
|
|
159
|
-
parts
|
|
160
|
+
appendAll(parts, objects);
|
|
160
161
|
}
|
|
161
162
|
return parts;
|
|
162
163
|
}
|
|
@@ -1,22 +1,35 @@
|
|
|
1
1
|
import { irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
-
import {
|
|
4
|
+
import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
5
5
|
import type { PathItemObject, PathsObject } from "../../../domain/openapi/path-item-object.js";
|
|
6
6
|
import { documentEntries } from "../document-entries.js";
|
|
7
|
+
import { refType } from "../ref-type.js";
|
|
7
8
|
import type { TransformContext } from "../transform-context.js";
|
|
8
9
|
import { pathItemType } from "./path-item.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* The `webhooks` interface body (OpenAPI 3.1 §4.8.1): one path item per webhook name. A `$ref`
|
|
13
|
+
* entry (often to `components/pathItems`) is the type it points at, as in `paths`; the original
|
|
14
|
+
* read it as a path item, so every method was `never`. Members carry no JSDoc.
|
|
14
15
|
*/
|
|
15
16
|
export function webhooksType(webhooks: PathsObject, context: TransformContext): IrType {
|
|
16
17
|
const members = documentEntries(webhooks, context.options).map(([name, pathItem]) => {
|
|
17
|
-
const
|
|
18
|
-
const type = pathItemType(pathItem as PathItemObject, location, context);
|
|
18
|
+
const type = webhookType(name, pathItem, context);
|
|
19
19
|
return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
|
|
20
20
|
});
|
|
21
21
|
return irObject(members);
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
function webhookType(
|
|
25
|
+
name: string,
|
|
26
|
+
pathItem: PathsObject[string],
|
|
27
|
+
context: TransformContext,
|
|
28
|
+
): IrType {
|
|
29
|
+
// A document may hold any value here; one that is no object is read as a path item, as before.
|
|
30
|
+
if (typeof pathItem === "object" && pathItem !== null && "$ref" in pathItem) {
|
|
31
|
+
return refType(pathItem.$ref);
|
|
32
|
+
}
|
|
33
|
+
const location = { path: appendPointer(ROOT_POINTER, ["webhooks", name]) };
|
|
34
|
+
return pathItemType(pathItem as PathItemObject, location, context);
|
|
35
|
+
}
|