openapi-typesafe 1.0.0-rc.0 → 1.0.0-rc.2
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/README.md +12 -5
- package/dist/adapters/redocly-loader/configured-headers.cjs +32 -0
- package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs +21 -2
- package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-config-source.mjs +22 -3
- package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +34 -11
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +33 -10
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +5 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +5 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs +15 -9
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs +15 -9
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs.map +1 -1
- package/dist/api/default-ports.cjs +9 -0
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +8 -1
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs +25 -0
- package/dist/api/discriminator-conflict-warnings.cjs.map +1 -0
- package/dist/api/discriminator-conflict-warnings.mjs +23 -0
- package/dist/api/discriminator-conflict-warnings.mjs.map +1 -0
- package/dist/api/discriminator-enum-names.cjs +19 -0
- package/dist/api/discriminator-enum-names.cjs.map +1 -0
- package/dist/api/discriminator-enum-names.mjs +17 -0
- package/dist/api/discriminator-enum-names.mjs.map +1 -0
- package/dist/api/discriminator-enum-parent.cjs +59 -0
- package/dist/api/discriminator-enum-parent.cjs.map +1 -0
- package/dist/api/discriminator-enum-parent.mjs +57 -0
- package/dist/api/discriminator-enum-parent.mjs.map +1 -0
- package/dist/api/discriminator-enum.cjs +25 -0
- package/dist/api/discriminator-enum.cjs.map +1 -1
- package/dist/api/discriminator-enum.mjs +25 -1
- package/dist/api/discriminator-enum.mjs.map +1 -1
- package/dist/api/discriminator-other-owners.cjs +67 -0
- package/dist/api/discriminator-other-owners.cjs.map +1 -0
- package/dist/api/discriminator-other-owners.mjs +64 -0
- package/dist/api/discriminator-other-owners.mjs.map +1 -0
- package/dist/api/discriminator-patch.cjs +92 -0
- package/dist/api/discriminator-patch.cjs.map +1 -0
- package/dist/api/discriminator-patch.mjs +86 -0
- package/dist/api/discriminator-patch.mjs.map +1 -0
- package/dist/api/discriminator-scan.cjs +50 -65
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +44 -59
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-refs.cjs +15 -12
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +15 -12
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +21 -4
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +22 -5
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/enum-values-warnings.cjs +16 -0
- package/dist/api/enum-values-warnings.cjs.map +1 -0
- package/dist/api/enum-values-warnings.mjs +14 -0
- package/dist/api/enum-values-warnings.mjs.map +1 -0
- package/dist/api/footer-sink.cjs +25 -2
- package/dist/api/footer-sink.cjs.map +1 -1
- package/dist/api/footer-sink.mjs +25 -2
- package/dist/api/footer-sink.mjs.map +1 -1
- package/dist/api/legacy-callback-warning.cjs +4 -1
- package/dist/api/legacy-callback-warning.cjs.map +1 -1
- package/dist/api/legacy-callback-warning.mjs +4 -1
- package/dist/api/legacy-callback-warning.mjs.map +1 -1
- package/dist/api/legacy-ts-helpers.cjs.map +1 -1
- package/dist/api/legacy-ts-helpers.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 +2 -1
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +3 -2
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/path-template-warnings.cjs +21 -0
- package/dist/api/path-template-warnings.cjs.map +1 -0
- package/dist/api/path-template-warnings.mjs +19 -0
- package/dist/api/path-template-warnings.mjs.map +1 -0
- package/dist/api/transform-context.cjs +4 -2
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +4 -2
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +52 -3
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +53 -4
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/api/unsupported-feature-warnings.cjs +6 -1
- package/dist/api/unsupported-feature-warnings.cjs.map +1 -1
- package/dist/api/unsupported-feature-warnings.mjs +6 -1
- package/dist/api/unsupported-feature-warnings.mjs.map +1 -1
- package/dist/application/print/type-printer.cjs +7 -1
- package/dist/application/print/type-printer.cjs.map +1 -1
- package/dist/application/print/type-printer.mjs +7 -1
- package/dist/application/print/type-printer.mjs.map +1 -1
- package/dist/application/transform/document/assignability.cjs +144 -0
- package/dist/application/transform/document/assignability.cjs.map +1 -0
- package/dist/application/transform/document/assignability.mjs +138 -0
- package/dist/application/transform/document/assignability.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +2 -2
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +4 -4
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/declared-types.cjs +66 -0
- package/dist/application/transform/document/declared-types.cjs.map +1 -0
- package/dist/application/transform/document/declared-types.mjs +63 -0
- package/dist/application/transform/document/declared-types.mjs.map +1 -0
- package/dist/application/transform/document/document.cjs +32 -9
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +34 -11
- package/dist/application/transform/document/document.mjs.map +1 -1
- package/dist/application/transform/document/exploded-query.cjs +46 -0
- package/dist/application/transform/document/exploded-query.cjs.map +1 -0
- package/dist/application/transform/document/exploded-query.mjs +43 -0
- package/dist/application/transform/document/exploded-query.mjs.map +1 -0
- package/dist/application/transform/document/global-type-references.cjs +63 -0
- package/dist/application/transform/document/global-type-references.cjs.map +1 -0
- package/dist/application/transform/document/global-type-references.mjs +61 -0
- package/dist/application/transform/document/global-type-references.mjs.map +1 -0
- package/dist/application/transform/document/list-assignability.cjs +54 -0
- package/dist/application/transform/document/list-assignability.cjs.map +1 -0
- package/dist/application/transform/document/list-assignability.mjs +52 -0
- package/dist/application/transform/document/list-assignability.mjs.map +1 -0
- package/dist/application/transform/document/parameters.cjs +41 -9
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +42 -10
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-key-overlaps.cjs +83 -33
- package/dist/application/transform/document/path-key-overlaps.cjs.map +1 -1
- package/dist/application/transform/document/path-key-overlaps.mjs +83 -33
- package/dist/application/transform/document/path-key-overlaps.mjs.map +1 -1
- package/dist/application/transform/document/path-template-replace.cjs +48 -0
- package/dist/application/transform/document/path-template-replace.cjs.map +1 -0
- package/dist/application/transform/document/path-template-replace.mjs +45 -0
- package/dist/application/transform/document/path-template-replace.mjs.map +1 -0
- package/dist/application/transform/document/paths.cjs +55 -29
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +54 -30
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.cjs +15 -14
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.mjs +15 -13
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
- package/dist/application/transform/document/template-key-match.cjs +128 -0
- package/dist/application/transform/document/template-key-match.cjs.map +1 -0
- package/dist/application/transform/document/template-key-match.mjs +125 -0
- package/dist/application/transform/document/template-key-match.mjs.map +1 -0
- package/dist/application/transform/document/type-assignability.cjs +192 -0
- package/dist/application/transform/document/type-assignability.cjs.map +1 -0
- package/dist/application/transform/document/type-assignability.mjs +190 -0
- package/dist/application/transform/document/type-assignability.mjs.map +1 -0
- package/dist/application/transform/document/type-key.cjs +70 -0
- package/dist/application/transform/document/type-key.cjs.map +1 -0
- package/dist/application/transform/document/type-key.mjs +68 -0
- package/dist/application/transform/document/type-key.mjs.map +1 -0
- package/dist/application/transform/document/type-resolution.cjs +131 -0
- package/dist/application/transform/document/type-resolution.cjs.map +1 -0
- package/dist/application/transform/document/type-resolution.mjs +125 -0
- package/dist/application/transform/document/type-resolution.mjs.map +1 -0
- package/dist/application/transform/footer/document-footer.cjs +66 -4
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +67 -5
- package/dist/application/transform/footer/document-footer.mjs.map +1 -1
- package/dist/application/transform/footer/enum-naming.cjs +17 -0
- package/dist/application/transform/footer/enum-naming.cjs.map +1 -1
- package/dist/application/transform/footer/enum-naming.mjs +17 -1
- package/dist/application/transform/footer/enum-naming.mjs.map +1 -1
- package/dist/application/transform/footer/enum-values-check.cjs +129 -0
- package/dist/application/transform/footer/enum-values-check.cjs.map +1 -0
- package/dist/application/transform/footer/enum-values-check.mjs +127 -0
- package/dist/application/transform/footer/enum-values-check.mjs.map +1 -0
- package/dist/application/transform/footer/evaluation.cjs +42 -0
- package/dist/application/transform/footer/evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/evaluation.mjs +33 -0
- package/dist/application/transform/footer/evaluation.mjs.map +1 -0
- package/dist/application/transform/footer/shared-enum-names.cjs +60 -0
- package/dist/application/transform/footer/shared-enum-names.cjs.map +1 -0
- package/dist/application/transform/footer/shared-enum-names.mjs +57 -0
- package/dist/application/transform/footer/shared-enum-names.mjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.cjs +138 -0
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.mjs +136 -0
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -0
- package/dist/application/transform/footer/type-indexing.cjs +107 -0
- package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
- package/dist/application/transform/footer/type-indexing.mjs +105 -0
- package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
- package/dist/application/transform/footer/type-rules.cjs +172 -0
- package/dist/application/transform/footer/type-rules.cjs.map +1 -0
- package/dist/application/transform/footer/type-rules.mjs +166 -0
- package/dist/application/transform/footer/type-rules.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-location.cjs +138 -0
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-location.mjs +136 -0
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-shape.cjs +171 -0
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/generated-shape.mjs +162 -0
- package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/inline-cycles.cjs +44 -0
- package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/inline-cycles.mjs +42 -0
- package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.cjs +62 -0
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.mjs +60 -0
- package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-type.cjs +60 -0
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-type.mjs +57 -0
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-walk.cjs +66 -0
- package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/pointer-walk.mjs +56 -0
- package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +124 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.mjs +122 -0
- package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -0
- package/dist/application/transform/ref-type.cjs +7 -2
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +3 -2
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs +38 -0
- package/dist/application/transform/schema/access-flags.cjs.map +1 -0
- package/dist/application/transform/schema/access-flags.mjs +36 -0
- package/dist/application/transform/schema/access-flags.mjs.map +1 -0
- package/dist/application/transform/schema/array-type.cjs +32 -1
- package/dist/application/transform/schema/array-type.cjs.map +1 -1
- package/dist/application/transform/schema/array-type.mjs +33 -2
- package/dist/application/transform/schema/array-type.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +50 -15
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +50 -15
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/core-type.cjs +3 -1
- package/dist/application/transform/schema/core-type.cjs.map +1 -1
- package/dist/application/transform/schema/core-type.mjs +3 -1
- package/dist/application/transform/schema/core-type.mjs.map +1 -1
- package/dist/application/transform/schema/discriminated-union.cjs +30 -0
- package/dist/application/transform/schema/discriminated-union.cjs.map +1 -0
- package/dist/application/transform/schema/discriminated-union.mjs +27 -0
- package/dist/application/transform/schema/discriminated-union.mjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.cjs +3 -2
- package/dist/application/transform/schema/discriminator-property.cjs.map +1 -1
- package/dist/application/transform/schema/discriminator-property.mjs +3 -2
- package/dist/application/transform/schema/discriminator-property.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +66 -10
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +67 -12
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/inherited-discriminator.cjs +29 -0
- package/dist/application/transform/schema/inherited-discriminator.cjs.map +1 -0
- package/dist/application/transform/schema/inherited-discriminator.mjs +26 -0
- package/dist/application/transform/schema/inherited-discriminator.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +38 -25
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +39 -27
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/required-variants.cjs +45 -0
- package/dist/application/transform/schema/required-variants.cjs.map +1 -0
- package/dist/application/transform/schema/required-variants.mjs +42 -0
- package/dist/application/transform/schema/required-variants.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +2 -2
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +2 -2
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +51 -5
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +50 -6
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/application/transform/type-combinators.mjs +1 -1
- package/dist/cli/api-settings.cjs +78 -0
- package/dist/cli/api-settings.cjs.map +1 -0
- package/dist/cli/api-settings.mjs +73 -0
- package/dist/cli/api-settings.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +12 -3
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +12 -4
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +3 -2
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +3 -2
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +8 -3
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +9 -4
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/help-text.cjs +3 -3
- package/dist/cli/help-text.cjs.map +1 -1
- package/dist/cli/help-text.mjs +3 -3
- package/dist/cli/help-text.mjs.map +1 -1
- package/dist/cli/main.cjs +5 -0
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +5 -0
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +15 -7
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +15 -7
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/ref-limits.cjs +1 -1
- package/dist/cli/ref-limits.cjs.map +1 -1
- package/dist/cli/ref-limits.mjs +2 -2
- package/dist/cli/ref-limits.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +20 -3
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +21 -4
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/errors.cjs +6 -1
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +6 -1
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/constructors.cjs +7 -1
- package/dist/domain/ir/constructors.cjs.map +1 -1
- package/dist/domain/ir/constructors.mjs +6 -2
- package/dist/domain/ir/constructors.mjs.map +1 -1
- package/dist/domain/openapi/admitted-values.cjs +75 -0
- package/dist/domain/openapi/admitted-values.cjs.map +1 -0
- package/dist/domain/openapi/admitted-values.mjs +72 -0
- package/dist/domain/openapi/admitted-values.mjs.map +1 -0
- package/dist/domain/openapi/discriminated-union.cjs +68 -0
- package/dist/domain/openapi/discriminated-union.cjs.map +1 -0
- package/dist/domain/openapi/discriminated-union.mjs +62 -0
- package/dist/domain/openapi/discriminated-union.mjs.map +1 -0
- package/dist/domain/openapi/discriminator-conflicts.cjs +143 -0
- package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -0
- package/dist/domain/openapi/discriminator-conflicts.mjs +141 -0
- package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -0
- package/dist/domain/openapi/parameter-object.cjs.map +1 -1
- package/dist/domain/openapi/parameter-object.mjs.map +1 -1
- package/dist/domain/openapi/path-templates.cjs +23 -0
- package/dist/domain/openapi/path-templates.cjs.map +1 -0
- package/dist/domain/openapi/path-templates.mjs +21 -0
- package/dist/domain/openapi/path-templates.mjs.map +1 -0
- package/dist/domain/output-fixes.cjs +36 -1
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +36 -1
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/url-credentials.cjs +10 -0
- package/dist/domain/url-credentials.cjs.map +1 -0
- package/dist/domain/url-credentials.mjs +8 -0
- package/dist/domain/url-credentials.mjs.map +1 -0
- package/dist/domain/warnings.cjs +23 -0
- package/dist/domain/warnings.cjs.map +1 -0
- package/dist/domain/warnings.mjs +20 -0
- package/dist/domain/warnings.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1182 -46
- package/dist/index.d.mts +1182 -46
- package/dist/index.d.ts +1182 -46
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/dist/transform/components-object.cjs +2 -1
- package/dist/transform/components-object.cjs.map +1 -1
- package/dist/transform/components-object.mjs +2 -1
- package/dist/transform/components-object.mjs.map +1 -1
- package/dist/transform/path-item-object.cjs.map +1 -1
- package/dist/transform/path-item-object.mjs.map +1 -1
- package/package.json +6 -5
- package/src/adapters/redocly-loader/configured-headers.ts +65 -0
- package/src/adapters/redocly-loader/redocly-config-source.ts +41 -6
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +44 -13
- package/src/adapters/redocly-loader/ref-access.ts +60 -5
- package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
- package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
- package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
- package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +5 -1
- package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
- package/src/adapters/type-ast-bridge/typescript-to-ir.ts +26 -12
- package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
- package/src/api/default-ports.ts +16 -0
- package/src/api/discriminator-conflict-warnings.ts +43 -0
- package/src/api/discriminator-enum-names.ts +26 -0
- package/src/api/discriminator-enum-parent.ts +129 -0
- package/src/api/discriminator-enum.ts +39 -0
- package/src/api/discriminator-other-owners.ts +97 -0
- package/src/api/discriminator-patch.ts +152 -0
- package/src/api/discriminator-scan.ts +78 -90
- package/src/api/document-refs.ts +19 -15
- package/src/api/document-run.ts +32 -11
- package/src/api/enum-values-warnings.ts +21 -0
- package/src/api/footer-sink.ts +34 -2
- package/src/api/legacy-callback-warning.ts +7 -3
- package/src/api/legacy-ts-helpers.ts +7 -5
- package/src/api/legacy-utils.ts +1 -1
- package/src/api/openapi-ts.ts +2 -0
- package/src/api/path-template-warnings.ts +27 -0
- package/src/api/run-context.ts +34 -0
- package/src/api/transform-context.ts +17 -9
- package/src/api/transform-schema.ts +90 -5
- package/src/api/unsupported-feature-warnings.ts +8 -1
- package/src/application/ports/redocly-config-source.ts +5 -1
- package/src/application/print/type-printer.ts +8 -1
- package/src/application/transform/document/assignability.ts +203 -0
- package/src/application/transform/document/components.ts +6 -6
- package/src/application/transform/document/declared-types.ts +93 -0
- package/src/application/transform/document/document.ts +71 -13
- package/src/application/transform/document/exploded-query.ts +91 -0
- package/src/application/transform/document/global-type-references.ts +78 -0
- package/src/application/transform/document/list-assignability.ts +87 -0
- package/src/application/transform/document/parameters.ts +78 -12
- package/src/application/transform/document/path-key-overlaps.ts +148 -59
- package/src/application/transform/document/path-template-replace.ts +90 -0
- package/src/application/transform/document/paths.ts +101 -38
- package/src/application/transform/document/root-type-aliases.ts +29 -28
- package/src/application/transform/document/template-key-match.ts +183 -0
- package/src/application/transform/document/type-assignability.ts +268 -0
- package/src/application/transform/document/type-key.ts +80 -0
- package/src/application/transform/document/type-resolution.ts +163 -0
- package/src/application/transform/footer/document-footer.ts +91 -6
- package/src/application/transform/footer/enum-naming.ts +29 -0
- package/src/application/transform/footer/enum-values-check.ts +171 -0
- package/src/application/transform/footer/evaluation.ts +57 -0
- package/src/application/transform/footer/shared-enum-names.ts +86 -0
- package/src/application/transform/footer/type-evaluation.ts +167 -0
- package/src/application/transform/footer/type-indexing.ts +152 -0
- package/src/application/transform/footer/type-rules.ts +269 -0
- package/src/application/transform/ref-pointer/generated-location.ts +211 -0
- package/src/application/transform/ref-pointer/generated-shape.ts +275 -0
- package/src/application/transform/ref-pointer/inline-cycles.ts +56 -0
- package/src/application/transform/ref-pointer/original-index.ts +95 -0
- package/src/application/transform/ref-pointer/pointer-type.ts +92 -0
- package/src/application/transform/ref-pointer/pointer-walk.ts +96 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +192 -0
- package/src/application/transform/ref-type.ts +11 -6
- package/src/application/transform/schema/access-flags.ts +63 -0
- package/src/application/transform/schema/array-type.ts +66 -5
- package/src/application/transform/schema/composition-type.ts +96 -24
- package/src/application/transform/schema/core-type.ts +8 -4
- package/src/application/transform/schema/discriminated-union.ts +58 -0
- package/src/application/transform/schema/discriminator-property.ts +8 -3
- package/src/application/transform/schema/enum-rule.ts +136 -13
- package/src/application/transform/schema/inherited-discriminator.ts +54 -0
- package/src/application/transform/schema/object-type.ts +51 -33
- package/src/application/transform/schema/required-variants.ts +88 -0
- package/src/application/transform/schema/schema-context.ts +26 -0
- package/src/application/transform/schema/schema-transform.ts +2 -2
- package/src/application/transform/schema-comment.ts +84 -4
- package/src/cli/api-settings.ts +109 -0
- package/src/cli/cli-arguments.ts +18 -5
- package/src/cli/cli-dependencies.ts +5 -0
- package/src/cli/cli-errors.ts +4 -2
- package/src/cli/cli-output.ts +18 -4
- package/src/cli/help-text.ts +4 -4
- package/src/cli/main.ts +6 -0
- package/src/cli/redocly-apis.ts +21 -11
- package/src/cli/ref-limits.ts +2 -2
- package/src/cli/run-cli.ts +25 -4
- package/src/domain/errors.ts +10 -2
- package/src/domain/ir/constructors.ts +9 -1
- package/src/domain/ir/nodes.ts +11 -7
- package/src/domain/openapi/admitted-values.ts +113 -0
- package/src/domain/openapi/discriminated-union.ts +109 -0
- package/src/domain/openapi/discriminator-conflicts.ts +251 -0
- package/src/domain/openapi/parameter-object.ts +4 -0
- package/src/domain/openapi/path-templates.ts +32 -0
- package/src/domain/openapi/schema-object.ts +2 -0
- package/src/domain/output-fixes.ts +43 -2
- package/src/domain/url-credentials.ts +18 -0
- package/src/domain/warnings.ts +28 -0
- package/src/index.ts +1 -0
- package/src/transform/components-object.ts +3 -1
- package/src/transform/path-item-object.ts +6 -2
- package/src/types/generator-options.ts +12 -21
- package/src/types/openapi-common.ts +1 -0
- package/src/types/openapi-request.ts +3 -0
- package/src/types/openapi-schema.ts +2 -0
- package/src/types/openapi-security.ts +1 -0
- package/dist/application/transform/document/path-item-conflicts.cjs +0 -51
- package/dist/application/transform/document/path-item-conflicts.cjs.map +0 -1
- package/dist/application/transform/document/path-item-conflicts.mjs +0 -49
- package/dist/application/transform/document/path-item-conflicts.mjs.map +0 -1
- package/src/application/transform/document/path-item-conflicts.ts +0 -79
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WARNING_CODES, warningText } from "../domain/warnings.js";
|
|
2
|
+
import type { LegacyCallbackName } from "../types.js";
|
|
2
3
|
import { defaultLogger } from "./default-ports.js";
|
|
4
|
+
import type { RunContext } from "./run-context.js";
|
|
3
5
|
|
|
4
6
|
/** Where the IR callbacks are documented; the warning points users there. */
|
|
5
7
|
export const IR_CALLBACKS_GUIDE_URL =
|
|
@@ -19,11 +21,13 @@ function message(name: LegacyCallbackName): string {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/** Warn once per run and callback; `silent` runs record the use but print nothing. */
|
|
22
|
-
export function warnLegacyCallback(ctx:
|
|
24
|
+
export function warnLegacyCallback(ctx: RunContext, name: LegacyCallbackName): void {
|
|
23
25
|
ctx.legacyCallbackWarnings ??= new Set();
|
|
24
26
|
if (ctx.legacyCallbackWarnings.has(name)) {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
29
|
ctx.legacyCallbackWarnings.add(name);
|
|
28
|
-
(ctx.logger ?? defaultLogger(ctx.silent)).warn(
|
|
30
|
+
(ctx.logger ?? defaultLogger(ctx.silent)).warn(
|
|
31
|
+
warningText(message(name), WARNING_CODES.LEGACY_CALLBACK_DEPRECATED),
|
|
32
|
+
);
|
|
29
33
|
}
|
|
@@ -103,7 +103,7 @@ export function tsDedupe(types: TypeInput[]): ts.TypeNode[] {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */
|
|
106
|
-
export const enumCache
|
|
106
|
+
export const enumCache: Map<string, ts.EnumDeclaration> = new Map();
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Create a TS enum (with sanitized name and members)
|
|
@@ -114,7 +114,7 @@ export function tsEnum(
|
|
|
114
114
|
members: (string | number)[],
|
|
115
115
|
metadata?: { name?: string; description?: string | null }[],
|
|
116
116
|
options?: { export?: boolean; shouldCache?: boolean },
|
|
117
|
-
) {
|
|
117
|
+
): ts.EnumDeclaration {
|
|
118
118
|
const ts = loadTypeScript();
|
|
119
119
|
let enumName = sanitizeMemberName(name);
|
|
120
120
|
enumName = `${enumName.charAt(0).toUpperCase()}${enumName.substring(1)}`;
|
|
@@ -149,7 +149,7 @@ export function tsArrayLiteralExpression(
|
|
|
149
149
|
elementType: TypeInput,
|
|
150
150
|
values: (string | number)[],
|
|
151
151
|
options?: { export?: boolean; readonly?: boolean; injectFooter?: FooterEntry[] },
|
|
152
|
-
) {
|
|
152
|
+
): ts.VariableStatement {
|
|
153
153
|
const ts = loadTypeScript();
|
|
154
154
|
let variableName = sanitizeMemberName(name);
|
|
155
155
|
variableName = `${variableName.charAt(0).toLowerCase()}${variableName.substring(1)}`;
|
|
@@ -223,7 +223,7 @@ function enumMemberName(value: string | number, explicitName: string | undefined
|
|
|
223
223
|
export function tsEnumMember(
|
|
224
224
|
value: string | number,
|
|
225
225
|
metadata: { name?: string; description?: string | null } = {},
|
|
226
|
-
) {
|
|
226
|
+
): ts.EnumMember {
|
|
227
227
|
const ts = loadTypeScript();
|
|
228
228
|
const name = enumMemberName(value, metadata.name);
|
|
229
229
|
const member = ts.factory.createEnumMember(name, toValueExpression(ts, value));
|
|
@@ -281,7 +281,9 @@ export function tsModifiers(modifiers: { readonly?: boolean; export?: boolean })
|
|
|
281
281
|
* Create a valid property index
|
|
282
282
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
283
283
|
*/
|
|
284
|
-
export function tsPropertyIndex(
|
|
284
|
+
export function tsPropertyIndex(
|
|
285
|
+
index: string | number,
|
|
286
|
+
): ts.Identifier | ts.NumericLiteral | ts.StringLiteral {
|
|
285
287
|
const ts = loadTypeScript();
|
|
286
288
|
if (
|
|
287
289
|
(typeof index === "number" && !(index < 0)) ||
|
package/src/api/legacy-utils.ts
CHANGED
|
@@ -90,7 +90,7 @@ export type { ResolveRefOptions } from "./document-refs.js";
|
|
|
90
90
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
91
91
|
*/
|
|
92
92
|
export function resolveRef<T>(
|
|
93
|
-
schema:
|
|
93
|
+
schema: unknown,
|
|
94
94
|
$ref: string,
|
|
95
95
|
options: ResolveRefOptions,
|
|
96
96
|
): T | undefined {
|
package/src/api/openapi-ts.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { withStackOverflowReported } from "../application/stack-overflow.js";
|
|
|
3
3
|
import type { IrDeclaration } from "../domain/ir/nodes.js";
|
|
4
4
|
import type { GeneratorOptions, SchemaSource } from "../types.js";
|
|
5
5
|
import {
|
|
6
|
+
DEFAULT_REMOTE_DOCUMENT_LIMITS,
|
|
6
7
|
defaultLogger,
|
|
7
8
|
defaultRedoclyConfig,
|
|
8
9
|
monotonicNow,
|
|
@@ -42,6 +43,7 @@ export async function defaultGeneratorPorts(options: GeneratorOptions): Promise<
|
|
|
42
43
|
logger,
|
|
43
44
|
now: monotonicNow,
|
|
44
45
|
remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,
|
|
46
|
+
remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,
|
|
45
47
|
});
|
|
46
48
|
return { loader, logger, redoc, now: monotonicNow };
|
|
47
49
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Logger } from "../application/ports/logger.js";
|
|
2
|
+
import { findIdenticalPathTemplates } from "../domain/openapi/path-templates.js";
|
|
3
|
+
import { WARNING_CODES, warningText } from "../domain/warnings.js";
|
|
4
|
+
|
|
5
|
+
const DOCS_URL =
|
|
6
|
+
"https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#pathparamsastypes";
|
|
7
|
+
const SPEC_RULE =
|
|
8
|
+
"OpenAPI does not allow this (Paths Object): templated paths with the same hierarchy but " +
|
|
9
|
+
"different templated names MUST NOT exist as they are identical";
|
|
10
|
+
|
|
11
|
+
/** `"/a"`, `"/a" and "/b"`, `"/a", "/b" and "/c"`. */
|
|
12
|
+
function quotedList(urls: readonly string[]): string {
|
|
13
|
+
const quoted = urls.map((url) => `"${url}"`);
|
|
14
|
+
const last = quoted.pop();
|
|
15
|
+
return quoted.length === 0 ? (last ?? "") : `${quoted.join(", ")} and ${last}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Warn once per group of paths that differ only in parameter names, which the spec forbids: a URL
|
|
20
|
+
* cannot tell them apart, and `--path-params-as-types` gives them the same key type.
|
|
21
|
+
*/
|
|
22
|
+
export function warnIdenticalPathTemplates(document: unknown, logger: Logger): void {
|
|
23
|
+
for (const urls of findIdenticalPathTemplates(document)) {
|
|
24
|
+
const message = `Paths ${quotedList(urls)} differ only in their parameter names. ${SPEC_RULE}`;
|
|
25
|
+
logger.warn(warningText(`${message}. See ${DOCS_URL}`, WARNING_CODES.PATH_TEMPLATES_IDENTICAL));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Logger } from "../application/ports/logger.js";
|
|
2
|
+
import type { DocumentFooter } from "../application/transform/transform-context.js";
|
|
3
|
+
import type { GlobalContext, LegacyCallbackName, SchemaObject } from "../types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The context the generator builds for a run: the public `GlobalContext` plus the run's own
|
|
7
|
+
* state. The state is not part of the public type, so it can change in a minor release; every
|
|
8
|
+
* field is optional, so a context a user builds by hand is a valid `RunContext` without it.
|
|
9
|
+
* Callbacks receive this object as `options.ctx` and may spread it; the state travels with it.
|
|
10
|
+
*/
|
|
11
|
+
export interface RunContext extends GlobalContext {
|
|
12
|
+
readonly discriminators: GlobalContext["discriminators"] & {
|
|
13
|
+
/**
|
|
14
|
+
* With the `discriminator-values` fix: for each enum the scan added to a member and each
|
|
15
|
+
* inherited discriminator object, the enum of the owner's property and the location it is
|
|
16
|
+
* typed at.
|
|
17
|
+
*/
|
|
18
|
+
readonly enumParents?: ReadonlyMap<
|
|
19
|
+
object,
|
|
20
|
+
{ readonly schema: SchemaObject; readonly path: string }
|
|
21
|
+
>;
|
|
22
|
+
/**
|
|
23
|
+
* With the `discriminator-values` fix: for each schema, the properties of the discriminators
|
|
24
|
+
* it inherits besides `objects[ref]`, which it redefines too.
|
|
25
|
+
*/
|
|
26
|
+
readonly otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
27
|
+
};
|
|
28
|
+
/** Footer state of this run (enum registry and enum naming), created on first use. */
|
|
29
|
+
runFooter?: DocumentFooter;
|
|
30
|
+
/** The deprecated callback forms this run has warned about (once each). */
|
|
31
|
+
legacyCallbackWarnings?: Set<LegacyCallbackName>;
|
|
32
|
+
/** Where this run reports warnings and debug output; without it, the terminal. */
|
|
33
|
+
logger?: Logger;
|
|
34
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as changeCase from "change-case";
|
|
2
2
|
import { RunFooter } from "../application/transform/footer/document-footer.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
DiscriminatorEnumParent,
|
|
5
|
+
SchemaLocation,
|
|
6
|
+
} from "../application/transform/schema/schema-context.js";
|
|
4
7
|
import type {
|
|
5
8
|
DocumentFooter,
|
|
6
9
|
NameCasing,
|
|
@@ -8,22 +11,24 @@ import type {
|
|
|
8
11
|
TransformDiagnostics,
|
|
9
12
|
TransformOptions,
|
|
10
13
|
} from "../application/transform/transform-context.js";
|
|
11
|
-
import type {
|
|
14
|
+
import type { TransformNodeOptions } from "../types.js";
|
|
12
15
|
import { defaultLogger, monotonicNow } from "./default-ports.js";
|
|
13
16
|
import { ContextFooterSink } from "./footer-sink.js";
|
|
17
|
+
import type { RunContext } from "./run-context.js";
|
|
14
18
|
import { schemaCallbacks } from "./schema-callbacks.js";
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
|
-
* Builds the ported transformers' context from the original `GlobalContext
|
|
18
|
-
* discriminators, the run footer and the user callbacks (see
|
|
21
|
+
* Builds the ported transformers' context from the original `GlobalContext` (in a run, a
|
|
22
|
+
* `RunContext`): options, refs, discriminators, the run footer and the user callbacks (see
|
|
23
|
+
* `schema-callbacks.ts`).
|
|
19
24
|
*/
|
|
20
25
|
|
|
21
|
-
function transformOptions(ctx:
|
|
26
|
+
function transformOptions(ctx: RunContext): TransformOptions {
|
|
22
27
|
return {
|
|
23
28
|
additionalProperties: ctx.additionalProperties,
|
|
24
29
|
alphabetize: ctx.alphabetize,
|
|
25
30
|
arrayLength: ctx.arrayLength,
|
|
26
|
-
binaryAsBlob: ctx.binaryAsBlob,
|
|
31
|
+
binaryAsBlob: ctx.binaryAsBlob ?? false,
|
|
27
32
|
conditionalEnums: ctx.conditionalEnums,
|
|
28
33
|
dedupeEnums: ctx.dedupeEnums,
|
|
29
34
|
defaultNonNullable: ctx.defaultNonNullable,
|
|
@@ -47,7 +52,7 @@ function transformOptions(ctx: GlobalContext): TransformOptions {
|
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
/** One footer per run: it holds the enum registry, so it lives on the run's context. */
|
|
50
|
-
function runFooter(ctx:
|
|
55
|
+
function runFooter(ctx: RunContext): DocumentFooter {
|
|
51
56
|
ctx.runFooter ??= new RunFooter(new ContextFooterSink(ctx.injectFooter), ctx.dedupeEnums);
|
|
52
57
|
return ctx.runFooter;
|
|
53
58
|
}
|
|
@@ -57,7 +62,7 @@ const CASING: NameCasing = { pascalCase: (text) => changeCase.pascalCase(text) }
|
|
|
57
62
|
/**
|
|
58
63
|
* A monotonic clock and the run's logger (the default one for a user's own context), "ts" group.
|
|
59
64
|
*/
|
|
60
|
-
function diagnostics(ctx:
|
|
65
|
+
function diagnostics(ctx: RunContext): TransformDiagnostics {
|
|
61
66
|
const logger = ctx.logger ?? defaultLogger(ctx.silent);
|
|
62
67
|
return {
|
|
63
68
|
now: monotonicNow,
|
|
@@ -66,13 +71,16 @@ function diagnostics(ctx: GlobalContext): TransformDiagnostics {
|
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
/** The ported transformers' context for one call from a legacy transformer. */
|
|
69
|
-
export function createTransformContext(ctx:
|
|
74
|
+
export function createTransformContext(ctx: RunContext): TransformContext {
|
|
70
75
|
return {
|
|
71
76
|
options: transformOptions(ctx),
|
|
72
77
|
refs: { resolve: (ref) => ctx.resolve(ref) },
|
|
73
78
|
discriminators: {
|
|
74
79
|
objectAt: (ref) => ctx.discriminators.objects[ref],
|
|
75
80
|
isHandled: (ref) => ctx.discriminators.refsHandled.includes(ref),
|
|
81
|
+
otherPropertiesAt: (ref) => ctx.discriminators.otherProperties?.[ref] ?? [],
|
|
82
|
+
enumParentOf: (schema) =>
|
|
83
|
+
ctx.discriminators.enumParents?.get(schema) as DiscriminatorEnumParent | undefined,
|
|
76
84
|
},
|
|
77
85
|
footer: runFooter(ctx),
|
|
78
86
|
callbacks: schemaCallbacks(ctx),
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { ts } from "../adapters/type-ast-bridge/typescript-types.js";
|
|
2
2
|
import { documentBody, documentClosing } from "../application/transform/document/document.js";
|
|
3
|
-
import {
|
|
3
|
+
import { renameTakenAliases } from "../application/transform/document/root-type-aliases.js";
|
|
4
|
+
import { RunFooter } from "../application/transform/footer/document-footer.js";
|
|
5
|
+
import { checkedEnumValues } from "../application/transform/footer/enum-values-check.js";
|
|
6
|
+
import {
|
|
7
|
+
SharedEnumNameRecorder,
|
|
8
|
+
type SharedEnumNames,
|
|
9
|
+
} from "../application/transform/footer/shared-enum-names.js";
|
|
4
10
|
import type { IrDeclaration } from "../domain/ir/nodes.js";
|
|
5
11
|
import type { DocumentObject } from "../domain/openapi/document-object.js";
|
|
12
|
+
import { OutputFix } from "../domain/output-fixes.js";
|
|
6
13
|
import type { GlobalContext, OpenAPI3 } from "../types.js";
|
|
14
|
+
import { FirstSchemaNameRecorder } from "./discriminator-enum-names.js";
|
|
7
15
|
import { documentDeclarations, type TransformedDocument } from "./document-declarations.js";
|
|
16
|
+
import { excludedValuesWarning } from "./enum-values-warnings.js";
|
|
8
17
|
import { type FooterEntry, isIrDeclaration } from "./footer-entry.js";
|
|
18
|
+
import { ContextFooterSink } from "./footer-sink.js";
|
|
19
|
+
import type { RunContext } from "./run-context.js";
|
|
9
20
|
import { createTransformContext } from "./transform-context.js";
|
|
10
21
|
|
|
11
22
|
const OPERATIONS_NAME = "operations";
|
|
@@ -18,15 +29,89 @@ function isOperations(entry: FooterEntry): boolean {
|
|
|
18
29
|
return name === OPERATIONS_NAME;
|
|
19
30
|
}
|
|
20
31
|
|
|
32
|
+
/** Drops a message: the first pass must not repeat the run's warnings or debug lines. */
|
|
33
|
+
const dropMessage = (): void => undefined;
|
|
34
|
+
const DROPPED_MESSAGES = { debug: dropMessage, warn: dropMessage, error: dropMessage };
|
|
35
|
+
|
|
36
|
+
/** A shared enum name recorder of a first pass, and the names it gives the second. */
|
|
37
|
+
interface EnumNameRecorder extends SharedEnumNames {
|
|
38
|
+
chosenNames(): SharedEnumNames;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The names of shared enums, known only at the end: a first pass transforms the document into a
|
|
43
|
+
* scratch footer that `recorder` watches; its output is dropped. User callbacks run in both
|
|
44
|
+
* passes. The `dedupe-enum-names` fix (ADR-021, upstream #1683) names an enum by all of its
|
|
45
|
+
* schemas; `discriminator-values` keeps the first declaring schema's name
|
|
46
|
+
* (`FirstSchemaNameRecorder`).
|
|
47
|
+
*/
|
|
48
|
+
function sharedEnumNamesOf(
|
|
49
|
+
document: DocumentObject,
|
|
50
|
+
ctx: RunContext,
|
|
51
|
+
recorder: EnumNameRecorder,
|
|
52
|
+
): SharedEnumNames {
|
|
53
|
+
const injectFooter: FooterEntry[] = [];
|
|
54
|
+
const scratch: RunContext = {
|
|
55
|
+
...ctx,
|
|
56
|
+
injectFooter,
|
|
57
|
+
runFooter: new RunFooter(new ContextFooterSink(injectFooter), true, recorder),
|
|
58
|
+
logger: DROPPED_MESSAGES,
|
|
59
|
+
legacyCallbackWarnings: new Set(),
|
|
60
|
+
};
|
|
61
|
+
const scratchContext = createTransformContext(scratch);
|
|
62
|
+
documentBody(document, scratchContext, () => injectFooter.filter(isIrDeclaration));
|
|
63
|
+
return recorder.chosenNames();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The recorder of the run's fixes, or null where the first schema's name needs no first pass. */
|
|
67
|
+
function enumNameRecorderOf(ctx: GlobalContext): EnumNameRecorder | null {
|
|
68
|
+
if (ctx.fix?.includes(OutputFix.DEDUPE_ENUM_NAMES)) {
|
|
69
|
+
return new SharedEnumNameRecorder();
|
|
70
|
+
}
|
|
71
|
+
return ctx.fix?.includes(OutputFix.DISCRIMINATOR_VALUES) ? new FirstSchemaNameRecorder() : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** With a naming fix, `--enum` and `--dedupe-enums`, the run's footer names shared enums. */
|
|
75
|
+
function withSharedEnumNames(document: DocumentObject, ctx: RunContext): void {
|
|
76
|
+
const recorder = ctx.runFooter === undefined ? enumNameRecorderOf(ctx) : null;
|
|
77
|
+
if (recorder === null || !ctx.enum || !ctx.dedupeEnums) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const names = sharedEnumNamesOf(document, ctx, recorder);
|
|
81
|
+
ctx.runFooter = new RunFooter(new ContextFooterSink(ctx.injectFooter), true, names);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* With `--enum-values`, arrays whose location type does not hold their values are typed by their
|
|
86
|
+
* values (ADR-027); a location that excludes listed values is a contradiction of the document.
|
|
87
|
+
*/
|
|
88
|
+
function enumValuesChecked(
|
|
89
|
+
body: readonly IrDeclaration[],
|
|
90
|
+
footer: FooterEntry[],
|
|
91
|
+
ctx: RunContext,
|
|
92
|
+
): FooterEntry[] {
|
|
93
|
+
if (!ctx.enumValues) {
|
|
94
|
+
return footer;
|
|
95
|
+
}
|
|
96
|
+
const checked = checkedEnumValues(footer, body, isIrDeclaration);
|
|
97
|
+
for (const retype of checked.retyped) {
|
|
98
|
+
if (retype.kind === "excluded") {
|
|
99
|
+
ctx.logger?.warn(excludedValuesWarning(retype.name, retype.excluded));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return checked.footer;
|
|
103
|
+
}
|
|
104
|
+
|
|
21
105
|
/** @internal Root types, the footer, then the closing declarations (Phase 5, step 6). */
|
|
22
|
-
export function transformDocument(schema: OpenAPI3, ctx:
|
|
106
|
+
export function transformDocument(schema: OpenAPI3, ctx: RunContext): TransformedDocument {
|
|
23
107
|
const document = schema as DocumentObject;
|
|
108
|
+
withSharedEnumNames(document, ctx);
|
|
24
109
|
const context = createTransformContext(ctx);
|
|
25
110
|
// documentBody registers the enums in the footer, so the footer is read after it.
|
|
26
|
-
const rawBody = documentBody(document, context);
|
|
27
|
-
const footer
|
|
28
|
-
const body = renameAliasesTakenByFooter(rawBody, footer.filter(isIrDeclaration));
|
|
111
|
+
const rawBody = documentBody(document, context, () => ctx.injectFooter.filter(isIrDeclaration));
|
|
112
|
+
const footer = enumValuesChecked(rawBody, [...ctx.injectFooter], ctx);
|
|
29
113
|
const closing = documentClosing(document, context, footer.some(isOperations));
|
|
114
|
+
const body = renameTakenAliases(rawBody, footer.filter(isIrDeclaration), closing);
|
|
30
115
|
return { body, footer, closing };
|
|
31
116
|
}
|
|
32
117
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
findUnsupportedFeatures,
|
|
4
4
|
UnsupportedFeature,
|
|
5
5
|
} from "../domain/openapi/unsupported-features.js";
|
|
6
|
+
import { WARNING_CODES, type WarningCode, warningText } from "../domain/warnings.js";
|
|
6
7
|
|
|
7
8
|
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
8
9
|
const SUPPORT_DOCS_URL = `${DOCS_BASE_URL}/introduction.md#openapi-3-2-support`;
|
|
@@ -15,12 +16,18 @@ const REASONS: Readonly<Record<UnsupportedFeature, string>> = {
|
|
|
15
16
|
"generated types",
|
|
16
17
|
};
|
|
17
18
|
|
|
19
|
+
/** The warning code of each feature. */
|
|
20
|
+
const CODES: Readonly<Record<UnsupportedFeature, WarningCode>> = {
|
|
21
|
+
[UnsupportedFeature.QUERYSTRING_NEXT_TO_QUERY]: WARNING_CODES.QUERYSTRING_NEXT_TO_QUERY,
|
|
22
|
+
};
|
|
23
|
+
|
|
18
24
|
/**
|
|
19
25
|
* Warn once per use of an OpenAPI 3.2 feature that the generated types leave out, so a missing
|
|
20
26
|
* parameter is never silent (CODING_PRINCIPLES §8.7).
|
|
21
27
|
*/
|
|
22
28
|
export function warnUnsupportedFeatures(document: unknown, logger: Logger): void {
|
|
23
29
|
for (const { feature, pointer } of findUnsupportedFeatures(document)) {
|
|
24
|
-
|
|
30
|
+
const message = `${pointer} ${REASONS[feature]}. See ${SUPPORT_DOCS_URL}`;
|
|
31
|
+
logger.warn(warningText(message, CODES[feature]));
|
|
25
32
|
}
|
|
26
33
|
}
|
|
@@ -10,7 +10,11 @@ export interface RedoclyConfigSource {
|
|
|
10
10
|
* from the working directory. Undefined when there is none.
|
|
11
11
|
*/
|
|
12
12
|
find(explicitPath: string | undefined): string | undefined;
|
|
13
|
+
/** The config of a file; fails with `CLI_CONFIG_INVALID` when it or its ignore file is bad. */
|
|
13
14
|
load(configPath: string): Promise<RedoclyConfig>;
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The config used when there is no file: the minimal rules. Fails with `CLI_CONFIG_INVALID`
|
|
17
|
+
* when the ignore file of the working directory is bad.
|
|
18
|
+
*/
|
|
15
19
|
createDefault(): Promise<RedoclyConfig>;
|
|
16
20
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertNever } from "../../domain/assert-never.js";
|
|
2
|
+
import { DEFAULT_STRING_ENCODING } from "../../domain/ir/constructors.js";
|
|
2
3
|
import type {
|
|
3
4
|
IrIndexedAccessType,
|
|
4
5
|
IrMember,
|
|
@@ -135,6 +136,12 @@ function writeTupleElement(writer: TextWriter, element: IrTupleElement): void {
|
|
|
135
136
|
if (element.isRest) {
|
|
136
137
|
writer.write("...");
|
|
137
138
|
}
|
|
139
|
+
if (element.isOptional) {
|
|
140
|
+
// TypeScript parenthesizes an optional element as a postfix operand (`(A | B)?`).
|
|
141
|
+
writeTypeIn(writer, element.type, needsParensAsPostfixOperand);
|
|
142
|
+
writer.write("?");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
138
145
|
writeType(writer, element.type);
|
|
139
146
|
}
|
|
140
147
|
|
|
@@ -190,7 +197,7 @@ function printLeafType(type: IrLeafType): string {
|
|
|
190
197
|
case "keyword":
|
|
191
198
|
return type.keyword;
|
|
192
199
|
case "stringLiteral":
|
|
193
|
-
return printStringLiteral(type.value, type.encoding);
|
|
200
|
+
return printStringLiteral(type.value, type.encoding ?? DEFAULT_STRING_ENCODING);
|
|
194
201
|
case "numberLiteral":
|
|
195
202
|
return printNumberLiteral(type.value);
|
|
196
203
|
case "booleanLiteral":
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { IrObjectType, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
2
|
+
import { indexSignaturesOf, nameOf, propertiesOf } from "./type-resolution.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the `--path-params-as-types` overlap check knows about one type where another is expected.
|
|
6
|
+
* `assignable` and `rejected` are proofs of what TypeScript decides (`strict`, without
|
|
7
|
+
* `exactOptionalPropertyTypes`); `undecided` is a pair the check does not model, such as a utility
|
|
8
|
+
* type or raw text. Only a rejection changes the output, so an undecided pair keeps the original.
|
|
9
|
+
*/
|
|
10
|
+
export type Assignability = "assignable" | "rejected" | "undecided";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* All of the relations: rejected when one is, assignable when each is. The relations are computed
|
|
14
|
+
* lazily, so a rejection stops the rest.
|
|
15
|
+
*/
|
|
16
|
+
export function everyOf<T>(
|
|
17
|
+
items: readonly T[],
|
|
18
|
+
relate: (item: T, index: number) => Assignability,
|
|
19
|
+
): Assignability {
|
|
20
|
+
let result: Assignability = "assignable";
|
|
21
|
+
for (const [index, item] of items.entries()) {
|
|
22
|
+
const each = relate(item, index);
|
|
23
|
+
if (each === "rejected") {
|
|
24
|
+
return "rejected";
|
|
25
|
+
}
|
|
26
|
+
if (each === "undecided") {
|
|
27
|
+
result = "undecided";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One of the relations: assignable when one is, rejected when each is. */
|
|
34
|
+
export function someOf<T>(items: readonly T[], relate: (item: T) => Assignability): Assignability {
|
|
35
|
+
let result: Assignability = "rejected";
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
const each = relate(item);
|
|
38
|
+
if (each === "assignable") {
|
|
39
|
+
return "assignable";
|
|
40
|
+
}
|
|
41
|
+
if (each === "undecided") {
|
|
42
|
+
result = "undecided";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Assignable when the condition holds, rejected when it does not. */
|
|
49
|
+
export function provenBy(condition: boolean): Assignability {
|
|
50
|
+
return condition ? "assignable" : "rejected";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The kinds of resolved types the check tells apart. A type of one kind is never assignable to a
|
|
55
|
+
* type of another, except that a primitive or a list may fit an object type (`string` fits
|
|
56
|
+
* `{ length: number }`), which the check models only in part. `opaque` is any type it cannot
|
|
57
|
+
* read.
|
|
58
|
+
*/
|
|
59
|
+
type TypeCategory = "primitive" | "list" | "object" | "opaque";
|
|
60
|
+
|
|
61
|
+
function categoryOf(type: IrType): TypeCategory {
|
|
62
|
+
switch (type.kind) {
|
|
63
|
+
case "keyword":
|
|
64
|
+
case "stringLiteral":
|
|
65
|
+
case "numberLiteral":
|
|
66
|
+
case "booleanLiteral":
|
|
67
|
+
return "primitive";
|
|
68
|
+
case "array":
|
|
69
|
+
case "tuple":
|
|
70
|
+
case "readonly":
|
|
71
|
+
return "list";
|
|
72
|
+
case "object":
|
|
73
|
+
return "object";
|
|
74
|
+
default:
|
|
75
|
+
return "opaque";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Keywords that are no object: `{}` rejects them under `strictNullChecks`. */
|
|
80
|
+
const NO_OBJECT_KEYWORDS: ReadonlySet<string> = new Set(["null", "undefined", "unknown", "never"]);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The members of `ReadonlyArray` and `Array` in the TypeScript libraries up to ESNext. An object
|
|
84
|
+
* type that needs a property of another name is no list; a numeric name may be a tuple element.
|
|
85
|
+
*/
|
|
86
|
+
const ARRAY_MEMBER_NAMES: ReadonlySet<string> = new Set([
|
|
87
|
+
"length",
|
|
88
|
+
"toString",
|
|
89
|
+
"toLocaleString",
|
|
90
|
+
"pop",
|
|
91
|
+
"push",
|
|
92
|
+
"concat",
|
|
93
|
+
"join",
|
|
94
|
+
"reverse",
|
|
95
|
+
"shift",
|
|
96
|
+
"slice",
|
|
97
|
+
"sort",
|
|
98
|
+
"splice",
|
|
99
|
+
"unshift",
|
|
100
|
+
"indexOf",
|
|
101
|
+
"lastIndexOf",
|
|
102
|
+
"every",
|
|
103
|
+
"some",
|
|
104
|
+
"forEach",
|
|
105
|
+
"map",
|
|
106
|
+
"filter",
|
|
107
|
+
"reduce",
|
|
108
|
+
"reduceRight",
|
|
109
|
+
"find",
|
|
110
|
+
"findIndex",
|
|
111
|
+
"fill",
|
|
112
|
+
"copyWithin",
|
|
113
|
+
"entries",
|
|
114
|
+
"keys",
|
|
115
|
+
"values",
|
|
116
|
+
"includes",
|
|
117
|
+
"flatMap",
|
|
118
|
+
"flat",
|
|
119
|
+
"at",
|
|
120
|
+
"findLast",
|
|
121
|
+
"findLastIndex",
|
|
122
|
+
"toReversed",
|
|
123
|
+
"toSorted",
|
|
124
|
+
"toSpliced",
|
|
125
|
+
"with",
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
const ARRAY_LENGTH = "length";
|
|
129
|
+
/** A tuple element's name: `"0"`, `"1"`. */
|
|
130
|
+
const ELEMENT_NAME_RE = /^\d+$/;
|
|
131
|
+
|
|
132
|
+
function isListMemberName(name: string): boolean {
|
|
133
|
+
return ARRAY_MEMBER_NAMES.has(name) || ELEMENT_NAME_RE.test(name);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Whether a list fits an object type. It does not when the object needs a property no list has
|
|
138
|
+
* (TS2741), or when the object is a weak type and no list has one of its properties (TS2559).
|
|
139
|
+
*/
|
|
140
|
+
function listToObject(target: IrObjectType): Assignability {
|
|
141
|
+
const properties = [...propertiesOf(target).values()];
|
|
142
|
+
const isForeign = (property: IrPropertySignature) => !isListMemberName(nameOf(property));
|
|
143
|
+
const needsForeign = properties.some((property) => !property.isOptional && isForeign(property));
|
|
144
|
+
const isWeak =
|
|
145
|
+
properties.length > 0 &&
|
|
146
|
+
indexSignaturesOf(target).length === 0 &&
|
|
147
|
+
properties.every((property) => property.isOptional);
|
|
148
|
+
return needsForeign || (isWeak && properties.every(isForeign)) ? "rejected" : "undecided";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Whether a primitive fits an object type: `null`, `undefined` and `unknown` never do; any other
|
|
153
|
+
* may (`{}`, `{ length: number }`), which is not modelled.
|
|
154
|
+
*/
|
|
155
|
+
function primitiveToObject(source: IrType): Assignability {
|
|
156
|
+
const isNoObject = source.kind === "keyword" && NO_OBJECT_KEYWORDS.has(source.keyword);
|
|
157
|
+
return isNoObject ? "rejected" : "undecided";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** An object type fits an array only with all of its members; `length` is the first it needs. */
|
|
161
|
+
function objectToList(source: IrObjectType): Assignability {
|
|
162
|
+
return propertiesOf(source).has(ARRAY_LENGTH) ? "undecided" : "rejected";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The relation of two types of different categories, or null when they are of the same one.
|
|
167
|
+
* Primitive and list targets accept nothing of another category; see `TypeCategory`.
|
|
168
|
+
*/
|
|
169
|
+
export function crossCategoryRelation(source: IrType, target: IrType): Assignability | null {
|
|
170
|
+
const from = categoryOf(source);
|
|
171
|
+
const to = categoryOf(target);
|
|
172
|
+
if (from === "opaque" || to === "opaque") {
|
|
173
|
+
return "undecided";
|
|
174
|
+
}
|
|
175
|
+
if (from === to) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (to !== "object") {
|
|
179
|
+
return source.kind === "object" && to === "list" ? objectToList(source) : "rejected";
|
|
180
|
+
}
|
|
181
|
+
return from === "primitive" ? primitiveToObject(source) : listToObject(target as IrObjectType);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The keyword a literal type belongs to. */
|
|
185
|
+
const LITERAL_KEYWORDS = {
|
|
186
|
+
stringLiteral: "string",
|
|
187
|
+
numberLiteral: "number",
|
|
188
|
+
booleanLiteral: "boolean",
|
|
189
|
+
} as const;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The relation of two primitive types written differently (the same text is assignable). A
|
|
193
|
+
* literal fits its keyword; any other pair is rejected: different keywords, different literals,
|
|
194
|
+
* a keyword for one literal (a union of literals is compared in `type-assignability.ts`), and
|
|
195
|
+
* anything for `never`.
|
|
196
|
+
*/
|
|
197
|
+
export function primitiveRelation(source: IrType, target: IrType): Assignability {
|
|
198
|
+
if (target.kind !== "keyword" || source.kind === "keyword") {
|
|
199
|
+
return "rejected";
|
|
200
|
+
}
|
|
201
|
+
const keyword = (LITERAL_KEYWORDS as Partial<Record<IrType["kind"], string>>)[source.kind];
|
|
202
|
+
return provenBy(keyword === target.keyword);
|
|
203
|
+
}
|