openapi-typesafe 0.0.0 → 1.0.0-rc.0
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/LICENSE +22 -0
- package/README.md +71 -1
- package/bin/cli.js +4 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +46 -0
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -0
- package/dist/adapters/node-file-system/node-file-system.mjs +40 -0
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -0
- package/dist/adapters/redocly-loader/alias-limit.cjs +16 -0
- package/dist/adapters/redocly-loader/alias-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/alias-limit.mjs +14 -0
- package/dist/adapters/redocly-loader/alias-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/allowed-hosts.cjs +42 -0
- package/dist/adapters/redocly-loader/allowed-hosts.cjs.map +1 -0
- package/dist/adapters/redocly-loader/allowed-hosts.mjs +40 -0
- package/dist/adapters/redocly-loader/allowed-hosts.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +53 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +51 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -0
- package/dist/adapters/redocly-loader/malformed-refs.cjs +41 -0
- package/dist/adapters/redocly-loader/malformed-refs.cjs.map +1 -0
- package/dist/adapters/redocly-loader/malformed-refs.mjs +38 -0
- package/dist/adapters/redocly-loader/malformed-refs.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs +42 -0
- package/dist/adapters/redocly-loader/redocly-config-source.cjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-config-source.mjs +35 -0
- package/dist/adapters/redocly-loader/redocly-config-source.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +169 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +167 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-access.cjs +107 -0
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-access.mjs +99 -0
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-holders.cjs +31 -0
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-holders.mjs +29 -0
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +60 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.mjs +56 -0
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +87 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +77 -0
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-source.cjs +104 -0
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-source.mjs +98 -0
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -0
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +62 -0
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -0
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +58 -0
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -0
- package/dist/adapters/terminal-logger/terminal-logger.cjs +67 -0
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -0
- package/dist/adapters/terminal-logger/terminal-logger.mjs +59 -0
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.cjs +21 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.mjs +17 -0
- package/dist/adapters/type-ast-bridge/footer-nodes.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.cjs +75 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.mjs +71 -0
- package/dist/adapters/type-ast-bridge/ir-declarations-to-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +145 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +139 -0
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/lazy-node.cjs +23 -0
- package/dist/adapters/type-ast-bridge/lazy-node.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/lazy-node.mjs +21 -0
- package/dist/adapters/type-ast-bridge/lazy-node.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/load-typescript.cjs +57 -0
- package/dist/adapters/type-ast-bridge/load-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/load-typescript.mjs +51 -0
- package/dist/adapters/type-ast-bridge/load-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/print-typescript.cjs +21 -0
- package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/print-typescript.mjs +19 -0
- package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.cjs +33 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.mjs +29 -0
- package/dist/adapters/type-ast-bridge/typescript-raw-text.mjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs +204 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.cjs.map +1 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs +201 -0
- package/dist/adapters/type-ast-bridge/typescript-to-ir.mjs.map +1 -0
- package/dist/api/ast-to-string.cjs +39 -0
- package/dist/api/ast-to-string.cjs.map +1 -0
- package/dist/api/ast-to-string.mjs +37 -0
- package/dist/api/ast-to-string.mjs.map +1 -0
- package/dist/api/comment-header.cjs +11 -0
- package/dist/api/comment-header.cjs.map +1 -0
- package/dist/api/comment-header.mjs +9 -0
- package/dist/api/comment-header.mjs.map +1 -0
- package/dist/api/default-ports.cjs +38 -0
- package/dist/api/default-ports.cjs.map +1 -0
- package/dist/api/default-ports.mjs +28 -0
- package/dist/api/default-ports.mjs.map +1 -0
- package/dist/api/discriminator-enum.cjs +44 -0
- package/dist/api/discriminator-enum.cjs.map +1 -0
- package/dist/api/discriminator-enum.mjs +42 -0
- package/dist/api/discriminator-enum.mjs.map +1 -0
- package/dist/api/discriminator-scan.cjs +168 -0
- package/dist/api/discriminator-scan.cjs.map +1 -0
- package/dist/api/discriminator-scan.mjs +165 -0
- package/dist/api/discriminator-scan.mjs.map +1 -0
- package/dist/api/document-declarations.cjs +28 -0
- package/dist/api/document-declarations.cjs.map +1 -0
- package/dist/api/document-declarations.mjs +26 -0
- package/dist/api/document-declarations.mjs.map +1 -0
- package/dist/api/document-refs.cjs +53 -0
- package/dist/api/document-refs.cjs.map +1 -0
- package/dist/api/document-refs.mjs +50 -0
- package/dist/api/document-refs.mjs.map +1 -0
- package/dist/api/document-run.cjs +107 -0
- package/dist/api/document-run.cjs.map +1 -0
- package/dist/api/document-run.mjs +101 -0
- package/dist/api/document-run.mjs.map +1 -0
- package/dist/api/footer-entry.cjs +18 -0
- package/dist/api/footer-entry.cjs.map +1 -0
- package/dist/api/footer-entry.mjs +15 -0
- package/dist/api/footer-entry.mjs.map +1 -0
- package/dist/api/footer-sink.cjs +53 -0
- package/dist/api/footer-sink.cjs.map +1 -0
- package/dist/api/footer-sink.mjs +51 -0
- package/dist/api/footer-sink.mjs.map +1 -0
- package/dist/api/legacy-callback-warning.cjs +25 -0
- package/dist/api/legacy-callback-warning.cjs.map +1 -0
- package/dist/api/legacy-callback-warning.mjs +22 -0
- package/dist/api/legacy-callback-warning.mjs.map +1 -0
- package/dist/api/legacy-ts-helpers.cjs +203 -0
- package/dist/api/legacy-ts-helpers.cjs.map +1 -0
- package/dist/api/legacy-ts-helpers.mjs +187 -0
- package/dist/api/legacy-ts-helpers.mjs.map +1 -0
- package/dist/api/legacy-utils.cjs +65 -0
- package/dist/api/legacy-utils.cjs.map +1 -0
- package/dist/api/legacy-utils.mjs +50 -0
- package/dist/api/legacy-utils.mjs.map +1 -0
- package/dist/api/openapi-ts.cjs +40 -0
- package/dist/api/openapi-ts.cjs.map +1 -0
- package/dist/api/openapi-ts.mjs +34 -0
- package/dist/api/openapi-ts.mjs.map +1 -0
- package/dist/api/schema-callbacks.cjs +140 -0
- package/dist/api/schema-callbacks.cjs.map +1 -0
- package/dist/api/schema-callbacks.mjs +136 -0
- package/dist/api/schema-callbacks.mjs.map +1 -0
- package/dist/api/string-to-ast.cjs +21 -0
- package/dist/api/string-to-ast.cjs.map +1 -0
- package/dist/api/string-to-ast.mjs +18 -0
- package/dist/api/string-to-ast.mjs.map +1 -0
- package/dist/api/transform-context.cjs +82 -0
- package/dist/api/transform-context.cjs.map +1 -0
- package/dist/api/transform-context.mjs +65 -0
- package/dist/api/transform-context.mjs.map +1 -0
- package/dist/api/transform-schema.cjs +31 -0
- package/dist/api/transform-schema.cjs.map +1 -0
- package/dist/api/transform-schema.mjs +26 -0
- package/dist/api/transform-schema.mjs.map +1 -0
- package/dist/api/type-helpers.cjs +85 -0
- package/dist/api/type-helpers.cjs.map +1 -0
- package/dist/api/type-helpers.mjs +66 -0
- package/dist/api/type-helpers.mjs.map +1 -0
- package/dist/api/unsupported-feature-warnings.cjs +17 -0
- package/dist/api/unsupported-feature-warnings.cjs.map +1 -0
- package/dist/api/unsupported-feature-warnings.mjs +15 -0
- package/dist/api/unsupported-feature-warnings.mjs.map +1 -0
- package/dist/application/print/comment-writer.cjs +95 -0
- package/dist/application/print/comment-writer.cjs.map +1 -0
- package/dist/application/print/comment-writer.mjs +93 -0
- package/dist/application/print/comment-writer.mjs.map +1 -0
- package/dist/application/print/declaration-printer.cjs +83 -0
- package/dist/application/print/declaration-printer.cjs.map +1 -0
- package/dist/application/print/declaration-printer.mjs +81 -0
- package/dist/application/print/declaration-printer.mjs.map +1 -0
- package/dist/application/print/literal-text.cjs +52 -0
- package/dist/application/print/literal-text.cjs.map +1 -0
- package/dist/application/print/literal-text.mjs +48 -0
- package/dist/application/print/literal-text.mjs.map +1 -0
- package/dist/application/print/print-nodes.cjs +38 -0
- package/dist/application/print/print-nodes.cjs.map +1 -0
- package/dist/application/print/print-nodes.mjs +36 -0
- package/dist/application/print/print-nodes.mjs.map +1 -0
- package/dist/application/print/print-options.cjs +6 -0
- package/dist/application/print/print-options.cjs.map +1 -0
- package/dist/application/print/print-options.mjs +4 -0
- package/dist/application/print/print-options.mjs.map +1 -0
- package/dist/application/print/text-writer.cjs +63 -0
- package/dist/application/print/text-writer.cjs.map +1 -0
- package/dist/application/print/text-writer.mjs +60 -0
- package/dist/application/print/text-writer.mjs.map +1 -0
- package/dist/application/print/type-printer.cjs +214 -0
- package/dist/application/print/type-printer.cjs.map +1 -0
- package/dist/application/print/type-printer.mjs +210 -0
- package/dist/application/print/type-printer.mjs.map +1 -0
- package/dist/application/stack-overflow.cjs +36 -0
- package/dist/application/stack-overflow.cjs.map +1 -0
- package/dist/application/stack-overflow.mjs +31 -0
- package/dist/application/stack-overflow.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +104 -0
- package/dist/application/transform/document/components.cjs.map +1 -0
- package/dist/application/transform/document/components.mjs +102 -0
- package/dist/application/transform/document/components.mjs.map +1 -0
- package/dist/application/transform/document/defs-root.cjs +18 -0
- package/dist/application/transform/document/defs-root.cjs.map +1 -0
- package/dist/application/transform/document/defs-root.mjs +16 -0
- package/dist/application/transform/document/defs-root.mjs.map +1 -0
- package/dist/application/transform/document/document-member.cjs +13 -0
- package/dist/application/transform/document/document-member.cjs.map +1 -0
- package/dist/application/transform/document/document-member.mjs +11 -0
- package/dist/application/transform/document/document-member.mjs.map +1 -0
- package/dist/application/transform/document/document.cjs +86 -0
- package/dist/application/transform/document/document.cjs.map +1 -0
- package/dist/application/transform/document/document.mjs +83 -0
- package/dist/application/transform/document/document.mjs.map +1 -0
- package/dist/application/transform/document/header.cjs +27 -0
- package/dist/application/transform/document/header.cjs.map +1 -0
- package/dist/application/transform/document/header.mjs +25 -0
- package/dist/application/transform/document/header.mjs.map +1 -0
- package/dist/application/transform/document/kept-deprecated.cjs +96 -0
- package/dist/application/transform/document/kept-deprecated.cjs.map +1 -0
- package/dist/application/transform/document/kept-deprecated.mjs +94 -0
- package/dist/application/transform/document/kept-deprecated.mjs.map +1 -0
- package/dist/application/transform/document/media-type.cjs +42 -0
- package/dist/application/transform/document/media-type.cjs.map +1 -0
- package/dist/application/transform/document/media-type.mjs +38 -0
- package/dist/application/transform/document/media-type.mjs.map +1 -0
- package/dist/application/transform/document/operation.cjs +45 -0
- package/dist/application/transform/document/operation.cjs.map +1 -0
- package/dist/application/transform/document/operation.mjs +43 -0
- package/dist/application/transform/document/operation.mjs.map +1 -0
- package/dist/application/transform/document/parameter.cjs +25 -0
- package/dist/application/transform/document/parameter.cjs.map +1 -0
- package/dist/application/transform/document/parameter.mjs +23 -0
- package/dist/application/transform/document/parameter.mjs.map +1 -0
- package/dist/application/transform/document/parameters.cjs +114 -0
- package/dist/application/transform/document/parameters.cjs.map +1 -0
- package/dist/application/transform/document/parameters.mjs +112 -0
- package/dist/application/transform/document/parameters.mjs.map +1 -0
- package/dist/application/transform/document/path-item-conflicts.cjs +51 -0
- package/dist/application/transform/document/path-item-conflicts.cjs.map +1 -0
- package/dist/application/transform/document/path-item-conflicts.mjs +49 -0
- package/dist/application/transform/document/path-item-conflicts.mjs.map +1 -0
- package/dist/application/transform/document/path-item.cjs +82 -0
- package/dist/application/transform/document/path-item.cjs.map +1 -0
- package/dist/application/transform/document/path-item.mjs +80 -0
- package/dist/application/transform/document/path-item.mjs.map +1 -0
- package/dist/application/transform/document/path-key-overlaps.cjs +57 -0
- package/dist/application/transform/document/path-key-overlaps.cjs.map +1 -0
- package/dist/application/transform/document/path-key-overlaps.mjs +55 -0
- package/dist/application/transform/document/path-key-overlaps.mjs.map +1 -0
- package/dist/application/transform/document/paths-enum.cjs +75 -0
- package/dist/application/transform/document/paths-enum.cjs.map +1 -0
- package/dist/application/transform/document/paths-enum.mjs +72 -0
- package/dist/application/transform/document/paths-enum.mjs.map +1 -0
- package/dist/application/transform/document/paths.cjs +127 -0
- package/dist/application/transform/document/paths.cjs.map +1 -0
- package/dist/application/transform/document/paths.mjs +125 -0
- package/dist/application/transform/document/paths.mjs.map +1 -0
- package/dist/application/transform/document/request-body.cjs +36 -0
- package/dist/application/transform/document/request-body.cjs.map +1 -0
- package/dist/application/transform/document/request-body.mjs +34 -0
- package/dist/application/transform/document/request-body.mjs.map +1 -0
- package/dist/application/transform/document/response.cjs +59 -0
- package/dist/application/transform/document/response.cjs.map +1 -0
- package/dist/application/transform/document/response.mjs +57 -0
- package/dist/application/transform/document/response.mjs.map +1 -0
- package/dist/application/transform/document/responses.cjs +23 -0
- package/dist/application/transform/document/responses.cjs.map +1 -0
- package/dist/application/transform/document/responses.mjs +21 -0
- package/dist/application/transform/document/responses.mjs.map +1 -0
- package/dist/application/transform/document/root-type-aliases.cjs +69 -0
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -0
- package/dist/application/transform/document/root-type-aliases.mjs +65 -0
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -0
- package/dist/application/transform/document/webhooks.cjs +19 -0
- package/dist/application/transform/document/webhooks.cjs.map +1 -0
- package/dist/application/transform/document/webhooks.mjs +17 -0
- package/dist/application/transform/document/webhooks.mjs.map +1 -0
- package/dist/application/transform/document-entries.cjs +17 -0
- package/dist/application/transform/document-entries.cjs.map +1 -0
- package/dist/application/transform/document-entries.mjs +14 -0
- package/dist/application/transform/document-entries.mjs.map +1 -0
- package/dist/application/transform/footer/document-footer.cjs +88 -0
- package/dist/application/transform/footer/document-footer.cjs.map +1 -0
- package/dist/application/transform/footer/document-footer.mjs +86 -0
- package/dist/application/transform/footer/document-footer.mjs.map +1 -0
- package/dist/application/transform/footer/enum-naming.cjs +121 -0
- package/dist/application/transform/footer/enum-naming.cjs.map +1 -0
- package/dist/application/transform/footer/enum-naming.mjs +115 -0
- package/dist/application/transform/footer/enum-naming.mjs.map +1 -0
- package/dist/application/transform/helper-types.cjs +68 -0
- package/dist/application/transform/helper-types.cjs.map +1 -0
- package/dist/application/transform/helper-types.mjs +65 -0
- package/dist/application/transform/helper-types.mjs.map +1 -0
- package/dist/application/transform/literal-type.cjs +36 -0
- package/dist/application/transform/literal-type.cjs.map +1 -0
- package/dist/application/transform/literal-type.mjs +34 -0
- package/dist/application/transform/literal-type.mjs.map +1 -0
- package/dist/application/transform/numbered-names.cjs +18 -0
- package/dist/application/transform/numbered-names.cjs.map +1 -0
- package/dist/application/transform/numbered-names.mjs +16 -0
- package/dist/application/transform/numbered-names.mjs.map +1 -0
- package/dist/application/transform/ref-type.cjs +57 -0
- package/dist/application/transform/ref-type.cjs.map +1 -0
- package/dist/application/transform/ref-type.mjs +54 -0
- package/dist/application/transform/ref-type.mjs.map +1 -0
- package/dist/application/transform/schema/array-type.cjs +105 -0
- package/dist/application/transform/schema/array-type.cjs.map +1 -0
- package/dist/application/transform/schema/array-type.mjs +103 -0
- package/dist/application/transform/schema/array-type.mjs.map +1 -0
- package/dist/application/transform/schema/composition-type.cjs +107 -0
- package/dist/application/transform/schema/composition-type.cjs.map +1 -0
- package/dist/application/transform/schema/composition-type.mjs +105 -0
- package/dist/application/transform/schema/composition-type.mjs.map +1 -0
- package/dist/application/transform/schema/core-type.cjs +84 -0
- package/dist/application/transform/schema/core-type.cjs.map +1 -0
- package/dist/application/transform/schema/core-type.mjs +82 -0
- package/dist/application/transform/schema/core-type.mjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.cjs +21 -0
- package/dist/application/transform/schema/discriminator-property.cjs.map +1 -0
- package/dist/application/transform/schema/discriminator-property.mjs +19 -0
- package/dist/application/transform/schema/discriminator-property.mjs.map +1 -0
- package/dist/application/transform/schema/enum-rule.cjs +107 -0
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -0
- package/dist/application/transform/schema/enum-rule.mjs +105 -0
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +173 -0
- package/dist/application/transform/schema/object-type.cjs.map +1 -0
- package/dist/application/transform/schema/object-type.mjs +170 -0
- package/dist/application/transform/schema/object-type.mjs.map +1 -0
- package/dist/application/transform/schema/presence-members.cjs +59 -0
- package/dist/application/transform/schema/presence-members.cjs.map +1 -0
- package/dist/application/transform/schema/presence-members.mjs +57 -0
- package/dist/application/transform/schema/presence-members.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +72 -0
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.mjs +68 -0
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -0
- package/dist/application/transform/schema/unevaluated-properties.cjs +61 -0
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -0
- package/dist/application/transform/schema/unevaluated-properties.mjs +59 -0
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -0
- package/dist/application/transform/schema-comment.cjs +84 -0
- package/dist/application/transform/schema-comment.cjs.map +1 -0
- package/dist/application/transform/schema-comment.mjs +81 -0
- package/dist/application/transform/schema-comment.mjs.map +1 -0
- package/dist/application/transform/shared-types.cjs +8 -0
- package/dist/application/transform/shared-types.cjs.map +1 -0
- package/dist/application/transform/shared-types.mjs +6 -0
- package/dist/application/transform/shared-types.mjs.map +1 -0
- package/dist/application/transform/type-combinators.cjs +49 -0
- package/dist/application/transform/type-combinators.cjs.map +1 -0
- package/dist/application/transform/type-combinators.mjs +42 -0
- package/dist/application/transform/type-combinators.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +137 -0
- package/dist/cli/cli-arguments.cjs.map +1 -0
- package/dist/cli/cli-arguments.mjs +129 -0
- package/dist/cli/cli-arguments.mjs.map +1 -0
- package/dist/cli/cli-errors.cjs +80 -0
- package/dist/cli/cli-errors.cjs.map +1 -0
- package/dist/cli/cli-errors.mjs +76 -0
- package/dist/cli/cli-errors.mjs.map +1 -0
- package/dist/cli/cli-output.cjs +37 -0
- package/dist/cli/cli-output.cjs.map +1 -0
- package/dist/cli/cli-output.mjs +30 -0
- package/dist/cli/cli-output.mjs.map +1 -0
- package/dist/cli/docs-links.cjs +6 -0
- package/dist/cli/docs-links.cjs.map +1 -0
- package/dist/cli/docs-links.mjs +4 -0
- package/dist/cli/docs-links.mjs.map +1 -0
- package/dist/cli/fix-option.cjs +19 -0
- package/dist/cli/fix-option.cjs.map +1 -0
- package/dist/cli/fix-option.mjs +16 -0
- package/dist/cli/fix-option.mjs.map +1 -0
- package/dist/cli/help-text.cjs +44 -0
- package/dist/cli/help-text.cjs.map +1 -0
- package/dist/cli/help-text.mjs +42 -0
- package/dist/cli/help-text.mjs.map +1 -0
- package/dist/cli/main.cjs +62 -0
- package/dist/cli/main.cjs.map +1 -0
- package/dist/cli/main.d.cts +2 -0
- package/dist/cli/main.d.mts +2 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.mjs +54 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cli/redocly-apis.cjs +65 -0
- package/dist/cli/redocly-apis.cjs.map +1 -0
- package/dist/cli/redocly-apis.mjs +62 -0
- package/dist/cli/redocly-apis.mjs.map +1 -0
- package/dist/cli/ref-limits.cjs +14 -0
- package/dist/cli/ref-limits.cjs.map +1 -0
- package/dist/cli/ref-limits.mjs +12 -0
- package/dist/cli/ref-limits.mjs.map +1 -0
- package/dist/cli/run-cli.cjs +100 -0
- package/dist/cli/run-cli.cjs.map +1 -0
- package/dist/cli/run-cli.mjs +98 -0
- package/dist/cli/run-cli.mjs.map +1 -0
- package/dist/domain/assert-never.cjs +8 -0
- package/dist/domain/assert-never.cjs.map +1 -0
- package/dist/domain/assert-never.mjs +6 -0
- package/dist/domain/assert-never.mjs.map +1 -0
- package/dist/domain/errors.cjs +50 -0
- package/dist/domain/errors.cjs.map +1 -0
- package/dist/domain/errors.mjs +46 -0
- package/dist/domain/errors.mjs.map +1 -0
- package/dist/domain/ir/constructors.cjs +89 -0
- package/dist/domain/ir/constructors.cjs.map +1 -0
- package/dist/domain/ir/constructors.mjs +71 -0
- package/dist/domain/ir/constructors.mjs.map +1 -0
- package/dist/domain/ir/identifier-text.cjs +29 -0
- package/dist/domain/ir/identifier-text.cjs.map +1 -0
- package/dist/domain/ir/identifier-text.mjs +25 -0
- package/dist/domain/ir/identifier-text.mjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs +109 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.mjs +106 -0
- package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -0
- package/dist/domain/ir/normalize.cjs +32 -0
- package/dist/domain/ir/normalize.cjs.map +1 -0
- package/dist/domain/ir/normalize.mjs +29 -0
- package/dist/domain/ir/normalize.mjs.map +1 -0
- package/dist/domain/ir/property-name.cjs +19 -0
- package/dist/domain/ir/property-name.cjs.map +1 -0
- package/dist/domain/ir/property-name.mjs +16 -0
- package/dist/domain/ir/property-name.mjs.map +1 -0
- package/dist/domain/ir/raw-text-escapes.cjs +25 -0
- package/dist/domain/ir/raw-text-escapes.cjs.map +1 -0
- package/dist/domain/ir/raw-text-escapes.mjs +22 -0
- package/dist/domain/ir/raw-text-escapes.mjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.cjs +50 -0
- package/dist/domain/openapi/alias-expansion.cjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.mjs +45 -0
- package/dist/domain/openapi/alias-expansion.mjs.map +1 -0
- package/dist/domain/openapi/binary-content.cjs +48 -0
- package/dist/domain/openapi/binary-content.cjs.map +1 -0
- package/dist/domain/openapi/binary-content.mjs +45 -0
- package/dist/domain/openapi/binary-content.mjs.map +1 -0
- package/dist/domain/openapi/components-object.cjs +29 -0
- package/dist/domain/openapi/components-object.cjs.map +1 -0
- package/dist/domain/openapi/components-object.mjs +24 -0
- package/dist/domain/openapi/components-object.mjs.map +1 -0
- package/dist/domain/openapi/json-pointer.cjs +31 -0
- package/dist/domain/openapi/json-pointer.cjs.map +1 -0
- package/dist/domain/openapi/json-pointer.mjs +27 -0
- package/dist/domain/openapi/json-pointer.mjs.map +1 -0
- package/dist/domain/openapi/media-type-object.cjs +14 -0
- package/dist/domain/openapi/media-type-object.cjs.map +1 -0
- package/dist/domain/openapi/media-type-object.mjs +11 -0
- package/dist/domain/openapi/media-type-object.mjs.map +1 -0
- package/dist/domain/openapi/parameter-object.cjs +13 -0
- package/dist/domain/openapi/parameter-object.cjs.map +1 -0
- package/dist/domain/openapi/parameter-object.mjs +10 -0
- package/dist/domain/openapi/parameter-object.mjs.map +1 -0
- package/dist/domain/openapi/path-item-object.cjs +35 -0
- package/dist/domain/openapi/path-item-object.cjs.map +1 -0
- package/dist/domain/openapi/path-item-object.mjs +30 -0
- package/dist/domain/openapi/path-item-object.mjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.cjs +87 -0
- package/dist/domain/openapi/unsupported-features.cjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.mjs +84 -0
- package/dist/domain/openapi/unsupported-features.mjs.map +1 -0
- package/dist/domain/output-fixes.cjs +66 -0
- package/dist/domain/output-fixes.cjs.map +1 -0
- package/dist/domain/output-fixes.mjs +59 -0
- package/dist/domain/output-fixes.mjs.map +1 -0
- package/dist/index.cjs +98 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +812 -0
- package/dist/index.d.mts +812 -0
- package/dist/index.d.ts +812 -0
- package/dist/index.mjs +27 -0
- package/dist/index.mjs.map +1 -0
- package/dist/transform/components-object.cjs +14 -0
- package/dist/transform/components-object.cjs.map +1 -0
- package/dist/transform/components-object.mjs +10 -0
- package/dist/transform/components-object.mjs.map +1 -0
- package/dist/transform/header-object.cjs +12 -0
- package/dist/transform/header-object.cjs.map +1 -0
- package/dist/transform/header-object.mjs +10 -0
- package/dist/transform/header-object.mjs.map +1 -0
- package/dist/transform/media-type-object.cjs +12 -0
- package/dist/transform/media-type-object.cjs.map +1 -0
- package/dist/transform/media-type-object.mjs +10 -0
- package/dist/transform/media-type-object.mjs.map +1 -0
- package/dist/transform/operation-object.cjs +26 -0
- package/dist/transform/operation-object.cjs.map +1 -0
- package/dist/transform/operation-object.mjs +21 -0
- package/dist/transform/operation-object.mjs.map +1 -0
- package/dist/transform/parameter-object.cjs +12 -0
- package/dist/transform/parameter-object.cjs.map +1 -0
- package/dist/transform/parameter-object.mjs +10 -0
- package/dist/transform/parameter-object.mjs.map +1 -0
- package/dist/transform/path-item-object.cjs +12 -0
- package/dist/transform/path-item-object.cjs.map +1 -0
- package/dist/transform/path-item-object.mjs +10 -0
- package/dist/transform/path-item-object.mjs.map +1 -0
- package/dist/transform/paths-object.cjs +11 -0
- package/dist/transform/paths-object.cjs.map +1 -0
- package/dist/transform/paths-object.mjs +9 -0
- package/dist/transform/paths-object.mjs.map +1 -0
- package/dist/transform/request-body-object.cjs +12 -0
- package/dist/transform/request-body-object.cjs.map +1 -0
- package/dist/transform/request-body-object.mjs +10 -0
- package/dist/transform/request-body-object.mjs.map +1 -0
- package/dist/transform/response-object.cjs +12 -0
- package/dist/transform/response-object.cjs.map +1 -0
- package/dist/transform/response-object.mjs +10 -0
- package/dist/transform/response-object.mjs.map +1 -0
- package/dist/transform/responses-object.cjs +12 -0
- package/dist/transform/responses-object.cjs.map +1 -0
- package/dist/transform/responses-object.mjs +10 -0
- package/dist/transform/responses-object.mjs.map +1 -0
- package/dist/transform/schema-object.cjs +21 -0
- package/dist/transform/schema-object.cjs.map +1 -0
- package/dist/transform/schema-object.mjs +16 -0
- package/dist/transform/schema-object.mjs.map +1 -0
- package/package.json +115 -4
- package/src/adapters/node-file-system/node-file-system.ts +44 -0
- package/src/adapters/redocly-loader/alias-limit.ts +20 -0
- package/src/adapters/redocly-loader/allowed-hosts.ts +62 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +65 -0
- package/src/adapters/redocly-loader/malformed-refs.ts +61 -0
- package/src/adapters/redocly-loader/redocly-config-source.ts +43 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +246 -0
- package/src/adapters/redocly-loader/ref-access.ts +146 -0
- package/src/adapters/redocly-loader/ref-holders.ts +43 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +104 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +124 -0
- package/src/adapters/redocly-loader/schema-source.ts +151 -0
- package/src/adapters/redocly-loader/unsupported-keys.ts +102 -0
- package/src/adapters/terminal-logger/terminal-logger.ts +98 -0
- package/src/adapters/type-ast-bridge/footer-nodes.ts +38 -0
- package/src/adapters/type-ast-bridge/ir-declarations-to-typescript.ts +100 -0
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +220 -0
- package/src/adapters/type-ast-bridge/lazy-node.ts +24 -0
- package/src/adapters/type-ast-bridge/load-typescript.ts +84 -0
- package/src/adapters/type-ast-bridge/print-typescript.ts +33 -0
- package/src/adapters/type-ast-bridge/typescript-raw-text.ts +49 -0
- package/src/adapters/type-ast-bridge/typescript-to-ir.ts +280 -0
- package/src/adapters/type-ast-bridge/typescript-types.ts +8 -0
- package/src/api/ast-to-string.ts +59 -0
- package/src/api/comment-header.ts +7 -0
- package/src/api/default-ports.ts +44 -0
- package/src/api/discriminator-enum.ts +76 -0
- package/src/api/discriminator-scan.ts +272 -0
- package/src/api/document-declarations.ts +41 -0
- package/src/api/document-refs.ts +71 -0
- package/src/api/document-run.ts +159 -0
- package/src/api/footer-entry.ts +23 -0
- package/src/api/footer-sink.ts +67 -0
- package/src/api/legacy-callback-warning.ts +29 -0
- package/src/api/legacy-ts-helpers.ts +311 -0
- package/src/api/legacy-utils.ts +118 -0
- package/src/api/openapi-ts.ts +62 -0
- package/src/api/schema-callbacks.ts +211 -0
- package/src/api/string-to-ast.ts +27 -0
- package/src/api/transform-context.ts +87 -0
- package/src/api/transform-schema.ts +39 -0
- package/src/api/type-helpers.ts +130 -0
- package/src/api/unsupported-feature-warnings.ts +26 -0
- package/src/application/ports/file-system.ts +12 -0
- package/src/application/ports/logger.ts +16 -0
- package/src/application/ports/redocly-config-source.ts +16 -0
- package/src/application/ports/schema-loader.ts +32 -0
- package/src/application/print/comment-writer.ts +91 -0
- package/src/application/print/declaration-printer.ts +100 -0
- package/src/application/print/literal-text.ts +62 -0
- package/src/application/print/print-nodes.ts +62 -0
- package/src/application/print/print-options.ts +11 -0
- package/src/application/print/text-writer.ts +83 -0
- package/src/application/print/type-printer.ts +281 -0
- package/src/application/stack-overflow.ts +54 -0
- package/src/application/transform/document/components.ts +189 -0
- package/src/application/transform/document/defs-root.ts +25 -0
- package/src/application/transform/document/document-member.ts +20 -0
- package/src/application/transform/document/document.ts +157 -0
- package/src/application/transform/document/header.ts +34 -0
- package/src/application/transform/document/kept-deprecated.ts +135 -0
- package/src/application/transform/document/media-type.ts +78 -0
- package/src/application/transform/document/operation.ts +64 -0
- package/src/application/transform/document/parameter.ts +45 -0
- package/src/application/transform/document/parameters.ts +200 -0
- package/src/application/transform/document/path-item-conflicts.ts +79 -0
- package/src/application/transform/document/path-item.ts +168 -0
- package/src/application/transform/document/path-key-overlaps.ts +112 -0
- package/src/application/transform/document/paths-enum.ts +127 -0
- package/src/application/transform/document/paths.ts +211 -0
- package/src/application/transform/document/request-body.ts +50 -0
- package/src/application/transform/document/response.ts +109 -0
- package/src/application/transform/document/responses.ts +29 -0
- package/src/application/transform/document/root-type-aliases.ts +106 -0
- package/src/application/transform/document/webhooks.ts +22 -0
- package/src/application/transform/document-entries.ts +28 -0
- package/src/application/transform/footer/document-footer.ts +127 -0
- package/src/application/transform/footer/enum-naming.ts +181 -0
- package/src/application/transform/helper-types.ts +92 -0
- package/src/application/transform/literal-type.ts +54 -0
- package/src/application/transform/numbered-names.ts +20 -0
- package/src/application/transform/ref-type.ts +97 -0
- package/src/application/transform/schema/array-type.ts +152 -0
- package/src/application/transform/schema/composition-type.ts +183 -0
- package/src/application/transform/schema/core-type.ts +115 -0
- package/src/application/transform/schema/discriminator-property.ts +28 -0
- package/src/application/transform/schema/enum-rule.ts +157 -0
- package/src/application/transform/schema/object-type.ts +271 -0
- package/src/application/transform/schema/presence-members.ts +96 -0
- package/src/application/transform/schema/schema-context.ts +110 -0
- package/src/application/transform/schema/schema-rule.ts +29 -0
- package/src/application/transform/schema/schema-transform.ts +99 -0
- package/src/application/transform/schema/unevaluated-properties.ts +105 -0
- package/src/application/transform/schema-comment.ts +116 -0
- package/src/application/transform/shared-types.ts +9 -0
- package/src/application/transform/transform-context.ts +51 -0
- package/src/application/transform/type-combinators.ts +57 -0
- package/src/cli/cli-arguments.ts +198 -0
- package/src/cli/cli-dependencies.ts +42 -0
- package/src/cli/cli-errors.ts +125 -0
- package/src/cli/cli-output.ts +53 -0
- package/src/cli/docs-links.ts +6 -0
- package/src/cli/fix-option.ts +29 -0
- package/src/cli/help-text.ts +52 -0
- package/src/cli/main.ts +67 -0
- package/src/cli/redocly-apis.ts +91 -0
- package/src/cli/ref-limits.ts +16 -0
- package/src/cli/run-cli.ts +114 -0
- package/src/domain/assert-never.ts +8 -0
- package/src/domain/errors.ts +74 -0
- package/src/domain/ir/constructors.ts +137 -0
- package/src/domain/ir/identifier-text.ts +49 -0
- package/src/domain/ir/newer-identifier-ranges.ts +109 -0
- package/src/domain/ir/nodes.ts +224 -0
- package/src/domain/ir/normalize.ts +51 -0
- package/src/domain/ir/property-name.ts +28 -0
- package/src/domain/ir/raw-text-escapes.ts +37 -0
- package/src/domain/openapi/alias-expansion.ts +72 -0
- package/src/domain/openapi/binary-content.ts +74 -0
- package/src/domain/openapi/components-object.ts +52 -0
- package/src/domain/openapi/document-object.ts +12 -0
- package/src/domain/openapi/header-object.ts +9 -0
- package/src/domain/openapi/json-pointer.ts +46 -0
- package/src/domain/openapi/media-type-object.ts +26 -0
- package/src/domain/openapi/operation-object.ts +13 -0
- package/src/domain/openapi/parameter-object.ts +30 -0
- package/src/domain/openapi/path-item-object.ts +70 -0
- package/src/domain/openapi/request-body-object.ts +7 -0
- package/src/domain/openapi/response-object.ts +14 -0
- package/src/domain/openapi/schema-object.ts +59 -0
- package/src/domain/openapi/unsupported-features.ts +139 -0
- package/src/domain/output-fixes.ts +95 -0
- package/src/index.ts +67 -0
- package/src/transform/components-object.ts +25 -0
- package/src/transform/header-object.ts +19 -0
- package/src/transform/media-type-object.ts +19 -0
- package/src/transform/operation-object.ts +36 -0
- package/src/transform/parameter-object.ts +19 -0
- package/src/transform/parameters-array.ts +19 -0
- package/src/transform/path-item-object.ts +22 -0
- package/src/transform/paths-enum.ts +8 -0
- package/src/transform/paths-object.ts +15 -0
- package/src/transform/request-body-object.ts +19 -0
- package/src/transform/response-object.ts +19 -0
- package/src/transform/responses-object.ts +19 -0
- package/src/transform/schema-object.ts +36 -0
- package/src/transform/webhooks-object.ts +15 -0
- package/src/types/generator-options.ts +267 -0
- package/src/types/openapi-common.ts +100 -0
- package/src/types/openapi-document.ts +196 -0
- package/src/types/openapi-path-item.ts +130 -0
- package/src/types/openapi-request.ts +209 -0
- package/src/types/openapi-response.ts +81 -0
- package/src/types/openapi-schema.ts +169 -0
- package/src/types/openapi-security.ts +116 -0
- package/src/types.ts +12 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrObjectType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
+
import { createRef } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import type { Schema } from "../../../domain/openapi/schema-object.js";
|
|
6
|
+
import { transformSchema } from "../schema/schema-transform.js";
|
|
7
|
+
import type { TransformContext } from "../transform-context.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The root `$defs` type: one required member per named subschema, so `#/$defs/<name>` refs
|
|
11
|
+
* (`$defs["<name>"]`) resolve. The original transformed the whole `$defs` map as one schema,
|
|
12
|
+
* which gave `Record<string, never>` and made every such ref `never` (research/legacy-bugs.md,
|
|
13
|
+
* item 18).
|
|
14
|
+
*/
|
|
15
|
+
export function defsRootType(
|
|
16
|
+
defs: Readonly<Record<string, Schema>>,
|
|
17
|
+
context: TransformContext,
|
|
18
|
+
): IrObjectType {
|
|
19
|
+
const members = Object.entries(defs).map(([name, schema]) => {
|
|
20
|
+
const location = { path: createRef(["$defs", name]), schema };
|
|
21
|
+
const type = transformSchema(schema, location, context);
|
|
22
|
+
return irProperty(toPropertyName(name), type, { isReadonly: context.options.immutable });
|
|
23
|
+
});
|
|
24
|
+
return irObject(members);
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { irProperty } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
+
import { withSchemaComment } from "../schema-comment.js";
|
|
5
|
+
|
|
6
|
+
export interface DocumentMemberFlags {
|
|
7
|
+
readonly isReadonly: boolean;
|
|
8
|
+
readonly isOptional?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** A member named by a document map key (media type, header, status code), with its JSDoc. */
|
|
12
|
+
export function documentMember(
|
|
13
|
+
name: string,
|
|
14
|
+
type: IrType,
|
|
15
|
+
entry: unknown,
|
|
16
|
+
flags: DocumentMemberFlags,
|
|
17
|
+
): IrPropertySignature {
|
|
18
|
+
const property = irProperty(toPropertyName(name), type, flags);
|
|
19
|
+
return withSchemaComment(property, entry);
|
|
20
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { irKeyword, irRecord } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type {
|
|
3
|
+
IrDeclaration,
|
|
4
|
+
IrIntersectionType,
|
|
5
|
+
IrObjectType,
|
|
6
|
+
IrType,
|
|
7
|
+
IrTypeAliasDeclaration,
|
|
8
|
+
} from "../../../domain/ir/nodes.js";
|
|
9
|
+
import type { ComponentsObject } from "../../../domain/openapi/components-object.js";
|
|
10
|
+
import type { DocumentObject } from "../../../domain/openapi/document-object.js";
|
|
11
|
+
import type { PathsObject } from "../../../domain/openapi/path-item-object.js";
|
|
12
|
+
import { READ_WRITE_MARKER_TYPES } from "../helper-types.js";
|
|
13
|
+
import type { TransformContext, TransformOptions } from "../transform-context.js";
|
|
14
|
+
import { componentsType } from "./components.js";
|
|
15
|
+
import { defsRootType } from "./defs-root.js";
|
|
16
|
+
import { keptDeprecatedComponents } from "./kept-deprecated.js";
|
|
17
|
+
import { pathsType } from "./paths.js";
|
|
18
|
+
import { apiPathsEnumDeclaration } from "./paths-enum.js";
|
|
19
|
+
import { webhooksType } from "./webhooks.js";
|
|
20
|
+
|
|
21
|
+
/** The root types, in output order. */
|
|
22
|
+
const ROOT_KEYS = Object.freeze(["paths", "webhooks", "components", "$defs"] as const);
|
|
23
|
+
type RootKey = (typeof ROOT_KEYS)[number];
|
|
24
|
+
|
|
25
|
+
const OPERATIONS_NAME = "operations";
|
|
26
|
+
/** The type of a root without members: `Record<string, never>`. */
|
|
27
|
+
const EMPTY_ROOT_TYPE = irRecord(irKeyword("string"), irKeyword("never"));
|
|
28
|
+
|
|
29
|
+
/** A root's type and the declarations that follow it (the `--root-types` aliases). */
|
|
30
|
+
interface RootResult {
|
|
31
|
+
readonly type: IrType;
|
|
32
|
+
readonly aliases: readonly IrTypeAliasDeclaration[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type RootTransform = (
|
|
36
|
+
node: object,
|
|
37
|
+
context: TransformContext,
|
|
38
|
+
document: DocumentObject,
|
|
39
|
+
) => RootResult;
|
|
40
|
+
|
|
41
|
+
/** Without `--exclude-deprecated` nothing is left out, so the scan is skipped. */
|
|
42
|
+
function keptDeprecated(document: DocumentObject, context: TransformContext): ReadonlySet<object> {
|
|
43
|
+
return context.options.excludeDeprecated
|
|
44
|
+
? keptDeprecatedComponents(document, context.refs)
|
|
45
|
+
: new Set();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const ROOT_TRANSFORMS: Readonly<Record<RootKey, RootTransform>> = {
|
|
49
|
+
paths: (node, context) => ({ type: pathsType(node as PathsObject, context), aliases: [] }),
|
|
50
|
+
webhooks: (node, context) => ({ type: webhooksType(node as PathsObject, context), aliases: [] }),
|
|
51
|
+
components: (node, context, document) => {
|
|
52
|
+
const kept = keptDeprecated(document, context);
|
|
53
|
+
const { type, rootTypes } = componentsType(node as ComponentsObject, context, kept);
|
|
54
|
+
return { type, aliases: rootTypes };
|
|
55
|
+
},
|
|
56
|
+
$defs: (node, context) => ({
|
|
57
|
+
type: defsRootType(node as NonNullable<DocumentObject["$defs"]>, context),
|
|
58
|
+
aliases: [],
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
function emptyAlias(name: string): IrTypeAliasDeclaration {
|
|
63
|
+
return { kind: "typeAlias", name, isExported: true, type: EMPTY_ROOT_TYPE, comments: [] };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** A root type that declares something: an object with members, or an intersection of them. */
|
|
67
|
+
type RootBodyType = IrObjectType | IrIntersectionType;
|
|
68
|
+
|
|
69
|
+
function isRootBody(type: IrType): type is RootBodyType {
|
|
70
|
+
return (type.kind === "object" && type.members.length > 0) || type.kind === "intersection";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A root with members: an interface, or a type alias with `--export-type`. An intersection (the
|
|
75
|
+
* `paths` of overlapping `--path-params-as-types` keys) can only be a type alias.
|
|
76
|
+
*/
|
|
77
|
+
function rootDeclaration(
|
|
78
|
+
name: RootKey,
|
|
79
|
+
type: RootBodyType,
|
|
80
|
+
options: TransformOptions,
|
|
81
|
+
): IrDeclaration {
|
|
82
|
+
return options.exportType || type.kind === "intersection"
|
|
83
|
+
? { kind: "typeAlias", name, isExported: true, type, comments: [] }
|
|
84
|
+
: { kind: "interface", name, isExported: true, members: type.members, comments: [] };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The declarations of one root. A root that is missing, or whose type has no members, is
|
|
89
|
+
* `Record<string, never>`. Only an object type (or the `paths` intersection) counts as having
|
|
90
|
+
* members: a callback type the IR keeps as raw text does not (ADR-004).
|
|
91
|
+
*/
|
|
92
|
+
function rootDeclarations(
|
|
93
|
+
root: RootKey,
|
|
94
|
+
document: DocumentObject,
|
|
95
|
+
context: TransformContext,
|
|
96
|
+
): IrDeclaration[] {
|
|
97
|
+
const node: unknown = document[root];
|
|
98
|
+
if (!node || typeof node !== "object") {
|
|
99
|
+
context.diagnostics.debug(`${root} done (skipped)`, 0);
|
|
100
|
+
return [emptyAlias(root)];
|
|
101
|
+
}
|
|
102
|
+
const startedAt = context.diagnostics.now();
|
|
103
|
+
const { type, aliases } = ROOT_TRANSFORMS[root](node, context, document);
|
|
104
|
+
if (!isRootBody(type)) {
|
|
105
|
+
context.diagnostics.debug(`${root} done (skipped)`, 0);
|
|
106
|
+
return [emptyAlias(root), ...aliases];
|
|
107
|
+
}
|
|
108
|
+
const declaration = rootDeclaration(root, type, context.options);
|
|
109
|
+
context.diagnostics.debug(`${root} done`, context.diagnostics.now() - startedAt);
|
|
110
|
+
return [declaration, ...aliases];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The `inject` text as written (ADR-010, decision 4), without the blank lines around it. The
|
|
115
|
+
* original reprinted it with the TypeScript printer; text without code printed nothing then.
|
|
116
|
+
*/
|
|
117
|
+
function withoutBlankLinesAround(text: string): string {
|
|
118
|
+
return text.replace(/^(?:[ \t]*\r?\n)+/, "").trimEnd();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The document's declarations before the footer: helper types, injected code, then one root type
|
|
123
|
+
* per root key with the aliases that follow it.
|
|
124
|
+
*/
|
|
125
|
+
export function documentBody(document: DocumentObject, context: TransformContext): IrDeclaration[] {
|
|
126
|
+
const declarations: IrDeclaration[] = [];
|
|
127
|
+
if (context.options.readWriteMarkers) {
|
|
128
|
+
declarations.push({ kind: "rawDeclaration", text: READ_WRITE_MARKER_TYPES });
|
|
129
|
+
}
|
|
130
|
+
const inject = withoutBlankLinesAround(context.options.inject ?? "");
|
|
131
|
+
if (inject !== "") {
|
|
132
|
+
declarations.push({ kind: "rawDeclaration", text: inject });
|
|
133
|
+
}
|
|
134
|
+
for (const root of ROOT_KEYS) {
|
|
135
|
+
declarations.push(...rootDeclarations(root, document, context));
|
|
136
|
+
}
|
|
137
|
+
return declarations;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The declarations after the footer: an empty `operations` type when the footer has no
|
|
142
|
+
* operations, and the `--make-paths-enum` enum.
|
|
143
|
+
*/
|
|
144
|
+
export function documentClosing(
|
|
145
|
+
document: DocumentObject,
|
|
146
|
+
context: TransformContext,
|
|
147
|
+
hasOperations: boolean,
|
|
148
|
+
): IrDeclaration[] {
|
|
149
|
+
const declarations: IrDeclaration[] = [];
|
|
150
|
+
if (!hasOperations) {
|
|
151
|
+
declarations.push(emptyAlias(OPERATIONS_NAME));
|
|
152
|
+
}
|
|
153
|
+
if (context.options.makePathsEnum && document.paths) {
|
|
154
|
+
declarations.push(apiPathsEnumDeclaration(document.paths));
|
|
155
|
+
}
|
|
156
|
+
return declarations;
|
|
157
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { irObject } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import type { HeaderObject } from "../../../domain/openapi/header-object.js";
|
|
4
|
+
import { escapePointerSegment } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import { documentEntries } from "../document-entries.js";
|
|
6
|
+
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
7
|
+
import { transformSchema } from "../schema/schema-transform.js";
|
|
8
|
+
import { UNKNOWN_TYPE } from "../shared-types.js";
|
|
9
|
+
import { documentMember } from "./document-member.js";
|
|
10
|
+
import { contentEntryType } from "./media-type.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A header's type (OpenAPI 3.1 §4.8.21): its schema, else an object with one property per media
|
|
14
|
+
* type in `content`, else `unknown`.
|
|
15
|
+
*/
|
|
16
|
+
export function headerType(
|
|
17
|
+
header: HeaderObject,
|
|
18
|
+
location: SchemaLocation,
|
|
19
|
+
context: SchemaContext,
|
|
20
|
+
): IrType {
|
|
21
|
+
if (header.schema) {
|
|
22
|
+
return transformSchema(header.schema, location, context);
|
|
23
|
+
}
|
|
24
|
+
if (!header.content) {
|
|
25
|
+
return UNKNOWN_TYPE;
|
|
26
|
+
}
|
|
27
|
+
const members = documentEntries(header.content, context.options).map(([contentType, entry]) => {
|
|
28
|
+
// Unlike other content maps, the original joins this path by hand: a missing path is `#`.
|
|
29
|
+
const path = `${location.path ?? "#"}/${escapePointerSegment(contentType)}`;
|
|
30
|
+
const type = contentEntryType(entry, { ...location, path }, context);
|
|
31
|
+
return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
|
|
32
|
+
});
|
|
33
|
+
return irObject(members);
|
|
34
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_KINDS,
|
|
3
|
+
type ComponentsObject,
|
|
4
|
+
DECLARED_COMPONENT_KINDS,
|
|
5
|
+
} from "../../../domain/openapi/components-object.js";
|
|
6
|
+
import type { DocumentObject } from "../../../domain/openapi/document-object.js";
|
|
7
|
+
import { isDeprecated } from "../document-entries.js";
|
|
8
|
+
import type { RefResolver } from "../schema/schema-context.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `--exclude-deprecated` and references (roadmap R10.3, backlog 29). A deprecated component is
|
|
12
|
+
* left out, but a kept schema may still point to it (an array's `items`, say), and the output then
|
|
13
|
+
* names a missing `components` key. This scan finds the deprecated components that the kept output
|
|
14
|
+
* references, so they are kept too. It follows the generator's rules: a property, parameter or
|
|
15
|
+
* operation whose (resolved) object is deprecated is dropped, so its `$ref` does not count. Keys
|
|
16
|
+
* that are not typed are not followed, so a component they name stays out, as before.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Keys whose contents the generator does not type. */
|
|
20
|
+
const UNTYPED_KEYS: ReadonlySet<string> = new Set([
|
|
21
|
+
"callbacks",
|
|
22
|
+
"discriminator",
|
|
23
|
+
"example",
|
|
24
|
+
"examples",
|
|
25
|
+
"externalDocs",
|
|
26
|
+
"links",
|
|
27
|
+
"security",
|
|
28
|
+
"securitySchemes",
|
|
29
|
+
"servers",
|
|
30
|
+
"xml",
|
|
31
|
+
]);
|
|
32
|
+
const EXTENSION_PREFIX = "x-";
|
|
33
|
+
/** Keys whose entries the generator drops when the entry or its `$ref` target is deprecated. */
|
|
34
|
+
const RESOLVED_ENTRY_KEYS: ReadonlySet<string> = new Set([
|
|
35
|
+
"properties",
|
|
36
|
+
"parameters",
|
|
37
|
+
"get",
|
|
38
|
+
"put",
|
|
39
|
+
"post",
|
|
40
|
+
"delete",
|
|
41
|
+
"options",
|
|
42
|
+
"head",
|
|
43
|
+
"patch",
|
|
44
|
+
"trace",
|
|
45
|
+
"query",
|
|
46
|
+
]);
|
|
47
|
+
const COMPONENTS_PREFIX = "#/components/";
|
|
48
|
+
|
|
49
|
+
interface Scan {
|
|
50
|
+
readonly refs: RefResolver;
|
|
51
|
+
/** The deprecated components to keep, as the document's own objects. */
|
|
52
|
+
readonly kept: Set<object>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isObject(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
56
|
+
return typeof value === "object" && value !== null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function refOf(value: unknown): string | undefined {
|
|
60
|
+
return isObject(value) && typeof value.$ref === "string" ? value.$ref : undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Whether a dropped-when-deprecated entry is dropped: its own or its target's `deprecated`. */
|
|
64
|
+
function isDroppedEntry(value: unknown, scan: Scan): boolean {
|
|
65
|
+
const ref = refOf(value);
|
|
66
|
+
return isDeprecated(value) || (ref !== undefined && isDeprecated(scan.refs.resolve(ref)));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A `$ref` to a deprecated component keeps it, and the component is scanned once. */
|
|
70
|
+
function visitRef(ref: string, scan: Scan): void {
|
|
71
|
+
const target = ref.startsWith(COMPONENTS_PREFIX) ? scan.refs.resolve(ref) : undefined;
|
|
72
|
+
if (isObject(target) && isDeprecated(target) && !scan.kept.has(target)) {
|
|
73
|
+
scan.kept.add(target);
|
|
74
|
+
visitContents(target, scan);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function visitEntries(value: unknown, scan: Scan): void {
|
|
79
|
+
for (const entry of Array.isArray(value) ? value : Object.values(value as object)) {
|
|
80
|
+
if (!isDroppedEntry(entry, scan)) {
|
|
81
|
+
visit(entry, scan);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** A node of kept output; a deprecated object here is dropped, so it is not followed. */
|
|
87
|
+
function visit(node: unknown, scan: Scan): void {
|
|
88
|
+
if (Array.isArray(node)) {
|
|
89
|
+
for (const item of node) {
|
|
90
|
+
visit(item, scan);
|
|
91
|
+
}
|
|
92
|
+
} else if (isObject(node) && !isDeprecated(node)) {
|
|
93
|
+
visitContents(node, scan);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The `$ref` and the typed keys of an object. */
|
|
98
|
+
function visitContents(node: Readonly<Record<string, unknown>>, scan: Scan): void {
|
|
99
|
+
const ref = refOf(node);
|
|
100
|
+
if (ref !== undefined) {
|
|
101
|
+
visitRef(ref, scan);
|
|
102
|
+
}
|
|
103
|
+
for (const [key, value] of Object.entries(node)) {
|
|
104
|
+
if (UNTYPED_KEYS.has(key) || key.startsWith(EXTENSION_PREFIX) || !isObject(value)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (RESOLVED_ENTRY_KEYS.has(key)) {
|
|
108
|
+
visitEntries(key === "properties" || key === "parameters" ? value : [value], scan);
|
|
109
|
+
} else {
|
|
110
|
+
visit(value, scan);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The kept (not deprecated) entries of the typed component kinds. */
|
|
116
|
+
function keptComponentEntries(components: ComponentsObject | undefined): unknown[] {
|
|
117
|
+
const kinds = [...COMPONENT_KINDS, ...DECLARED_COMPONENT_KINDS];
|
|
118
|
+
return kinds.flatMap((kind) =>
|
|
119
|
+
Object.values(components?.[kind] ?? {}).filter((item) => !isDeprecated(item)),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The deprecated components that kept output references, as the objects of `document.components`
|
|
125
|
+
* (the resolver returns those), so names that need escaping in a `$ref` match too.
|
|
126
|
+
*/
|
|
127
|
+
export function keptDeprecatedComponents(
|
|
128
|
+
document: DocumentObject,
|
|
129
|
+
refs: RefResolver,
|
|
130
|
+
): ReadonlySet<object> {
|
|
131
|
+
const scan: Scan = { refs, kept: new Set() };
|
|
132
|
+
visit([document.paths, document.webhooks, document.$defs], scan);
|
|
133
|
+
visit(keptComponentEntries(document.components), scan);
|
|
134
|
+
return scan.kept;
|
|
135
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { irObject, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
+
import { createRef } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import {
|
|
6
|
+
type ContentMap,
|
|
7
|
+
isMediaTypeComponentRef,
|
|
8
|
+
type MediaTypeObject,
|
|
9
|
+
} from "../../../domain/openapi/media-type-object.js";
|
|
10
|
+
import { documentEntries } from "../document-entries.js";
|
|
11
|
+
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
12
|
+
import { transformSchema } from "../schema/schema-transform.js";
|
|
13
|
+
import { UNKNOWN_TYPE } from "../shared-types.js";
|
|
14
|
+
import { documentMember } from "./document-member.js";
|
|
15
|
+
|
|
16
|
+
/** The sibling of `content` that holds item types (ADR-020). */
|
|
17
|
+
const ITEM_CONTENT_KEY = "itemContent";
|
|
18
|
+
|
|
19
|
+
/** A media type's schema, or `unknown` when it has none (OpenAPI 3.1 §4.8.14). */
|
|
20
|
+
export function mediaTypeType(
|
|
21
|
+
mediaType: MediaTypeObject,
|
|
22
|
+
location: SchemaLocation,
|
|
23
|
+
context: SchemaContext,
|
|
24
|
+
): IrType {
|
|
25
|
+
return mediaType.schema ? transformSchema(mediaType.schema, location, context) : UNKNOWN_TYPE;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A `content` entry: a `$ref` is transformed like a schema `$ref`, the rest as a media type. */
|
|
29
|
+
export function contentEntryType(
|
|
30
|
+
entry: ContentMap[string],
|
|
31
|
+
location: SchemaLocation,
|
|
32
|
+
context: SchemaContext,
|
|
33
|
+
): IrType {
|
|
34
|
+
// `in` throws for a null entry, as in the original.
|
|
35
|
+
return "$ref" in entry
|
|
36
|
+
? transformSchema(entry, location, context)
|
|
37
|
+
: mediaTypeType(entry, location, context);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The `itemSchema` of a `content` entry and where it is, following a `$ref` to a component. */
|
|
41
|
+
function itemSchemaAt(
|
|
42
|
+
entry: ContentMap[string],
|
|
43
|
+
path: string,
|
|
44
|
+
context: SchemaContext,
|
|
45
|
+
): { readonly schema: MediaTypeObject["itemSchema"]; readonly path: string } {
|
|
46
|
+
if ("$ref" in entry) {
|
|
47
|
+
// Other `$ref`s in `content` keep their pre-3.2 output, so only media type components count.
|
|
48
|
+
const resolved = isMediaTypeComponentRef(entry.$ref)
|
|
49
|
+
? (context.refs.resolve(entry.$ref) as MediaTypeObject | undefined)
|
|
50
|
+
: undefined;
|
|
51
|
+
return { schema: resolved?.itemSchema, path: createRef([entry.$ref, "itemSchema"]) };
|
|
52
|
+
}
|
|
53
|
+
return { schema: entry.itemSchema, path: createRef([path, "itemSchema"]) };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* `itemContent`: the type of one item of each media type with an `itemSchema` (OpenAPI 3.2), next
|
|
58
|
+
* to `content`, which keeps the type of the complete body. Null when no media type has one.
|
|
59
|
+
*/
|
|
60
|
+
export function itemContentMember(
|
|
61
|
+
content: ContentMap,
|
|
62
|
+
location: SchemaLocation,
|
|
63
|
+
context: SchemaContext,
|
|
64
|
+
flags: { readonly isReadonly: boolean },
|
|
65
|
+
): IrPropertySignature | null {
|
|
66
|
+
const members = documentEntries(content, context.options).flatMap(([mediaType, entry]) => {
|
|
67
|
+
const contentPath = createRef([location.path, "content", mediaType]);
|
|
68
|
+
const item = itemSchemaAt(entry, contentPath, context);
|
|
69
|
+
if (item.schema === undefined) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const type = transformSchema(item.schema, { ...location, path: item.path }, context);
|
|
73
|
+
return [documentMember(mediaType, type, entry, { isReadonly: context.options.immutable })];
|
|
74
|
+
});
|
|
75
|
+
return members.length > 0
|
|
76
|
+
? irProperty(toPropertyName(ITEM_CONTENT_KEY), irObject(members), flags)
|
|
77
|
+
: null;
|
|
78
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { irKeyword, irProperty } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrPropertySignature } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import { toPropertyName } from "../../../domain/ir/property-name.js";
|
|
4
|
+
import { createRef } from "../../../domain/openapi/json-pointer.js";
|
|
5
|
+
import type { OperationObject } from "../../../domain/openapi/operation-object.js";
|
|
6
|
+
import type { RequestBodyObject } from "../../../domain/openapi/request-body-object.js";
|
|
7
|
+
import { refType } from "../ref-type.js";
|
|
8
|
+
import type { SchemaLocation } from "../schema/schema-context.js";
|
|
9
|
+
import type { TransformContext } from "../transform-context.js";
|
|
10
|
+
import { documentMember } from "./document-member.js";
|
|
11
|
+
import { parametersMember } from "./parameters.js";
|
|
12
|
+
import { requestBodyType } from "./request-body.js";
|
|
13
|
+
import { responsesType } from "./responses.js";
|
|
14
|
+
|
|
15
|
+
/** `requestBody`, optional unless the resolved body is required; `requestBody?: never` if none. */
|
|
16
|
+
function requestBodyMember(
|
|
17
|
+
operation: OperationObject,
|
|
18
|
+
location: SchemaLocation,
|
|
19
|
+
context: TransformContext,
|
|
20
|
+
): IrPropertySignature {
|
|
21
|
+
const isReadonly = context.options.immutable;
|
|
22
|
+
const body = operation.requestBody;
|
|
23
|
+
if (!body) {
|
|
24
|
+
return irProperty(toPropertyName("requestBody"), irKeyword("never"), {
|
|
25
|
+
isOptional: true,
|
|
26
|
+
isReadonly,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const isReference = "$ref" in body;
|
|
30
|
+
const type = isReference
|
|
31
|
+
? refType(body.$ref)
|
|
32
|
+
: requestBodyType(
|
|
33
|
+
body,
|
|
34
|
+
{ ...location, path: createRef([location.path, "requestBody"]) },
|
|
35
|
+
context,
|
|
36
|
+
);
|
|
37
|
+
const resolved = isReference
|
|
38
|
+
? (context.refs.resolve(body.$ref) as RequestBodyObject | undefined)
|
|
39
|
+
: body;
|
|
40
|
+
return documentMember("requestBody", type, body, {
|
|
41
|
+
isReadonly,
|
|
42
|
+
isOptional: !resolved?.required,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The members of an operation (OpenAPI 3.1 §4.8.10): `parameters`, `requestBody` and `responses`.
|
|
48
|
+
* `location.path` is the operation's pointer.
|
|
49
|
+
*/
|
|
50
|
+
export function operationMembers(
|
|
51
|
+
operation: OperationObject,
|
|
52
|
+
location: SchemaLocation,
|
|
53
|
+
context: TransformContext,
|
|
54
|
+
): IrPropertySignature[] {
|
|
55
|
+
// Built in document order: each part may add footer declarations (enums), in this order.
|
|
56
|
+
const parameters = parametersMember(operation.parameters ?? [], location, context);
|
|
57
|
+
const requestBody = requestBodyMember(operation, location, context);
|
|
58
|
+
const responses = responsesType(operation.responses ?? {}, location, context);
|
|
59
|
+
return [
|
|
60
|
+
parameters,
|
|
61
|
+
requestBody,
|
|
62
|
+
irProperty(toPropertyName("responses"), responses, { isReadonly: context.options.immutable }),
|
|
63
|
+
];
|
|
64
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { irKeyword } from "../../../domain/ir/constructors.js";
|
|
2
|
+
import type { IrType } from "../../../domain/ir/nodes.js";
|
|
3
|
+
import { createRef } from "../../../domain/openapi/json-pointer.js";
|
|
4
|
+
import {
|
|
5
|
+
type ParameterObject,
|
|
6
|
+
QUERYSTRING_LOCATION,
|
|
7
|
+
} from "../../../domain/openapi/parameter-object.js";
|
|
8
|
+
import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
|
|
9
|
+
import { transformSchema } from "../schema/schema-transform.js";
|
|
10
|
+
import { contentEntryType } from "./media-type.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An `in: querystring` parameter (OpenAPI 3.2): the whole query string, typed by the schema of its
|
|
14
|
+
* one `content` media type (ADR-020). Without one it is `string`, the query string as text.
|
|
15
|
+
*/
|
|
16
|
+
function querystringType(
|
|
17
|
+
parameter: ParameterObject,
|
|
18
|
+
location: SchemaLocation,
|
|
19
|
+
context: SchemaContext,
|
|
20
|
+
): IrType {
|
|
21
|
+
const [mediaType, entry] = Object.entries(parameter.content ?? {})[0] ?? [];
|
|
22
|
+
if (mediaType === undefined || entry === undefined) {
|
|
23
|
+
return irKeyword("string");
|
|
24
|
+
}
|
|
25
|
+
const path = createRef([location.path, "content", mediaType]);
|
|
26
|
+
return contentEntryType(entry, { ...location, path }, context);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:
|
|
31
|
+
* query, path, header and cookie values all arrive as text. `content` is read only for
|
|
32
|
+
* `in: querystring`; other parameters with `content` keep their pre-3.2 type.
|
|
33
|
+
*/
|
|
34
|
+
export function parameterType(
|
|
35
|
+
parameter: ParameterObject,
|
|
36
|
+
location: SchemaLocation,
|
|
37
|
+
context: SchemaContext,
|
|
38
|
+
): IrType {
|
|
39
|
+
if (parameter.in === QUERYSTRING_LOCATION) {
|
|
40
|
+
return querystringType(parameter, location, context);
|
|
41
|
+
}
|
|
42
|
+
return parameter.schema
|
|
43
|
+
? transformSchema(parameter.schema, location, context)
|
|
44
|
+
: irKeyword("string");
|
|
45
|
+
}
|