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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { IrDeclaration } from "../../../domain/ir/nodes.js";
|
|
2
|
+
import { HELPER_TYPES, READ_WRITE_MARKER_TYPES } from "../helper-types.js";
|
|
3
|
+
import { typeNamesDeclaredBy, typeNamesInText } from "./declared-type-names.js";
|
|
4
|
+
import { OPERATIONS_NAME, ROOT_KEYS } from "./document.js";
|
|
5
|
+
import { GLOBAL_TYPE_NAMES, globalTypeReferences } from "./global-type-references.js";
|
|
6
|
+
import { API_PATHS_NAME } from "./paths-enum.js";
|
|
7
|
+
import { isRootTypeAlias } from "./root-type-aliases.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The second step of naming `--enum` declarations (`EnumNameClaims`): once the output is known,
|
|
11
|
+
* an enum that gave way to a name the output turned out not to need gets that name back.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The type names the output of a document may need, besides its enums: the global types it may
|
|
16
|
+
* refer to and the names the generator declares itself. An enum avoids them until the end.
|
|
17
|
+
*/
|
|
18
|
+
export const NAMES_THE_OUTPUT_MAY_NEED: ReadonlySet<string> = new Set([
|
|
19
|
+
...GLOBAL_TYPE_NAMES,
|
|
20
|
+
...Object.values(HELPER_TYPES).map(({ name }) => name),
|
|
21
|
+
...typeNamesInText(READ_WRITE_MARKER_TYPES),
|
|
22
|
+
API_PATHS_NAME,
|
|
23
|
+
...ROOT_KEYS,
|
|
24
|
+
OPERATIONS_NAME,
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
/** The parts of a transformed document; the footer holds only IR declarations here. */
|
|
28
|
+
export interface DocumentParts {
|
|
29
|
+
readonly body: readonly IrDeclaration[];
|
|
30
|
+
readonly footer: readonly IrDeclaration[];
|
|
31
|
+
readonly closing: readonly IrDeclaration[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The type names the output needs besides its enums: the globals it refers to, and the names of
|
|
36
|
+
* its other declarations. Root aliases give way to enums (`renameTakenAliases`), so they count
|
|
37
|
+
* for nothing.
|
|
38
|
+
*/
|
|
39
|
+
export function namesTheOutputNeeds({ body, footer, closing }: DocumentParts): Set<string> {
|
|
40
|
+
const others = [
|
|
41
|
+
...body.filter((declaration) => !isRootTypeAlias(declaration)),
|
|
42
|
+
...footer.filter((declaration) => declaration.kind !== "enum"),
|
|
43
|
+
...closing,
|
|
44
|
+
];
|
|
45
|
+
return new Set([
|
|
46
|
+
...globalTypeReferences([...body, ...footer, ...closing]),
|
|
47
|
+
...typeNamesDeclaredBy(others),
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** `origin` holds the compiler node a raw type was printed from; it is not IR. */
|
|
52
|
+
const SKIPPED_KEYS: ReadonlySet<string> = new Set(["origin"]);
|
|
53
|
+
|
|
54
|
+
/** The enum references the generator writes: `Name`, `Name.member` and `typeof Name`. */
|
|
55
|
+
const ENUM_REFERENCE_RE = /^(typeof )?([^.]+)(\..*)?$/s;
|
|
56
|
+
|
|
57
|
+
function renamedReference(name: string, renames: ReadonlyMap<string, string>): string {
|
|
58
|
+
const match = ENUM_REFERENCE_RE.exec(name);
|
|
59
|
+
const renamed = match === null ? undefined : renames.get(match[2] ?? "");
|
|
60
|
+
return renamed === undefined ? name : `${match?.[1] ?? ""}${renamed}${match?.[3] ?? ""}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isNode(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
64
|
+
return typeof value === "object" && value !== null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function renamedNode(value: unknown, renames: ReadonlyMap<string, string>): unknown {
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
return value.map((item) => renamedNode(item, renames));
|
|
70
|
+
}
|
|
71
|
+
if (!isNode(value)) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
const node = Object.fromEntries(
|
|
75
|
+
Object.entries(value).map(([key, child]) => [
|
|
76
|
+
key,
|
|
77
|
+
SKIPPED_KEYS.has(key) ? child : renamedNode(child, renames),
|
|
78
|
+
]),
|
|
79
|
+
);
|
|
80
|
+
const isNamed =
|
|
81
|
+
(node.kind === "reference" || node.kind === "enum") && typeof node.name === "string";
|
|
82
|
+
return isNamed ? { ...node, name: renamedReference(node.name as string, renames) } : node;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The declarations with each enum in `renames` (old name to new) renamed, references too. */
|
|
86
|
+
export function withEnumsRenamed<T extends IrDeclaration>(
|
|
87
|
+
declarations: readonly T[],
|
|
88
|
+
renames: ReadonlyMap<string, string>,
|
|
89
|
+
): T[] {
|
|
90
|
+
return renames.size === 0 ? [...declarations] : (renamedNode(declarations, renames) as T[]);
|
|
91
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
|
|
2
|
+
import type { Schema } from "../../../domain/openapi/schema-object.js";
|
|
3
|
+
import { transformSchema } from "../schema/schema-transform.js";
|
|
4
|
+
import type { TransformContext } from "../transform-context.js";
|
|
5
|
+
import { unionOf } from "../type-combinators.js";
|
|
6
|
+
import type { ResolvedEntry } from "./parameter-entries.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `exploded-query-objects` and index signatures. The keys of an exploded object are keys of
|
|
10
|
+
* `query`, next to the other parameters. TypeScript checks an index signature against every key
|
|
11
|
+
* of a value, so `{ page?: number } & { [key: string]: string }` admits no `page`, and no value
|
|
12
|
+
* with another parameter at all. An index signature of an exploded object therefore also takes
|
|
13
|
+
* the value types of the other keys of `query`: those keys carry their own values.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function refOf(value: unknown): string | undefined {
|
|
17
|
+
const ref = (value as { $ref?: unknown } | undefined)?.$ref;
|
|
18
|
+
return typeof ref === "string" ? ref : undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A schema `$ref` chain followed to its end, with the pointer where that schema is declared. */
|
|
22
|
+
function declaredSchema(schema: Schema | undefined, ref: string, context: TransformContext) {
|
|
23
|
+
let declared = { schema, path: ref };
|
|
24
|
+
const seen = new Set<string>();
|
|
25
|
+
for (let next = refOf(schema); next !== undefined && !seen.has(next); ) {
|
|
26
|
+
seen.add(next);
|
|
27
|
+
declared = { schema: context.refs.resolve(next) as Schema | undefined, path: next };
|
|
28
|
+
next = refOf(declared.schema);
|
|
29
|
+
}
|
|
30
|
+
return declared;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The type of an exploded parameter whose own type is a reference (its `$ref`, or the `$ref` of
|
|
35
|
+
* its schema), written out where its schema is declared: the index signature of a referenced type
|
|
36
|
+
* cannot be changed. The location is the one `components` types it at, so the enums it declares
|
|
37
|
+
* are the ones the reference names. Null when no `$ref` is involved.
|
|
38
|
+
*/
|
|
39
|
+
export function declaredObjectType(entry: ResolvedEntry, context: TransformContext): IrType | null {
|
|
40
|
+
const { original, resolved } = entry;
|
|
41
|
+
const schemaRef = refOf(resolved.schema);
|
|
42
|
+
if (schemaRef !== undefined) {
|
|
43
|
+
const { schema, path } = declaredSchema(resolved.schema, schemaRef, context);
|
|
44
|
+
return transformSchema(schema, { path, schema }, context);
|
|
45
|
+
}
|
|
46
|
+
const parameterRef = refOf(original);
|
|
47
|
+
return parameterRef === undefined
|
|
48
|
+
? null
|
|
49
|
+
: transformSchema(resolved.schema, { path: parameterRef, schema: resolved }, context);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isIndexSignature(member: IrMember): boolean {
|
|
53
|
+
return member.kind === "indexSignature";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Whether the type has an index signature in its objects, through unions and intersections. */
|
|
57
|
+
export function hasIndexSignature(type: IrType): boolean {
|
|
58
|
+
switch (type.kind) {
|
|
59
|
+
case "object":
|
|
60
|
+
return type.members.some(isIndexSignature);
|
|
61
|
+
case "union":
|
|
62
|
+
case "intersection":
|
|
63
|
+
return type.types.some(hasIndexSignature);
|
|
64
|
+
default:
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function widenedMember(member: IrMember, values: readonly IrType[]): IrMember {
|
|
70
|
+
// `unknown` takes every value already.
|
|
71
|
+
const isUnknown = member.type.kind === "keyword" && member.type.keyword === "unknown";
|
|
72
|
+
return isIndexSignature(member) && !isUnknown
|
|
73
|
+
? { ...member, type: unionOf([member.type, ...values]) }
|
|
74
|
+
: member;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The type with the values added to each index signature of its objects. */
|
|
78
|
+
export function withIndexValues(type: IrType, values: readonly IrType[]): IrType {
|
|
79
|
+
switch (type.kind) {
|
|
80
|
+
case "object":
|
|
81
|
+
return { ...type, members: type.members.map((member) => widenedMember(member, values)) };
|
|
82
|
+
case "union":
|
|
83
|
+
case "intersection":
|
|
84
|
+
return { ...type, types: type.types.map((member) => withIndexValues(member, values)) };
|
|
85
|
+
default:
|
|
86
|
+
return type;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -6,7 +6,7 @@ import type { IrDeclaration } from "../../../domain/ir/nodes.js";
|
|
|
6
6
|
* (`Exclude<…>`, `Readonly<…>`). A module declaration of the same name shadows the global: every
|
|
7
7
|
* use of it then fails to compile, or silently names the module's type (`Blob`).
|
|
8
8
|
*/
|
|
9
|
-
const GLOBAL_TYPE_NAMES: ReadonlySet<string> = new Set([
|
|
9
|
+
export const GLOBAL_TYPE_NAMES: ReadonlySet<string> = new Set([
|
|
10
10
|
"Array",
|
|
11
11
|
"Blob",
|
|
12
12
|
"Exclude",
|
|
@@ -2,6 +2,8 @@ import { irObject } from "../../../domain/ir/constructors.js";
|
|
|
2
2
|
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import type { HeaderObject } from "../../../domain/openapi/header-object.js";
|
|
4
4
|
import { escapePointerSegment } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import type { ContentMap } from "../../../domain/openapi/media-type-object.js";
|
|
6
|
+
import { FIX } from "../../../domain/output-fixes.js";
|
|
5
7
|
import { documentEntries } from "../document-entries.js";
|
|
6
8
|
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
7
9
|
import { transformSchema } from "../schema/schema-transform.js";
|
|
@@ -10,8 +12,10 @@ import { documentMember } from "./document-member.js";
|
|
|
10
12
|
import { contentEntryType } from "./media-type.js";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
|
-
* A header's type (OpenAPI 3.1 §4.8.21): its schema, else
|
|
14
|
-
*
|
|
15
|
+
* A header's type (OpenAPI 3.1 §4.8.21): its schema, else the type of its `content`, else
|
|
16
|
+
* `unknown`. `content` holds one media type whose schema describes the value; the original typed
|
|
17
|
+
* it as an object with one property per media type, which the `parameter-header-content` fix
|
|
18
|
+
* replaces by the media type's type, as for a parameter.
|
|
15
19
|
*/
|
|
16
20
|
export function headerType(
|
|
17
21
|
header: HeaderObject,
|
|
@@ -24,11 +28,27 @@ export function headerType(
|
|
|
24
28
|
if (!header.content) {
|
|
25
29
|
return UNKNOWN_TYPE;
|
|
26
30
|
}
|
|
31
|
+
if (context.options.fixes.has(FIX.PARAMETER_HEADER_CONTENT)) {
|
|
32
|
+
// The first media type in document order, as for a parameter: `--alphabetize` sorts only
|
|
33
|
+
// the members it writes.
|
|
34
|
+
const first = Object.entries(header.content)[0];
|
|
35
|
+
return first === undefined ? UNKNOWN_TYPE : mediaType(...first, location, context);
|
|
36
|
+
}
|
|
27
37
|
const members = documentEntries(header.content, context.options).map(([contentType, entry]) => {
|
|
28
|
-
|
|
29
|
-
const path = `${location.path ?? "#"}/${escapePointerSegment(contentType)}`;
|
|
30
|
-
const type = contentEntryType(entry, { ...location, path }, context);
|
|
38
|
+
const type = mediaType(contentType, entry, location, context);
|
|
31
39
|
return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
|
|
32
40
|
});
|
|
33
41
|
return irObject(members);
|
|
34
42
|
}
|
|
43
|
+
|
|
44
|
+
/** The type of one media type of a header, at the path the original gave it. */
|
|
45
|
+
function mediaType(
|
|
46
|
+
contentType: string,
|
|
47
|
+
entry: ContentMap[string],
|
|
48
|
+
location: SchemaLocation,
|
|
49
|
+
context: SchemaContext,
|
|
50
|
+
): IrType {
|
|
51
|
+
// Unlike other content maps, the original joins this path by hand: a missing path is `#`.
|
|
52
|
+
const path = `${location.path ?? "#"}/${escapePointerSegment(contentType)}`;
|
|
53
|
+
return contentEntryType(entry, { ...location, path }, context);
|
|
54
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
-
import { createRef } from "../../../domain/openapi/json-pointer.js";
|
|
4
|
+
import { appendPointer, createRef } from "../../../domain/openapi/json-pointer.js";
|
|
5
5
|
import {
|
|
6
6
|
type ContentMap,
|
|
7
7
|
isMediaTypeComponentRef,
|
|
@@ -48,9 +48,10 @@ function itemSchemaAt(
|
|
|
48
48
|
const resolved = isMediaTypeComponentRef(entry.$ref)
|
|
49
49
|
? (context.refs.resolve(entry.$ref) as MediaTypeObject | undefined)
|
|
50
50
|
: undefined;
|
|
51
|
+
// `createRef` reads the `$ref` itself as a pointer; only the constant segment is appended.
|
|
51
52
|
return { schema: resolved?.itemSchema, path: createRef([entry.$ref, "itemSchema"]) };
|
|
52
53
|
}
|
|
53
|
-
return { schema: entry.itemSchema, path:
|
|
54
|
+
return { schema: entry.itemSchema, path: appendPointer(path, ["itemSchema"]) };
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -64,7 +65,7 @@ export function itemContentMember(
|
|
|
64
65
|
flags: { readonly isReadonly: boolean },
|
|
65
66
|
): IrPropertySignature | null {
|
|
66
67
|
const members = documentEntries(content, context.options).flatMap(([mediaType, entry]) => {
|
|
67
|
-
const contentPath =
|
|
68
|
+
const contentPath = appendPointer(location.path, ["content", mediaType]);
|
|
68
69
|
const item = itemSchemaAt(entry, contentPath, context);
|
|
69
70
|
if (item.schema === undefined) {
|
|
70
71
|
return [];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { appendAll } from "../../../domain/append-all.js";
|
|
2
|
+
import { operationKeyOf } from "./path-item.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Every `operations` key that an `operationId` in the document asks for, so that a repeated ID
|
|
6
|
+
* never gets a number another operation has as its own ID (`OperationKeys`). Operations can sit
|
|
7
|
+
* in `paths`, `webhooks`, `components.pathItems` and callbacks, so the whole document is read. A
|
|
8
|
+
* Link Object's `operationId` is read too; an extra name only makes a number skip it.
|
|
9
|
+
*/
|
|
10
|
+
export function operationKeysWritten(document: object): Set<string> {
|
|
11
|
+
const keys = new Set<string>();
|
|
12
|
+
const seen = new WeakSet<object>();
|
|
13
|
+
const pending: unknown[] = [document];
|
|
14
|
+
while (pending.length > 0) {
|
|
15
|
+
const value = pending.pop();
|
|
16
|
+
if (typeof value !== "object" || value === null || seen.has(value)) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
seen.add(value);
|
|
20
|
+
const { operationId } = value as { operationId?: unknown };
|
|
21
|
+
if (typeof operationId === "string") {
|
|
22
|
+
keys.add(operationKeyOf(operationId));
|
|
23
|
+
}
|
|
24
|
+
appendAll(pending, Object.values(value));
|
|
25
|
+
}
|
|
26
|
+
return keys;
|
|
27
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { irKeyword, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
2
|
import type { IrPropertySignature } 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 { OperationObject } from "../../../domain/openapi/operation-object.js";
|
|
6
6
|
import type { RequestBodyObject } from "../../../domain/openapi/request-body-object.js";
|
|
7
7
|
import { refType } from "../ref-type.js";
|
|
@@ -31,7 +31,7 @@ function requestBodyMember(
|
|
|
31
31
|
? refType(body.$ref)
|
|
32
32
|
: requestBodyType(
|
|
33
33
|
body,
|
|
34
|
-
{ ...location, path:
|
|
34
|
+
{ ...location, path: appendPointer(location.path, ["requestBody"]) },
|
|
35
35
|
context,
|
|
36
36
|
);
|
|
37
37
|
const resolved = isReference
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { OperationObject } from "../../../domain/openapi/operation-object.js";
|
|
2
|
+
import type {
|
|
3
|
+
ParameterObject,
|
|
4
|
+
ParameterOrReference,
|
|
5
|
+
} from "../../../domain/openapi/parameter-object.js";
|
|
6
|
+
import type { PathItemObject } from "../../../domain/openapi/path-item-object.js";
|
|
7
|
+
import type { SchemaObject } from "../../../domain/openapi/schema-object.js";
|
|
8
|
+
import type { RefResolver } from "../schema/schema-context.js";
|
|
9
|
+
import type { TransformContext } from "../transform-context.js";
|
|
10
|
+
|
|
11
|
+
/** A parameter as written in the document, and the object its `$ref` points to. */
|
|
12
|
+
export interface ParameterEntry {
|
|
13
|
+
readonly original: ParameterOrReference;
|
|
14
|
+
readonly resolved: ParameterObject | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** An entry whose `$ref` resolved, so its location and name are known. */
|
|
18
|
+
export type ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };
|
|
19
|
+
|
|
20
|
+
/** The parameter object itself, or the one its `$ref` points to. */
|
|
21
|
+
export function resolveParameter(
|
|
22
|
+
parameter: ParameterOrReference,
|
|
23
|
+
refs: RefResolver,
|
|
24
|
+
): ParameterObject | undefined {
|
|
25
|
+
return "$ref" in parameter
|
|
26
|
+
? (refs.resolve(parameter.$ref) as ParameterObject | undefined)
|
|
27
|
+
: parameter;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {
|
|
31
|
+
const schema = parameter?.schema as SchemaObject | undefined;
|
|
32
|
+
return Boolean(parameter?.deprecated || schema?.deprecated);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */
|
|
36
|
+
export function parameterEntries(
|
|
37
|
+
parameters: readonly ParameterOrReference[],
|
|
38
|
+
context: TransformContext,
|
|
39
|
+
): ParameterEntry[] {
|
|
40
|
+
const entries = parameters.map((original) => ({
|
|
41
|
+
original,
|
|
42
|
+
resolved: resolveParameter(original, context.refs),
|
|
43
|
+
}));
|
|
44
|
+
if (context.options.alphabetize) {
|
|
45
|
+
// Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.
|
|
46
|
+
entries.sort((left, right) =>
|
|
47
|
+
(left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? ""),
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return context.options.excludeDeprecated
|
|
51
|
+
? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))
|
|
52
|
+
: entries;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Path item parameters followed by the operation's, keyed by location and name, so an operation
|
|
57
|
+
* parameter replaces the path item parameter it redefines (upstream issue #1798).
|
|
58
|
+
*/
|
|
59
|
+
export function mergedParameters(
|
|
60
|
+
pathItem: PathItemObject,
|
|
61
|
+
operation: OperationObject,
|
|
62
|
+
refs: RefResolver,
|
|
63
|
+
): ParameterOrReference[] {
|
|
64
|
+
const byKey = new Map<string, ParameterOrReference>();
|
|
65
|
+
for (const parameter of [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])]) {
|
|
66
|
+
const resolved = resolveParameter(parameter, refs);
|
|
67
|
+
byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);
|
|
68
|
+
}
|
|
69
|
+
return [...byKey.values()];
|
|
70
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { irKeyword } 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 {
|
|
5
5
|
type ParameterObject,
|
|
6
6
|
QUERYSTRING_LOCATION,
|
|
7
7
|
} from "../../../domain/openapi/parameter-object.js";
|
|
8
|
+
import { FIX } from "../../../domain/output-fixes.js";
|
|
8
9
|
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
9
10
|
import { transformSchema } from "../schema/schema-transform.js";
|
|
10
11
|
import { contentEntryType } from "./media-type.js";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* A parameter typed by the schema of its one `content` media type. An `in: querystring` parameter
|
|
15
|
+
* (OpenAPI 3.2) is the whole query string (ADR-020); without a media type it is `string`, the
|
|
16
|
+
* query string as text. With the `parameter-header-content` fix, any other parameter with `content`
|
|
17
|
+
* (OpenAPI 3.0 and later, for a JSON value in a query parameter) is typed the same way.
|
|
15
18
|
*/
|
|
16
|
-
function
|
|
19
|
+
function contentParameterType(
|
|
17
20
|
parameter: ParameterObject,
|
|
18
21
|
location: SchemaLocation,
|
|
19
22
|
context: SchemaContext,
|
|
@@ -22,22 +25,31 @@ function querystringType(
|
|
|
22
25
|
if (mediaType === undefined || entry === undefined) {
|
|
23
26
|
return irKeyword("string");
|
|
24
27
|
}
|
|
25
|
-
const path =
|
|
28
|
+
const path = appendPointer(location.path, ["content", mediaType]);
|
|
26
29
|
return contentEntryType(entry, { ...location, path }, context);
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
function isTypedByContent(parameter: ParameterObject, context: SchemaContext): boolean {
|
|
33
|
+
if (parameter.in === QUERYSTRING_LOCATION) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
const hasContent = parameter.schema === undefined && parameter.content !== undefined;
|
|
37
|
+
return hasContent && context.options.fixes.has(FIX.PARAMETER_HEADER_CONTENT);
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:
|
|
31
|
-
* query, path, header and cookie values all arrive as text. `content` is read
|
|
32
|
-
* `in: querystring
|
|
42
|
+
* query, path, header and cookie values all arrive as text. `content` is read for
|
|
43
|
+
* `in: querystring`, and with the `parameter-header-content` fix for every parameter; without
|
|
44
|
+
* the fix other parameters with `content` keep the original's `string`.
|
|
33
45
|
*/
|
|
34
46
|
export function parameterType(
|
|
35
47
|
parameter: ParameterObject,
|
|
36
48
|
location: SchemaLocation,
|
|
37
49
|
context: SchemaContext,
|
|
38
50
|
): IrType {
|
|
39
|
-
if (parameter
|
|
40
|
-
return
|
|
51
|
+
if (isTypedByContent(parameter, context)) {
|
|
52
|
+
return contentParameterType(parameter, location, context);
|
|
41
53
|
}
|
|
42
54
|
return parameter.schema
|
|
43
55
|
? transformSchema(parameter.schema, location, context)
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../../../domain/ir/constructors.js";
|
|
8
8
|
import type { IrPropertyName, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
9
9
|
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
10
|
-
import {
|
|
10
|
+
import { appendPointer } from "../../../domain/openapi/json-pointer.js";
|
|
11
11
|
import {
|
|
12
12
|
PARAMETER_LOCATIONS,
|
|
13
13
|
type ParameterLocation,
|
|
@@ -15,36 +15,25 @@ import {
|
|
|
15
15
|
type ParameterOrReference,
|
|
16
16
|
QUERYSTRING_LOCATION,
|
|
17
17
|
} from "../../../domain/openapi/parameter-object.js";
|
|
18
|
-
import type { SchemaObject } from "../../../domain/openapi/schema-object.js";
|
|
19
18
|
import { FIX } from "../../../domain/output-fixes.js";
|
|
20
|
-
import {
|
|
19
|
+
import { declaredValueTypes } from "../declared-value-types.js";
|
|
21
20
|
import type { SchemaLocation } from "../schema/schema-context.js";
|
|
22
21
|
import { withSchemaComment } from "../schema-comment.js";
|
|
23
22
|
import type { TransformContext } from "../transform-context.js";
|
|
24
23
|
import { isExplodedQueryObject } from "./exploded-query.js";
|
|
24
|
+
import { declaredObjectType, hasIndexSignature, withIndexValues } from "./exploded-query-values.js";
|
|
25
25
|
import { parameterType } from "./parameter.js";
|
|
26
|
+
import {
|
|
27
|
+
type ParameterEntry,
|
|
28
|
+
parameterEntries,
|
|
29
|
+
type ResolvedEntry,
|
|
30
|
+
resolveParameter,
|
|
31
|
+
} from "./parameter-entries.js";
|
|
32
|
+
import { referencedParameterType } from "./referenced-parameter.js";
|
|
26
33
|
|
|
27
34
|
/** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */
|
|
28
35
|
const PATH_TEMPLATE_RE = /\{([^{}]+)\}/g;
|
|
29
36
|
|
|
30
|
-
/** A parameter as written in the document, and the object its `$ref` points to. */
|
|
31
|
-
interface ParameterEntry {
|
|
32
|
-
readonly original: ParameterOrReference;
|
|
33
|
-
readonly resolved: ParameterObject | undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** An entry whose `$ref` resolved, so its location and name are known. */
|
|
37
|
-
type ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };
|
|
38
|
-
|
|
39
|
-
function resolveParameter(
|
|
40
|
-
parameter: ParameterOrReference,
|
|
41
|
-
context: TransformContext,
|
|
42
|
-
): ParameterObject | undefined {
|
|
43
|
-
return "$ref" in parameter
|
|
44
|
-
? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)
|
|
45
|
-
: parameter;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
37
|
/** Required string parameters for every `{name}` in a path template. */
|
|
49
38
|
function pathTemplateParameters(path: string): ParameterObject[] {
|
|
50
39
|
return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({
|
|
@@ -67,7 +56,7 @@ function withPathTemplateParameters(
|
|
|
67
56
|
}
|
|
68
57
|
for (const parameter of pathTemplateParameters(location.path)) {
|
|
69
58
|
const isDefined = result.some((candidate) => {
|
|
70
|
-
const resolved = resolveParameter(candidate, context);
|
|
59
|
+
const resolved = resolveParameter(candidate, context.refs);
|
|
71
60
|
return resolved?.in === "path" && resolved.name === parameter.name;
|
|
72
61
|
});
|
|
73
62
|
if (!isDefined) {
|
|
@@ -77,31 +66,6 @@ function withPathTemplateParameters(
|
|
|
77
66
|
return result;
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
function isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {
|
|
81
|
-
const schema = parameter?.schema as SchemaObject | undefined;
|
|
82
|
-
return Boolean(parameter?.deprecated || schema?.deprecated);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */
|
|
86
|
-
function parameterEntries(
|
|
87
|
-
parameters: readonly ParameterOrReference[],
|
|
88
|
-
context: TransformContext,
|
|
89
|
-
): ParameterEntry[] {
|
|
90
|
-
const entries = parameters.map((original) => ({
|
|
91
|
-
original,
|
|
92
|
-
resolved: resolveParameter(original, context),
|
|
93
|
-
}));
|
|
94
|
-
if (context.options.alphabetize) {
|
|
95
|
-
// Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.
|
|
96
|
-
entries.sort((left, right) =>
|
|
97
|
-
(left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? ""),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
return context.options.excludeDeprecated
|
|
101
|
-
? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))
|
|
102
|
-
: entries;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
69
|
/** The original quotes a name that is not text (a missing name prints as `"undefined"`). */
|
|
106
70
|
function parameterName(name: unknown): IrPropertyName {
|
|
107
71
|
return typeof name === "string" || typeof name === "number"
|
|
@@ -109,21 +73,14 @@ function parameterName(name: unknown): IrPropertyName {
|
|
|
109
73
|
: { kind: "string", value: String(name) };
|
|
110
74
|
}
|
|
111
75
|
|
|
112
|
-
function referencedParameterType(ref: string, resolved: ParameterObject): IrType {
|
|
113
|
-
// A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.
|
|
114
|
-
const isParameter = !(resolved as { $ref?: unknown }).$ref;
|
|
115
|
-
const parameter = isParameter ? { in: resolved.in, name: resolved.name } : null;
|
|
116
|
-
return refType(ref, { parameter });
|
|
117
|
-
}
|
|
118
|
-
|
|
119
76
|
function entryType(
|
|
120
77
|
{ original, resolved }: ResolvedEntry,
|
|
121
78
|
location: SchemaLocation,
|
|
122
79
|
context: TransformContext,
|
|
123
80
|
): IrType {
|
|
124
|
-
const path =
|
|
81
|
+
const path = appendPointer(location.path, ["parameters", resolved.in, resolved.name]);
|
|
125
82
|
return "$ref" in original
|
|
126
|
-
? referencedParameterType(original.$ref, resolved)
|
|
83
|
+
? referencedParameterType(original.$ref, resolved, context)
|
|
127
84
|
: parameterType(resolved, { ...location, path }, context);
|
|
128
85
|
}
|
|
129
86
|
|
|
@@ -171,17 +128,50 @@ function isExplodedEntry(entry: ResolvedEntry, context: TransformContext): boole
|
|
|
171
128
|
);
|
|
172
129
|
}
|
|
173
130
|
|
|
131
|
+
/** An exploded object parameter with its type, typed in document order. */
|
|
132
|
+
interface ExplodedEntry {
|
|
133
|
+
readonly entry: ResolvedEntry;
|
|
134
|
+
readonly type: IrType;
|
|
135
|
+
}
|
|
136
|
+
|
|
174
137
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
138
|
+
* The object type of an exploded parameter, written out when it is a reference to a type with an
|
|
139
|
+
* index signature and `query` has other keys, which that signature must then admit. Without
|
|
140
|
+
* other keys the reference is kept.
|
|
177
141
|
*/
|
|
178
|
-
function
|
|
179
|
-
entry:
|
|
180
|
-
|
|
142
|
+
function explodedObjectType(
|
|
143
|
+
{ entry, type }: ExplodedEntry,
|
|
144
|
+
hasOtherKeys: boolean,
|
|
181
145
|
context: TransformContext,
|
|
182
146
|
): IrType {
|
|
183
|
-
|
|
184
|
-
|
|
147
|
+
if (!hasOtherKeys) {
|
|
148
|
+
return type;
|
|
149
|
+
}
|
|
150
|
+
const declared = declaredObjectType(entry, context);
|
|
151
|
+
return declared !== null && hasIndexSignature(declared) ? declared : type;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The exploded object parameters' parts of `query`: their object types, each index signature
|
|
156
|
+
* widened by the value types of the other keys (see `exploded-query-values.ts`). A parameter that
|
|
157
|
+
* may be left out sends none of its keys then, so they are optional: `Partial<…>`.
|
|
158
|
+
*/
|
|
159
|
+
function explodedParts(
|
|
160
|
+
exploded: readonly ExplodedEntry[],
|
|
161
|
+
members: readonly IrPropertySignature[],
|
|
162
|
+
context: TransformContext,
|
|
163
|
+
): IrType[] {
|
|
164
|
+
const hasOtherKeys = members.length > 0 || exploded.length > 1;
|
|
165
|
+
const types = exploded.map((part) => explodedObjectType(part, hasOtherKeys, context));
|
|
166
|
+
const others = (index: number) => [
|
|
167
|
+
...(members.length > 0 ? [irObject(members)] : []),
|
|
168
|
+
...types.filter((_type, other) => other !== index),
|
|
169
|
+
];
|
|
170
|
+
return types.map((type, index) => {
|
|
171
|
+
const values = others(index).flatMap((other) => declaredValueTypes(other, context.footer));
|
|
172
|
+
const widened = withIndexValues(type, values);
|
|
173
|
+
return exploded[index]?.entry.resolved.required ? widened : irReference("Partial", [widened]);
|
|
174
|
+
});
|
|
185
175
|
}
|
|
186
176
|
|
|
187
177
|
/** A location's parameters as members, and the object types of its exploded parameters. */
|
|
@@ -198,11 +188,11 @@ function locationParts(
|
|
|
198
188
|
context: TransformContext,
|
|
199
189
|
): LocationParts {
|
|
200
190
|
const members: IrPropertySignature[] = [];
|
|
201
|
-
const exploded:
|
|
191
|
+
const exploded: ExplodedEntry[] = [];
|
|
202
192
|
let isOptional = true;
|
|
203
193
|
for (const entry of entries) {
|
|
204
194
|
if (isExplodedEntry(entry, context)) {
|
|
205
|
-
exploded.push(
|
|
195
|
+
exploded.push({ entry, type: entryType(entry, location, context) });
|
|
206
196
|
isOptional &&= !entry.resolved.required;
|
|
207
197
|
continue;
|
|
208
198
|
}
|
|
@@ -210,7 +200,7 @@ function locationParts(
|
|
|
210
200
|
members.push(member);
|
|
211
201
|
isOptional &&= member.isOptional;
|
|
212
202
|
}
|
|
213
|
-
return { members, exploded, isOptional };
|
|
203
|
+
return { members, exploded: explodedParts(exploded, members, context), isOptional };
|
|
214
204
|
}
|
|
215
205
|
|
|
216
206
|
/** The members' object, intersected with the exploded parameters' types; `never` for none. */
|