openapi-typesafe 1.0.0-rc.0 → 1.0.0-rc.1
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/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 +15 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +15 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +3 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +3 -0
- package/dist/adapters/type-ast-bridge/ir-to-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/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 +88 -0
- package/dist/api/discriminator-patch.cjs.map +1 -0
- package/dist/api/discriminator-patch.mjs +82 -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-run.cjs +18 -3
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +19 -4
- 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/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 +3 -1
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +3 -1
- 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 +5 -0
- package/dist/application/print/type-printer.cjs.map +1 -1
- package/dist/application/print/type-printer.mjs +5 -0
- 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 +40 -8
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +41 -9
- 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 +54 -28
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +53 -29
- 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 +33 -0
- package/dist/application/transform/footer/evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/evaluation.mjs +26 -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 +246 -0
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.mjs +244 -0
- package/dist/application/transform/footer/type-evaluation.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/cli-arguments.cjs +11 -3
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +11 -3
- 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/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 +7 -3
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +8 -4
- 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 +15 -2
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +16 -3
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/errors.cjs +2 -0
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +2 -0
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/constructors.cjs +5 -1
- package/dist/domain/ir/constructors.cjs.map +1 -1
- package/dist/domain/ir/constructors.mjs +5 -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/warnings.cjs +15 -0
- package/dist/domain/warnings.cjs.map +1 -0
- package/dist/domain/warnings.mjs +12 -0
- package/dist/domain/warnings.mjs.map +1 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- 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/package.json +1 -1
- package/src/adapters/redocly-loader/redocly-config-source.ts +41 -6
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -6
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +3 -0
- package/src/adapters/type-ast-bridge/typescript-to-ir.ts +26 -12
- 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 +147 -0
- package/src/api/discriminator-scan.ts +78 -90
- package/src/api/document-run.ts +24 -6
- package/src/api/enum-values-warnings.ts +21 -0
- package/src/api/path-template-warnings.ts +27 -0
- package/src/api/transform-context.ts +7 -1
- package/src/api/transform-schema.ts +88 -4
- 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 +6 -0
- 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 +76 -11
- 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 +99 -37
- 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 +47 -0
- package/src/application/transform/footer/shared-enum-names.ts +86 -0
- package/src/application/transform/footer/type-evaluation.ts +294 -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/cli-arguments.ts +13 -3
- 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/main.ts +6 -0
- package/src/cli/redocly-apis.ts +8 -4
- package/src/cli/ref-limits.ts +2 -2
- package/src/cli/run-cli.ts +20 -3
- package/src/domain/errors.ts +2 -0
- package/src/domain/ir/constructors.ts +6 -1
- package/src/domain/ir/nodes.ts +2 -1
- 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 +31 -0
- package/src/domain/openapi/schema-object.ts +2 -0
- package/src/domain/output-fixes.ts +43 -2
- package/src/domain/warnings.ts +20 -0
- package/src/transform/components-object.ts +3 -1
- package/src/types/generator-options.ts +11 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-object.mjs","sources":["../../../src/domain/openapi/parameter-object.ts"],"sourcesContent":["import type { ContentMap } from \"./media-type-object.js\";\nimport type { ReferenceSchema, Schema } from \"./schema-object.js\";\n\nexport type ParameterLocation = \"query\" | \"header\" | \"path\" | \"cookie\";\n\n/** Every parameter location, in the order the generated `parameters` type lists them. */\nexport const PARAMETER_LOCATIONS: readonly ParameterLocation[] = Object.freeze([\n \"query\",\n \"header\",\n \"path\",\n \"cookie\",\n]);\n\n/**\n * The OpenAPI 3.2 location of a parameter that is the whole query string, described by `content`.\n * Its type becomes the `query` member of `parameters` (ADR-020).\n */\nexport const QUERYSTRING_LOCATION = \"querystring\";\n\n/** The parts of a Parameter Object the generator reads (OpenAPI 3.2 §4.8.12). */\nexport interface ParameterObject {\n readonly name: string;\n readonly in: ParameterLocation | typeof QUERYSTRING_LOCATION;\n readonly required?: boolean;\n readonly deprecated?: boolean;\n readonly schema?: Schema;\n readonly content?: ContentMap;\n}\n\nexport type ParameterOrReference = ParameterObject | ReferenceSchema;\n"],"names":[],"mappings":"AAMO,MAAM,mBAAA,GAAoD,OAAO,MAAA,CAAO;AAAA,EAC7E,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC;AAMM,MAAM,oBAAA,GAAuB;;"}
|
|
1
|
+
{"version":3,"file":"parameter-object.mjs","sources":["../../../src/domain/openapi/parameter-object.ts"],"sourcesContent":["import type { ContentMap } from \"./media-type-object.js\";\nimport type { ReferenceSchema, Schema } from \"./schema-object.js\";\n\nexport type ParameterLocation = \"query\" | \"header\" | \"path\" | \"cookie\";\n\n/** Every parameter location, in the order the generated `parameters` type lists them. */\nexport const PARAMETER_LOCATIONS: readonly ParameterLocation[] = Object.freeze([\n \"query\",\n \"header\",\n \"path\",\n \"cookie\",\n]);\n\n/**\n * The OpenAPI 3.2 location of a parameter that is the whole query string, described by `content`.\n * Its type becomes the `query` member of `parameters` (ADR-020).\n */\nexport const QUERYSTRING_LOCATION = \"querystring\";\n\n/** The parts of a Parameter Object the generator reads (OpenAPI 3.2 §4.8.12). */\nexport interface ParameterObject {\n readonly name: string;\n readonly in: ParameterLocation | typeof QUERYSTRING_LOCATION;\n readonly required?: boolean;\n readonly deprecated?: boolean;\n /** How the value is serialized; `form` for `in: query` when absent (§4.8.12.4). */\n readonly style?: string;\n /** Whether an array or object value is sent as several values; true for `form` when absent. */\n readonly explode?: boolean;\n readonly schema?: Schema;\n readonly content?: ContentMap;\n}\n\nexport type ParameterOrReference = ParameterObject | ReferenceSchema;\n"],"names":[],"mappings":"AAMO,MAAM,mBAAA,GAAoD,OAAO,MAAA,CAAO;AAAA,EAC7E,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC;AAMM,MAAM,oBAAA,GAAuB;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PATH_PARAMETER_RE = /\{[^}]+\}/g;
|
|
4
|
+
const PATH_PREFIX = "/";
|
|
5
|
+
const UNNAMED_PARAMETER = "{}";
|
|
6
|
+
function isObject(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
function findIdenticalPathTemplates(document) {
|
|
10
|
+
const paths = isObject(document) && isObject(document.paths) ? document.paths : {};
|
|
11
|
+
const byHierarchy = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const url of Object.keys(paths)) {
|
|
13
|
+
if (!url.startsWith(PATH_PREFIX) || !url.includes("{")) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);
|
|
17
|
+
byHierarchy.set(hierarchy, [...byHierarchy.get(hierarchy) ?? [], url]);
|
|
18
|
+
}
|
|
19
|
+
return [...byHierarchy.values()].filter((urls) => urls.length > 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.findIdenticalPathTemplates = findIdenticalPathTemplates;
|
|
23
|
+
//# sourceMappingURL=path-templates.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-templates.cjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\nconst PATH_PARAMETER_RE = /\\{[^}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":";;AAMA,MAAM,iBAAA,GAAoB,YAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const PATH_PARAMETER_RE = /\{[^}]+\}/g;
|
|
2
|
+
const PATH_PREFIX = "/";
|
|
3
|
+
const UNNAMED_PARAMETER = "{}";
|
|
4
|
+
function isObject(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function findIdenticalPathTemplates(document) {
|
|
8
|
+
const paths = isObject(document) && isObject(document.paths) ? document.paths : {};
|
|
9
|
+
const byHierarchy = /* @__PURE__ */ new Map();
|
|
10
|
+
for (const url of Object.keys(paths)) {
|
|
11
|
+
if (!url.startsWith(PATH_PREFIX) || !url.includes("{")) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);
|
|
15
|
+
byHierarchy.set(hierarchy, [...byHierarchy.get(hierarchy) ?? [], url]);
|
|
16
|
+
}
|
|
17
|
+
return [...byHierarchy.values()].filter((urls) => urls.length > 1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { findIdenticalPathTemplates };
|
|
21
|
+
//# sourceMappingURL=path-templates.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-templates.mjs","sources":["../../../src/domain/openapi/path-templates.ts"],"sourcesContent":["/**\n * The Paths Object rule (OpenAPI 3.1 §4.8.8): \"Templated paths with the same hierarchy but\n * different templated names MUST NOT exist as they are identical.\" Such paths, `/a/{id}` and\n * `/a/{name}`, match the same URLs, so a client cannot tell which one a request is for.\n */\n\nconst PATH_PARAMETER_RE = /\\{[^}]+\\}/g;\nconst PATH_PREFIX = \"/\";\nconst UNNAMED_PARAMETER = \"{}\";\n\nfunction isObject(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * The groups of paths that differ only in the names of their template parameters, each group in\n * document order, the groups in the order of their first path. Keys that are no path, such as an\n * `x-` extension, are left out.\n */\nexport function findIdenticalPathTemplates(document: unknown): string[][] {\n const paths = isObject(document) && isObject(document.paths) ? document.paths : {};\n const byHierarchy = new Map<string, string[]>();\n for (const url of Object.keys(paths)) {\n if (!url.startsWith(PATH_PREFIX) || !url.includes(\"{\")) {\n continue;\n }\n const hierarchy = url.replace(PATH_PARAMETER_RE, UNNAMED_PARAMETER);\n byHierarchy.set(hierarchy, [...(byHierarchy.get(hierarchy) ?? []), url]);\n }\n return [...byHierarchy.values()].filter((urls) => urls.length > 1);\n}\n"],"names":[],"mappings":"AAMA,MAAM,iBAAA,GAAoB,YAAA;AAC1B,MAAM,WAAA,GAAc,GAAA;AACpB,MAAM,iBAAA,GAAoB,IAAA;AAE1B,SAAS,SAAS,KAAA,EAA4D;AAC5E,EAAA,OAAO,OAAO,UAAU,QAAA,IAAY,KAAA,KAAU,QAAQ,CAAC,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5E;AAOO,SAAS,2BAA2B,QAAA,EAA+B;AACxE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,QAAQ,CAAA,IAAK,QAAA,CAAS,SAAS,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA,GAAQ,EAAC;AACjF,EAAA,MAAM,WAAA,uBAAkB,GAAA,EAAsB;AAC9C,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,CAAC,IAAI,UAAA,CAAW,WAAW,KAAK,CAAC,GAAA,CAAI,QAAA,CAAS,GAAG,CAAA,EAAG;AACtD,MAAA;AAAA,IACF;AACA,IAAA,MAAM,SAAA,GAAY,GAAA,CAAI,OAAA,CAAQ,iBAAA,EAAmB,iBAAiB,CAAA;AAClE,IAAA,WAAA,CAAY,GAAA,CAAI,SAAA,EAAW,CAAC,GAAI,WAAA,CAAY,GAAA,CAAI,SAAS,CAAA,IAAK,EAAC,EAAI,GAAG,CAAC,CAAA;AAAA,EACzE;AACA,EAAA,OAAO,CAAC,GAAG,WAAA,CAAY,MAAA,EAAQ,CAAA,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,IAAA,CAAK,MAAA,GAAS,CAAC,CAAA;AACnE;;"}
|
|
@@ -3,14 +3,43 @@
|
|
|
3
3
|
const errors = require('./errors.cjs');
|
|
4
4
|
|
|
5
5
|
const OutputFix = {
|
|
6
|
+
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
7
|
+
ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union",
|
|
6
8
|
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
7
9
|
ALLOF_REQUIRED: "allof-required",
|
|
10
|
+
/** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */
|
|
11
|
+
ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions",
|
|
12
|
+
/** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */
|
|
13
|
+
ANYOF_ONEOF_REQUIRED: "anyof-oneof-required",
|
|
8
14
|
/** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */
|
|
9
15
|
ANYOF_PROPERTIES: "anyof-properties",
|
|
10
16
|
/** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */
|
|
11
17
|
ARRAY_LENGTH_TUPLES: "array-length-tuples",
|
|
12
|
-
/**
|
|
18
|
+
/** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */
|
|
19
|
+
DEDUPE_ENUM_NAMES: "dedupe-enum-names",
|
|
20
|
+
/** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */
|
|
21
|
+
DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required",
|
|
22
|
+
/**
|
|
23
|
+
* The value a discriminator member gets: one enum of every discriminator's values, a mapping
|
|
24
|
+
* before the schema name, a schema's own mapping before an inherited one, none where the member
|
|
25
|
+
* declares it, and with `--enum` a member of the owner's enum.
|
|
26
|
+
*/
|
|
13
27
|
DISCRIMINATOR_VALUES: "discriminator-values",
|
|
28
|
+
/** An exploded object query parameter's properties are keys of `query`, as they are sent. */
|
|
29
|
+
EXPLODED_QUERY_OBJECTS: "exploded-query-objects",
|
|
30
|
+
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
31
|
+
NULLABLE_ENUMS: "nullable-enums",
|
|
32
|
+
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
33
|
+
PATH_PARAM_TYPE_NAMES: "path-param-type-names",
|
|
34
|
+
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
35
|
+
PREFIX_ITEMS: "prefix-items",
|
|
36
|
+
/** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */
|
|
37
|
+
READ_WRITE_REFS: "read-write-refs",
|
|
38
|
+
/**
|
|
39
|
+
* A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it
|
|
40
|
+
* points at, also where the original type compiles through an index signature.
|
|
41
|
+
*/
|
|
42
|
+
REF_POINTERS: "ref-pointers",
|
|
14
43
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
15
44
|
ROOT_TYPE_NUMBERING: "root-type-numbering",
|
|
16
45
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -39,12 +68,18 @@ function resolveOutputFixes(names) {
|
|
|
39
68
|
return new Set(names.flatMap((name) => name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name]));
|
|
40
69
|
}
|
|
41
70
|
const ROOT_TYPES = { option: "rootTypes", flag: "--root-types" };
|
|
71
|
+
const ENUM = { option: "enum", flag: "--enum" };
|
|
42
72
|
const NO_SCHEMA_PREFIX = {
|
|
43
73
|
option: "rootTypesNoSchemaPrefix",
|
|
44
74
|
flag: "--root-types-no-schema-prefix"
|
|
45
75
|
};
|
|
46
76
|
const REQUIREMENTS = {
|
|
47
77
|
[OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
|
|
78
|
+
[OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
|
|
79
|
+
[OutputFix.NULLABLE_ENUMS]: [ENUM],
|
|
80
|
+
[OutputFix.PATH_PARAM_TYPE_NAMES]: [
|
|
81
|
+
{ option: "pathParamsAsTypes", flag: "--path-params-as-types" }
|
|
82
|
+
],
|
|
48
83
|
[OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
|
|
49
84
|
};
|
|
50
85
|
function describeRequirement(requirement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /**
|
|
1
|
+
{"version":3,"file":"output-fixes.cjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\nexport type OutputFix = (typeof OutputFix)[keyof typeof OutputFix];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(OutputFix);\n\n/** The name that turns on every fix of the installed version. */\nexport const ALL_OUTPUT_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `all`. */\nexport type OutputFixName = OutputFix | typeof ALL_OUTPUT_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [OutputFix.NULLABLE_ENUMS]: [ENUM],\n [OutputFix.PATH_PARAM_TYPE_NAMES]: [\n { option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" },\n ],\n [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":["OpenAPITypesafeError","ERROR_CODES"],"mappings":";;;;AAOO,MAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,yBAAA,EAA2B,2BAAA;AAAA;AAAA,EAE3B,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,wBAAA,EAA0B,0BAAA;AAAA;AAAA,EAE1B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,gBAAA,EAAkB,kBAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB,qBAAA;AAAA;AAAA,EAErB,iBAAA,EAAmB,mBAAA;AAAA;AAAA,EAEnB,6BAAA,EAA+B,+BAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,oBAAA,EAAsB,sBAAA;AAAA;AAAA,EAEtB,sBAAA,EAAwB,wBAAA;AAAA;AAAA,EAExB,cAAA,EAAgB,gBAAA;AAAA;AAAA,EAEhB,qBAAA,EAAuB,uBAAA;AAAA;AAAA,EAEvB,YAA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,CAAA,IAAK,EAAC,EAAG,MAAA,CAAO,CAAC,EAAE,MAAA,EAAO,KAAM,CAAC,UAAA,CAAW,MAAM,CAAC,CAAA;AACrF,IAAA,OAAO,QAAQ,MAAA,KAAW,CAAA,GACtB,EAAC,GACD,CAAC,CAAA,KAAA,EAAQ,IAAI,CAAA,wBAAA,EAA2B,OAAA,CAAQ,IAAI,mBAAmB,CAAA,CAAE,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE,CAAA;AAAA,EAC9F,CAAC,CAAA;AACH;;;;;;;"}
|
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
import { OpenAPITypesafeError, ERROR_CODES } from './errors.mjs';
|
|
2
2
|
|
|
3
3
|
const OutputFix = {
|
|
4
|
+
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
5
|
+
ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union",
|
|
4
6
|
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
5
7
|
ALLOF_REQUIRED: "allof-required",
|
|
8
|
+
/** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */
|
|
9
|
+
ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions",
|
|
10
|
+
/** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */
|
|
11
|
+
ANYOF_ONEOF_REQUIRED: "anyof-oneof-required",
|
|
6
12
|
/** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */
|
|
7
13
|
ANYOF_PROPERTIES: "anyof-properties",
|
|
8
14
|
/** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */
|
|
9
15
|
ARRAY_LENGTH_TUPLES: "array-length-tuples",
|
|
10
|
-
/**
|
|
16
|
+
/** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */
|
|
17
|
+
DEDUPE_ENUM_NAMES: "dedupe-enum-names",
|
|
18
|
+
/** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */
|
|
19
|
+
DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required",
|
|
20
|
+
/**
|
|
21
|
+
* The value a discriminator member gets: one enum of every discriminator's values, a mapping
|
|
22
|
+
* before the schema name, a schema's own mapping before an inherited one, none where the member
|
|
23
|
+
* declares it, and with `--enum` a member of the owner's enum.
|
|
24
|
+
*/
|
|
11
25
|
DISCRIMINATOR_VALUES: "discriminator-values",
|
|
26
|
+
/** An exploded object query parameter's properties are keys of `query`, as they are sent. */
|
|
27
|
+
EXPLODED_QUERY_OBJECTS: "exploded-query-objects",
|
|
28
|
+
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
29
|
+
NULLABLE_ENUMS: "nullable-enums",
|
|
30
|
+
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
31
|
+
PATH_PARAM_TYPE_NAMES: "path-param-type-names",
|
|
32
|
+
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
33
|
+
PREFIX_ITEMS: "prefix-items",
|
|
34
|
+
/** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */
|
|
35
|
+
READ_WRITE_REFS: "read-write-refs",
|
|
36
|
+
/**
|
|
37
|
+
* A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it
|
|
38
|
+
* points at, also where the original type compiles through an index signature.
|
|
39
|
+
*/
|
|
40
|
+
REF_POINTERS: "ref-pointers",
|
|
12
41
|
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
13
42
|
ROOT_TYPE_NUMBERING: "root-type-numbering",
|
|
14
43
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
@@ -37,12 +66,18 @@ function resolveOutputFixes(names) {
|
|
|
37
66
|
return new Set(names.flatMap((name) => name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name]));
|
|
38
67
|
}
|
|
39
68
|
const ROOT_TYPES = { option: "rootTypes", flag: "--root-types" };
|
|
69
|
+
const ENUM = { option: "enum", flag: "--enum" };
|
|
40
70
|
const NO_SCHEMA_PREFIX = {
|
|
41
71
|
option: "rootTypesNoSchemaPrefix",
|
|
42
72
|
flag: "--root-types-no-schema-prefix"
|
|
43
73
|
};
|
|
44
74
|
const REQUIREMENTS = {
|
|
45
75
|
[OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: "arrayLength", flag: "--array-length" }],
|
|
76
|
+
[OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: "dedupeEnums", flag: "--dedupe-enums" }],
|
|
77
|
+
[OutputFix.NULLABLE_ENUMS]: [ENUM],
|
|
78
|
+
[OutputFix.PATH_PARAM_TYPE_NAMES]: [
|
|
79
|
+
{ option: "pathParamsAsTypes", flag: "--path-params-as-types" }
|
|
80
|
+
],
|
|
46
81
|
[OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX]
|
|
47
82
|
};
|
|
48
83
|
function describeRequirement(requirement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-fixes.mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /**
|
|
1
|
+
{"version":3,"file":"output-fixes.mjs","sources":["../../src/domain/output-fixes.ts"],"sourcesContent":["import { ERROR_CODES, OpenAPITypesafeError } from \"./errors.js\";\n\n/**\n * Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;\n * without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the\n * default.\n */\nexport const OutputFix = {\n /** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */\n ALLOF_DISCRIMINATED_UNION: \"allof-discriminated-union\",\n /** An `allOf` member with only `required` makes those properties of the others required. */\n ALLOF_REQUIRED: \"allof-required\",\n /** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */\n ANYOF_ONEOF_DESCRIPTIONS: \"anyof-oneof-descriptions\",\n /** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */\n ANYOF_ONEOF_REQUIRED: \"anyof-oneof-required\",\n /** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */\n ANYOF_PROPERTIES: \"anyof-properties\",\n /** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */\n ARRAY_LENGTH_TUPLES: \"array-length-tuples\",\n /** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */\n DEDUPE_ENUM_NAMES: \"dedupe-enum-names\",\n /** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */\n DISCRIMINATOR_MEMBER_REQUIRED: \"discriminator-member-required\",\n /**\n * The value a discriminator member gets: one enum of every discriminator's values, a mapping\n * before the schema name, a schema's own mapping before an inherited one, none where the member\n * declares it, and with `--enum` a member of the owner's enum.\n */\n DISCRIMINATOR_VALUES: \"discriminator-values\",\n /** An exploded object query parameter's properties are keys of `query`, as they are sent. */\n EXPLODED_QUERY_OBJECTS: \"exploded-query-objects\",\n /** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */\n NULLABLE_ENUMS: \"nullable-enums\",\n /** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */\n PATH_PARAM_TYPE_NAMES: \"path-param-type-names\",\n /** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */\n PREFIX_ITEMS: \"prefix-items\",\n /** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */\n READ_WRITE_REFS: \"read-write-refs\",\n /**\n * A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it\n * points at, also where the original type compiles through an index signature.\n */\n REF_POINTERS: \"ref-pointers\",\n /** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */\n ROOT_TYPE_NUMBERING: \"root-type-numbering\",\n /** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */\n UNEVALUATED_PROPERTIES: \"unevaluated-properties\",\n} as const;\nexport type OutputFix = (typeof OutputFix)[keyof typeof OutputFix];\n\n/** Every fix of this version, in the order the docs list them. */\nexport const OUTPUT_FIXES: readonly OutputFix[] = Object.values(OutputFix);\n\n/** The name that turns on every fix of the installed version. */\nexport const ALL_OUTPUT_FIXES = \"all\";\n\n/** A name the `fix` option accepts: one fix, or `all`. */\nexport type OutputFixName = OutputFix | typeof ALL_OUTPUT_FIXES;\n\nconst KNOWN_NAMES: ReadonlySet<string> = new Set<string>([...OUTPUT_FIXES, ALL_OUTPUT_FIXES]);\n\nfunction isOutputFixName(value: unknown): value is OutputFixName {\n return typeof value === \"string\" && KNOWN_NAMES.has(value);\n}\n\n/** The fix names as given; fails with `OPTION_FIX_UNKNOWN` for any other value. */\nexport function outputFixNamesOf(values: readonly unknown[]): readonly OutputFixName[] {\n const unknown = values.filter((value) => !isOutputFixName(value));\n if (unknown.length > 0) {\n const names = unknown.map((value) => JSON.stringify(value)).join(\", \");\n const known = [...KNOWN_NAMES].join(\", \");\n throw new OpenAPITypesafeError({\n code: ERROR_CODES.OPTION_FIX_UNKNOWN,\n message: `Unknown fix ${names}. Known fixes: ${known}.`,\n details: { unknown, known: [...KNOWN_NAMES] },\n });\n }\n return values as readonly OutputFixName[];\n}\n\n/** The fixes the names turn on; `all` stands for every fix of this version. */\nexport function resolveOutputFixes(names: readonly OutputFixName[]): ReadonlySet<OutputFix> {\n return new Set(names.flatMap((name) => (name === ALL_OUTPUT_FIXES ? OUTPUT_FIXES : [name])));\n}\n\n/** A generator option that a fix works with; without it, the fix changes nothing (ADR-021). */\nexport interface OutputFixRequirement {\n readonly option:\n | \"arrayLength\"\n | \"dedupeEnums\"\n | \"enum\"\n | \"pathParamsAsTypes\"\n | \"rootTypes\"\n | \"rootTypesNoSchemaPrefix\";\n readonly flag: string;\n}\n\nconst ROOT_TYPES = { option: \"rootTypes\", flag: \"--root-types\" } as const;\nconst ENUM = { option: \"enum\", flag: \"--enum\" } as const;\nconst NO_SCHEMA_PREFIX = {\n option: \"rootTypesNoSchemaPrefix\",\n flag: \"--root-types-no-schema-prefix\",\n} as const;\n\n/** The options each fix needs, by fix name; `all` has none. */\nconst REQUIREMENTS: Readonly<Partial<Record<OutputFixName, readonly OutputFixRequirement[]>>> = {\n [OutputFix.ARRAY_LENGTH_TUPLES]: [{ option: \"arrayLength\", flag: \"--array-length\" }],\n [OutputFix.DEDUPE_ENUM_NAMES]: [ENUM, { option: \"dedupeEnums\", flag: \"--dedupe-enums\" }],\n [OutputFix.NULLABLE_ENUMS]: [ENUM],\n [OutputFix.PATH_PARAM_TYPE_NAMES]: [\n { option: \"pathParamsAsTypes\", flag: \"--path-params-as-types\" },\n ],\n [OutputFix.ROOT_TYPE_NUMBERING]: [ROOT_TYPES, NO_SCHEMA_PREFIX],\n};\n\nfunction describeRequirement(requirement: OutputFixRequirement): string {\n return `${requirement.option} (${requirement.flag})`;\n}\n\n/**\n * A notice for each fix given by name with an option it needs off; it names the options that are\n * off. `all` adds none: it means every fix that applies, so one that does not apply is expected.\n */\nexport function ineffectiveFixNotices(\n names: readonly OutputFixName[],\n isOptionOn: (option: OutputFixRequirement[\"option\"]) => boolean,\n): string[] {\n return [...new Set(names)].flatMap((name) => {\n const missing = (REQUIREMENTS[name] ?? []).filter(({ option }) => !isOptionOn(option));\n return missing.length === 0\n ? []\n : [`Fix \"${name}\" has no effect without ${missing.map(describeRequirement).join(\" and \")}`];\n });\n}\n"],"names":[],"mappings":";;AAOO,MAAM,SAAA,GAA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
9
|
+
function warningText(message, code) {
|
|
10
|
+
return `${message} (${code})`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.WARNING_CODES = WARNING_CODES;
|
|
14
|
+
exports.warningText = warningText;
|
|
15
|
+
//# sourceMappingURL=warnings.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.cjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":";;AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B;AAC7B;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const WARNING_CODES = {
|
|
2
|
+
DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED",
|
|
3
|
+
ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED",
|
|
4
|
+
PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL",
|
|
5
|
+
QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY"
|
|
6
|
+
};
|
|
7
|
+
function warningText(message, code) {
|
|
8
|
+
return `${message} (${code})`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { WARNING_CODES, warningText };
|
|
12
|
+
//# sourceMappingURL=warnings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warnings.mjs","sources":["../../src/domain/warnings.ts"],"sourcesContent":["/**\n * Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.\n * Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors\n * (`message (CODE)`), so a script or a person can search for it.\n */\n\n/** Every warning code. */\nexport const WARNING_CODES = {\n DISCRIMINATOR_VALUE_NOT_ALLOWED: \"DISCRIMINATOR_VALUE_NOT_ALLOWED\",\n ENUM_VALUES_EXCLUDED: \"ENUM_VALUES_EXCLUDED\",\n PATH_TEMPLATES_IDENTICAL: \"PATH_TEMPLATES_IDENTICAL\",\n QUERYSTRING_NEXT_TO_QUERY: \"QUERYSTRING_NEXT_TO_QUERY\",\n} as const;\n\nexport type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];\n\n/** The warning line for people, with its code at the end. */\nexport function warningText(message: string, code: WarningCode): string {\n return `${message} (${code})`;\n}\n"],"names":[],"mappings":"AAOO,MAAM,aAAA,GAAgB;AAAA,EAC3B,+BAAA,EAAiC,iCAAA;AAAA,EACjC,oBAAA,EAAsB,sBAAA;AAAA,EACtB,wBAAA,EAA0B,0BAAA;AAAA,EAC1B,yBAAA,EAA2B;AAC7B;AAKO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,EAAA,EAAK,IAAI,CAAA,CAAA,CAAA;AAC5B;;"}
|
package/dist/index.d.cts
CHANGED
|
@@ -35,6 +35,7 @@ interface IrArrayType {
|
|
|
35
35
|
interface IrTupleElement {
|
|
36
36
|
readonly type: IrType;
|
|
37
37
|
readonly isRest: boolean;
|
|
38
|
+
readonly isOptional: boolean;
|
|
38
39
|
}
|
|
39
40
|
interface IrTupleType {
|
|
40
41
|
readonly kind: "tuple";
|
|
@@ -152,10 +153,21 @@ interface Logger {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
declare const OutputFix: {
|
|
156
|
+
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
155
157
|
readonly ALLOF_REQUIRED: "allof-required";
|
|
158
|
+
readonly ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions";
|
|
159
|
+
readonly ANYOF_ONEOF_REQUIRED: "anyof-oneof-required";
|
|
156
160
|
readonly ANYOF_PROPERTIES: "anyof-properties";
|
|
157
161
|
readonly ARRAY_LENGTH_TUPLES: "array-length-tuples";
|
|
162
|
+
readonly DEDUPE_ENUM_NAMES: "dedupe-enum-names";
|
|
163
|
+
readonly DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required";
|
|
158
164
|
readonly DISCRIMINATOR_VALUES: "discriminator-values";
|
|
165
|
+
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
166
|
+
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
167
|
+
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
168
|
+
readonly PREFIX_ITEMS: "prefix-items";
|
|
169
|
+
readonly READ_WRITE_REFS: "read-write-refs";
|
|
170
|
+
readonly REF_POINTERS: "ref-pointers";
|
|
159
171
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
160
172
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
161
173
|
};
|
|
@@ -170,8 +182,10 @@ interface EnumMemberMetadata {
|
|
|
170
182
|
}
|
|
171
183
|
interface EnumDeclarationRequest {
|
|
172
184
|
readonly name: string;
|
|
185
|
+
readonly isComponentSchema: boolean;
|
|
173
186
|
readonly values: readonly (string | number)[];
|
|
174
187
|
readonly metadata: readonly EnumMemberMetadata[];
|
|
188
|
+
readonly isOwnerReference?: boolean;
|
|
175
189
|
}
|
|
176
190
|
interface EnumValuesRequest {
|
|
177
191
|
readonly name: string;
|
|
@@ -180,6 +194,7 @@ interface EnumValuesRequest {
|
|
|
180
194
|
}
|
|
181
195
|
interface FooterDeclarations {
|
|
182
196
|
addEnum(request: EnumDeclarationRequest): string;
|
|
197
|
+
enumMembers(name: string): ReadonlyMap<string | number, string>;
|
|
183
198
|
addEnumValues(request: EnumValuesRequest): void;
|
|
184
199
|
requireWithRequired(): void;
|
|
185
200
|
requirePropertyValues(): void;
|
|
@@ -584,6 +599,11 @@ interface GlobalContext {
|
|
|
584
599
|
discriminators: {
|
|
585
600
|
objects: Record<string, DiscriminatorObject>;
|
|
586
601
|
refsHandled: string[];
|
|
602
|
+
enumParents?: ReadonlyMap<object, {
|
|
603
|
+
readonly schema: SchemaObject;
|
|
604
|
+
readonly path: string;
|
|
605
|
+
}>;
|
|
606
|
+
otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
587
607
|
};
|
|
588
608
|
emptyObjectsUnknown: boolean;
|
|
589
609
|
enum: boolean;
|
|
@@ -643,8 +663,10 @@ declare const ERROR_CODES: {
|
|
|
643
663
|
readonly CLI_FLAG_REMOVED: "CLI_FLAG_REMOVED";
|
|
644
664
|
readonly CLI_GLOB_UNSUPPORTED: "CLI_GLOB_UNSUPPORTED";
|
|
645
665
|
readonly CLI_CONFIG_NOT_FOUND: "CLI_CONFIG_NOT_FOUND";
|
|
666
|
+
readonly CLI_CONFIG_INVALID: "CLI_CONFIG_INVALID";
|
|
646
667
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
647
668
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
669
|
+
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
648
670
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
649
671
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
650
672
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -677,9 +699,16 @@ declare function astToString(ast: AstToStringInput, options?: AstToStringOptions
|
|
|
677
699
|
|
|
678
700
|
declare const COMMENT_HEADER = "/**\n * This file was auto-generated by openapi-typesafe.\n * Do not make direct changes to the file.\n */\n\n";
|
|
679
701
|
|
|
702
|
+
interface EnumParent {
|
|
703
|
+
readonly schema: SchemaObject;
|
|
704
|
+
readonly path: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
680
707
|
interface DiscriminatorScan {
|
|
681
708
|
objects: Record<string, DiscriminatorObject>;
|
|
682
709
|
refsHandled: string[];
|
|
710
|
+
enumParents: ReadonlyMap<object, EnumParent>;
|
|
711
|
+
otherProperties: Readonly<Record<string, readonly string[]>>;
|
|
683
712
|
}
|
|
684
713
|
declare function scanDiscriminators(schema: OpenAPI3, options: GeneratorOptions, logger?: Logger): DiscriminatorScan;
|
|
685
714
|
|
package/dist/index.d.mts
CHANGED
|
@@ -35,6 +35,7 @@ interface IrArrayType {
|
|
|
35
35
|
interface IrTupleElement {
|
|
36
36
|
readonly type: IrType;
|
|
37
37
|
readonly isRest: boolean;
|
|
38
|
+
readonly isOptional: boolean;
|
|
38
39
|
}
|
|
39
40
|
interface IrTupleType {
|
|
40
41
|
readonly kind: "tuple";
|
|
@@ -152,10 +153,21 @@ interface Logger {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
declare const OutputFix: {
|
|
156
|
+
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
155
157
|
readonly ALLOF_REQUIRED: "allof-required";
|
|
158
|
+
readonly ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions";
|
|
159
|
+
readonly ANYOF_ONEOF_REQUIRED: "anyof-oneof-required";
|
|
156
160
|
readonly ANYOF_PROPERTIES: "anyof-properties";
|
|
157
161
|
readonly ARRAY_LENGTH_TUPLES: "array-length-tuples";
|
|
162
|
+
readonly DEDUPE_ENUM_NAMES: "dedupe-enum-names";
|
|
163
|
+
readonly DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required";
|
|
158
164
|
readonly DISCRIMINATOR_VALUES: "discriminator-values";
|
|
165
|
+
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
166
|
+
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
167
|
+
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
168
|
+
readonly PREFIX_ITEMS: "prefix-items";
|
|
169
|
+
readonly READ_WRITE_REFS: "read-write-refs";
|
|
170
|
+
readonly REF_POINTERS: "ref-pointers";
|
|
159
171
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
160
172
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
161
173
|
};
|
|
@@ -170,8 +182,10 @@ interface EnumMemberMetadata {
|
|
|
170
182
|
}
|
|
171
183
|
interface EnumDeclarationRequest {
|
|
172
184
|
readonly name: string;
|
|
185
|
+
readonly isComponentSchema: boolean;
|
|
173
186
|
readonly values: readonly (string | number)[];
|
|
174
187
|
readonly metadata: readonly EnumMemberMetadata[];
|
|
188
|
+
readonly isOwnerReference?: boolean;
|
|
175
189
|
}
|
|
176
190
|
interface EnumValuesRequest {
|
|
177
191
|
readonly name: string;
|
|
@@ -180,6 +194,7 @@ interface EnumValuesRequest {
|
|
|
180
194
|
}
|
|
181
195
|
interface FooterDeclarations {
|
|
182
196
|
addEnum(request: EnumDeclarationRequest): string;
|
|
197
|
+
enumMembers(name: string): ReadonlyMap<string | number, string>;
|
|
183
198
|
addEnumValues(request: EnumValuesRequest): void;
|
|
184
199
|
requireWithRequired(): void;
|
|
185
200
|
requirePropertyValues(): void;
|
|
@@ -584,6 +599,11 @@ interface GlobalContext {
|
|
|
584
599
|
discriminators: {
|
|
585
600
|
objects: Record<string, DiscriminatorObject>;
|
|
586
601
|
refsHandled: string[];
|
|
602
|
+
enumParents?: ReadonlyMap<object, {
|
|
603
|
+
readonly schema: SchemaObject;
|
|
604
|
+
readonly path: string;
|
|
605
|
+
}>;
|
|
606
|
+
otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
587
607
|
};
|
|
588
608
|
emptyObjectsUnknown: boolean;
|
|
589
609
|
enum: boolean;
|
|
@@ -643,8 +663,10 @@ declare const ERROR_CODES: {
|
|
|
643
663
|
readonly CLI_FLAG_REMOVED: "CLI_FLAG_REMOVED";
|
|
644
664
|
readonly CLI_GLOB_UNSUPPORTED: "CLI_GLOB_UNSUPPORTED";
|
|
645
665
|
readonly CLI_CONFIG_NOT_FOUND: "CLI_CONFIG_NOT_FOUND";
|
|
666
|
+
readonly CLI_CONFIG_INVALID: "CLI_CONFIG_INVALID";
|
|
646
667
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
647
668
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
669
|
+
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
648
670
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
649
671
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
650
672
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -677,9 +699,16 @@ declare function astToString(ast: AstToStringInput, options?: AstToStringOptions
|
|
|
677
699
|
|
|
678
700
|
declare const COMMENT_HEADER = "/**\n * This file was auto-generated by openapi-typesafe.\n * Do not make direct changes to the file.\n */\n\n";
|
|
679
701
|
|
|
702
|
+
interface EnumParent {
|
|
703
|
+
readonly schema: SchemaObject;
|
|
704
|
+
readonly path: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
680
707
|
interface DiscriminatorScan {
|
|
681
708
|
objects: Record<string, DiscriminatorObject>;
|
|
682
709
|
refsHandled: string[];
|
|
710
|
+
enumParents: ReadonlyMap<object, EnumParent>;
|
|
711
|
+
otherProperties: Readonly<Record<string, readonly string[]>>;
|
|
683
712
|
}
|
|
684
713
|
declare function scanDiscriminators(schema: OpenAPI3, options: GeneratorOptions, logger?: Logger): DiscriminatorScan;
|
|
685
714
|
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ interface IrArrayType {
|
|
|
35
35
|
interface IrTupleElement {
|
|
36
36
|
readonly type: IrType;
|
|
37
37
|
readonly isRest: boolean;
|
|
38
|
+
readonly isOptional: boolean;
|
|
38
39
|
}
|
|
39
40
|
interface IrTupleType {
|
|
40
41
|
readonly kind: "tuple";
|
|
@@ -152,10 +153,21 @@ interface Logger {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
declare const OutputFix: {
|
|
156
|
+
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
155
157
|
readonly ALLOF_REQUIRED: "allof-required";
|
|
158
|
+
readonly ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions";
|
|
159
|
+
readonly ANYOF_ONEOF_REQUIRED: "anyof-oneof-required";
|
|
156
160
|
readonly ANYOF_PROPERTIES: "anyof-properties";
|
|
157
161
|
readonly ARRAY_LENGTH_TUPLES: "array-length-tuples";
|
|
162
|
+
readonly DEDUPE_ENUM_NAMES: "dedupe-enum-names";
|
|
163
|
+
readonly DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required";
|
|
158
164
|
readonly DISCRIMINATOR_VALUES: "discriminator-values";
|
|
165
|
+
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
166
|
+
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
167
|
+
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
168
|
+
readonly PREFIX_ITEMS: "prefix-items";
|
|
169
|
+
readonly READ_WRITE_REFS: "read-write-refs";
|
|
170
|
+
readonly REF_POINTERS: "ref-pointers";
|
|
159
171
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
160
172
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
161
173
|
};
|
|
@@ -170,8 +182,10 @@ interface EnumMemberMetadata {
|
|
|
170
182
|
}
|
|
171
183
|
interface EnumDeclarationRequest {
|
|
172
184
|
readonly name: string;
|
|
185
|
+
readonly isComponentSchema: boolean;
|
|
173
186
|
readonly values: readonly (string | number)[];
|
|
174
187
|
readonly metadata: readonly EnumMemberMetadata[];
|
|
188
|
+
readonly isOwnerReference?: boolean;
|
|
175
189
|
}
|
|
176
190
|
interface EnumValuesRequest {
|
|
177
191
|
readonly name: string;
|
|
@@ -180,6 +194,7 @@ interface EnumValuesRequest {
|
|
|
180
194
|
}
|
|
181
195
|
interface FooterDeclarations {
|
|
182
196
|
addEnum(request: EnumDeclarationRequest): string;
|
|
197
|
+
enumMembers(name: string): ReadonlyMap<string | number, string>;
|
|
183
198
|
addEnumValues(request: EnumValuesRequest): void;
|
|
184
199
|
requireWithRequired(): void;
|
|
185
200
|
requirePropertyValues(): void;
|
|
@@ -584,6 +599,11 @@ interface GlobalContext {
|
|
|
584
599
|
discriminators: {
|
|
585
600
|
objects: Record<string, DiscriminatorObject>;
|
|
586
601
|
refsHandled: string[];
|
|
602
|
+
enumParents?: ReadonlyMap<object, {
|
|
603
|
+
readonly schema: SchemaObject;
|
|
604
|
+
readonly path: string;
|
|
605
|
+
}>;
|
|
606
|
+
otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
587
607
|
};
|
|
588
608
|
emptyObjectsUnknown: boolean;
|
|
589
609
|
enum: boolean;
|
|
@@ -643,8 +663,10 @@ declare const ERROR_CODES: {
|
|
|
643
663
|
readonly CLI_FLAG_REMOVED: "CLI_FLAG_REMOVED";
|
|
644
664
|
readonly CLI_GLOB_UNSUPPORTED: "CLI_GLOB_UNSUPPORTED";
|
|
645
665
|
readonly CLI_CONFIG_NOT_FOUND: "CLI_CONFIG_NOT_FOUND";
|
|
666
|
+
readonly CLI_CONFIG_INVALID: "CLI_CONFIG_INVALID";
|
|
646
667
|
readonly CLI_CONFIG_OUTPUT_MISSING: "CLI_CONFIG_OUTPUT_MISSING";
|
|
647
668
|
readonly CLI_CHECK_OUTPUT_MISSING: "CLI_CHECK_OUTPUT_MISSING";
|
|
669
|
+
readonly CLI_INPUT_MISSING: "CLI_INPUT_MISSING";
|
|
648
670
|
readonly OUTPUT_STALE: "OUTPUT_STALE";
|
|
649
671
|
readonly OUTPUT_READ_FAILED: "OUTPUT_READ_FAILED";
|
|
650
672
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
@@ -677,9 +699,16 @@ declare function astToString(ast: AstToStringInput, options?: AstToStringOptions
|
|
|
677
699
|
|
|
678
700
|
declare const COMMENT_HEADER = "/**\n * This file was auto-generated by openapi-typesafe.\n * Do not make direct changes to the file.\n */\n\n";
|
|
679
701
|
|
|
702
|
+
interface EnumParent {
|
|
703
|
+
readonly schema: SchemaObject;
|
|
704
|
+
readonly path: string;
|
|
705
|
+
}
|
|
706
|
+
|
|
680
707
|
interface DiscriminatorScan {
|
|
681
708
|
objects: Record<string, DiscriminatorObject>;
|
|
682
709
|
refsHandled: string[];
|
|
710
|
+
enumParents: ReadonlyMap<object, EnumParent>;
|
|
711
|
+
otherProperties: Readonly<Record<string, readonly string[]>>;
|
|
683
712
|
}
|
|
684
713
|
declare function scanDiscriminators(schema: OpenAPI3, options: GeneratorOptions, logger?: Logger): DiscriminatorScan;
|
|
685
714
|
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const transformContext = require('../api/transform-context.cjs');
|
|
6
6
|
const components = require('../application/transform/document/components.cjs');
|
|
7
|
+
const rootTypeAliases = require('../application/transform/document/root-type-aliases.cjs');
|
|
7
8
|
|
|
8
9
|
function transformComponentsObject(componentsObject, ctx) {
|
|
9
10
|
const { type, rootTypes } = components.componentsType(componentsObject, transformContext.createTransformContext(ctx));
|
|
10
|
-
return [type, ...rootTypes];
|
|
11
|
+
return [type, ...rootTypeAliases.renameTakenAliases(rootTypes, [])];
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
exports.default = transformComponentsObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components-object.cjs","sources":["../../src/transform/components-object.ts"],"sourcesContent":["import { createTransformContext } from \"../api/transform-context.js\";\nimport { componentsType } from \"../application/transform/document/components.js\";\nimport type { IrType, IrTypeAliasDeclaration } from \"../domain/ir/nodes.js\";\nimport { isEnumSchema, singularizeComponentKind } from \"../domain/openapi/components-object.js\";\nimport type { ComponentsObject, GlobalContext } from \"../types.js\";\n\nexport { isEnumSchema };\n\n/** `requestBodies` → `requestBody`; other keys drop the final `s`. */\nexport const singularizeComponentKey = singularizeComponentKind;\n\n/**\n * Transform the ComponentsObject (4.8.7)\n * @see https://spec.openapis.org/oas/latest.html#components-object\n *\n * Ported to IR (ENGINEERING_PLAN Phase 5, step 6). Same name and parameters as the original;\n * returns IR (task 6.2). For the public API: the `components` type, then the root type aliases.\n */\nexport default function transformComponentsObject(\n componentsObject: ComponentsObject,\n ctx: GlobalContext,\n): (IrType | IrTypeAliasDeclaration)[] {\n const { type, rootTypes } = componentsType(componentsObject, createTransformContext(ctx));\n return [type, ...rootTypes];\n}\n"],"names":["componentsType","createTransformContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"components-object.cjs","sources":["../../src/transform/components-object.ts"],"sourcesContent":["import { createTransformContext } from \"../api/transform-context.js\";\nimport { componentsType } from \"../application/transform/document/components.js\";\nimport { renameTakenAliases } from \"../application/transform/document/root-type-aliases.js\";\nimport type { IrType, IrTypeAliasDeclaration } from \"../domain/ir/nodes.js\";\nimport { isEnumSchema, singularizeComponentKind } from \"../domain/openapi/components-object.js\";\nimport type { ComponentsObject, GlobalContext } from \"../types.js\";\n\nexport { isEnumSchema };\n\n/** `requestBodies` → `requestBody`; other keys drop the final `s`. */\nexport const singularizeComponentKey = singularizeComponentKind;\n\n/**\n * Transform the ComponentsObject (4.8.7)\n * @see https://spec.openapis.org/oas/latest.html#components-object\n *\n * Ported to IR (ENGINEERING_PLAN Phase 5, step 6). Same name and parameters as the original;\n * returns IR (task 6.2). For the public API: the `components` type, then the root type aliases.\n */\nexport default function transformComponentsObject(\n componentsObject: ComponentsObject,\n ctx: GlobalContext,\n): (IrType | IrTypeAliasDeclaration)[] {\n const { type, rootTypes } = componentsType(componentsObject, createTransformContext(ctx));\n // No footer here: only the aliases the `root-type-numbering` fix keeps get numbers.\n return [type, ...renameTakenAliases(rootTypes, [])];\n}\n"],"names":["componentsType","createTransformContext","renameTakenAliases"],"mappings":";;;;;;;;AAmBA,SAAwB,yBAAA,CACtB,kBACA,GAAA,EACqC;AACrC,EAAA,MAAM,EAAE,MAAM,SAAA,EAAU,GAAIA,0BAAe,gBAAA,EAAkBC,uCAAA,CAAuB,GAAG,CAAC,CAAA;AAExF,EAAA,OAAO,CAAC,IAAA,EAAM,GAAGC,mCAAmB,SAAA,EAAW,EAAE,CAAC,CAAA;AACpD;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createTransformContext } from '../api/transform-context.mjs';
|
|
2
2
|
import { componentsType } from '../application/transform/document/components.mjs';
|
|
3
|
+
import { renameTakenAliases } from '../application/transform/document/root-type-aliases.mjs';
|
|
3
4
|
|
|
4
5
|
function transformComponentsObject(componentsObject, ctx) {
|
|
5
6
|
const { type, rootTypes } = componentsType(componentsObject, createTransformContext(ctx));
|
|
6
|
-
return [type, ...rootTypes];
|
|
7
|
+
return [type, ...renameTakenAliases(rootTypes, [])];
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export { transformComponentsObject as default };
|