openapi-typesafe 1.0.0-rc.3 → 1.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1972 -0
- package/dist/adapters/node-file-system/file-claims.cjs +105 -0
- package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-claims.mjs +95 -0
- package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.cjs +82 -0
- package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
- package/dist/adapters/node-file-system/file-identity.mjs +74 -0
- package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
- package/dist/adapters/node-file-system/node-file-system.cjs +97 -14
- package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
- package/dist/adapters/node-file-system/node-file-system.mjs +97 -14
- package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs +19 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.cjs.map +1 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs +17 -0
- package/dist/adapters/pipe-safe-writer/pipe-safe-writer.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +48 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +45 -0
- package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
- package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
- package/dist/adapters/redocly-loader/component-schemas.cjs +17 -0
- package/dist/adapters/redocly-loader/component-schemas.cjs.map +1 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs +14 -0
- package/dist/adapters/redocly-loader/component-schemas.mjs.map +1 -0
- package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
- package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
- package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.cjs +22 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.cjs.map +1 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs +20 -0
- package/dist/adapters/redocly-loader/mapping-schema-names.mjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs +137 -0
- package/dist/adapters/redocly-loader/query-named-components.cjs.map +1 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs +134 -0
- package/dist/adapters/redocly-loader/query-named-components.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +40 -29
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +38 -27
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +45 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.cjs +52 -10
- package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-holders.mjs +53 -12
- package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
- package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
- package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -9
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-node-limit.cjs +61 -0
- package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs +58 -0
- package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.cjs +18 -9
- package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-source.mjs +20 -11
- package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +10 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +10 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/api/default-ports.cjs +14 -2
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +14 -2
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-enum-parent.cjs +2 -2
- package/dist/api/discriminator-enum-parent.cjs.map +1 -1
- package/dist/api/discriminator-enum-parent.mjs +3 -3
- package/dist/api/discriminator-enum-parent.mjs.map +1 -1
- package/dist/api/discriminator-other-owners.cjs +5 -3
- package/dist/api/discriminator-other-owners.cjs.map +1 -1
- package/dist/api/discriminator-other-owners.mjs +5 -3
- package/dist/api/discriminator-other-owners.mjs.map +1 -1
- package/dist/api/discriminator-patch.cjs +5 -1
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +5 -1
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +15 -8
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +15 -8
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-refs.cjs +16 -1
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +16 -1
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +6 -12
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +6 -12
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +9 -6
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +10 -8
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/ref-limit-options.cjs +63 -0
- package/dist/api/ref-limit-options.cjs.map +1 -0
- package/dist/api/ref-limit-options.mjs +57 -0
- package/dist/api/ref-limit-options.mjs.map +1 -0
- package/dist/api/schema-callbacks.cjs +36 -12
- package/dist/api/schema-callbacks.cjs.map +1 -1
- package/dist/api/schema-callbacks.mjs +36 -12
- package/dist/api/schema-callbacks.mjs.map +1 -1
- package/dist/api/transform-context.cjs +7 -3
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +7 -3
- package/dist/api/transform-context.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +47 -10
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +48 -11
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/application/print/text-writer.cjs +10 -3
- package/dist/application/print/text-writer.cjs.map +1 -1
- package/dist/application/print/text-writer.mjs +10 -3
- package/dist/application/print/text-writer.mjs.map +1 -1
- package/dist/application/stack-overflow.cjs +2 -1
- package/dist/application/stack-overflow.cjs.map +1 -1
- package/dist/application/stack-overflow.mjs +2 -1
- package/dist/application/stack-overflow.mjs.map +1 -1
- package/dist/application/transform/declared-value-types.cjs +36 -0
- package/dist/application/transform/declared-value-types.cjs.map +1 -0
- package/dist/application/transform/declared-value-types.mjs +34 -0
- package/dist/application/transform/declared-value-types.mjs.map +1 -0
- package/dist/application/transform/document/components.cjs +1 -1
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +2 -2
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/declared-type-names.cjs +23 -0
- package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
- package/dist/application/transform/document/declared-type-names.mjs +20 -0
- package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
- package/dist/application/transform/document/defs-root.cjs +1 -1
- package/dist/application/transform/document/defs-root.cjs.map +1 -1
- package/dist/application/transform/document/defs-root.mjs +2 -2
- package/dist/application/transform/document/defs-root.mjs.map +1 -1
- package/dist/application/transform/document/document.cjs +7 -2
- package/dist/application/transform/document/document.cjs.map +1 -1
- package/dist/application/transform/document/document.mjs +6 -3
- package/dist/application/transform/document/document.mjs.map +1 -1
- package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
- package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
- package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
- package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
- package/dist/application/transform/document/exploded-query-values.cjs +63 -0
- package/dist/application/transform/document/exploded-query-values.cjs.map +1 -0
- package/dist/application/transform/document/exploded-query-values.mjs +59 -0
- package/dist/application/transform/document/exploded-query-values.mjs.map +1 -0
- package/dist/application/transform/document/global-type-references.cjs +1 -0
- package/dist/application/transform/document/global-type-references.cjs.map +1 -1
- package/dist/application/transform/document/global-type-references.mjs +1 -1
- package/dist/application/transform/document/global-type-references.mjs.map +1 -1
- package/dist/application/transform/document/header.cjs +11 -3
- package/dist/application/transform/document/header.cjs.map +1 -1
- package/dist/application/transform/document/header.mjs +10 -2
- package/dist/application/transform/document/header.mjs.map +1 -1
- package/dist/application/transform/document/media-type.cjs +2 -2
- package/dist/application/transform/document/media-type.cjs.map +1 -1
- package/dist/application/transform/document/media-type.mjs +3 -3
- package/dist/application/transform/document/media-type.mjs.map +1 -1
- package/dist/application/transform/document/operation-keys-written.cjs +26 -0
- package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
- package/dist/application/transform/document/operation-keys-written.mjs +24 -0
- package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
- package/dist/application/transform/document/operation.cjs +1 -1
- package/dist/application/transform/document/operation.cjs.map +1 -1
- package/dist/application/transform/document/operation.mjs +2 -2
- package/dist/application/transform/document/operation.mjs.map +1 -1
- package/dist/application/transform/document/parameter-entries.cjs +34 -0
- package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
- package/dist/application/transform/document/parameter-entries.mjs +30 -0
- package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
- package/dist/application/transform/document/parameter.cjs +12 -4
- package/dist/application/transform/document/parameter.cjs.map +1 -1
- package/dist/application/transform/document/parameter.mjs +13 -5
- package/dist/application/transform/document/parameter.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +29 -34
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +29 -34
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/path-item.cjs +15 -17
- package/dist/application/transform/document/path-item.cjs.map +1 -1
- package/dist/application/transform/document/path-item.mjs +15 -19
- package/dist/application/transform/document/path-item.mjs.map +1 -1
- package/dist/application/transform/document/path-template-key.cjs +84 -0
- package/dist/application/transform/document/path-template-key.cjs.map +1 -0
- package/dist/application/transform/document/path-template-key.mjs +79 -0
- package/dist/application/transform/document/path-template-key.mjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.cjs +70 -0
- package/dist/application/transform/document/path-template-refs.cjs.map +1 -0
- package/dist/application/transform/document/path-template-refs.mjs +67 -0
- package/dist/application/transform/document/path-template-refs.mjs.map +1 -0
- package/dist/application/transform/document/paths-enum.cjs +8 -6
- package/dist/application/transform/document/paths-enum.cjs.map +1 -1
- package/dist/application/transform/document/paths-enum.mjs +8 -7
- package/dist/application/transform/document/paths-enum.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +43 -67
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +42 -68
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/document/referenced-parameter.cjs +80 -0
- package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
- package/dist/application/transform/document/referenced-parameter.mjs +78 -0
- package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
- package/dist/application/transform/document/request-body.cjs +1 -1
- package/dist/application/transform/document/request-body.cjs.map +1 -1
- package/dist/application/transform/document/request-body.mjs +2 -2
- package/dist/application/transform/document/request-body.mjs.map +1 -1
- package/dist/application/transform/document/response.cjs +2 -2
- package/dist/application/transform/document/response.cjs.map +1 -1
- package/dist/application/transform/document/response.mjs +3 -3
- package/dist/application/transform/document/response.mjs.map +1 -1
- package/dist/application/transform/document/responses.cjs +1 -1
- package/dist/application/transform/document/responses.cjs.map +1 -1
- package/dist/application/transform/document/responses.mjs +2 -2
- package/dist/application/transform/document/responses.mjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.cjs +8 -23
- package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
- package/dist/application/transform/document/root-type-aliases.mjs +8 -24
- package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
- package/dist/application/transform/document/type-resolution.cjs +3 -1
- package/dist/application/transform/document/type-resolution.cjs.map +1 -1
- package/dist/application/transform/document/type-resolution.mjs +3 -1
- package/dist/application/transform/document/type-resolution.mjs.map +1 -1
- package/dist/application/transform/document/webhooks.cjs +10 -3
- package/dist/application/transform/document/webhooks.cjs.map +1 -1
- package/dist/application/transform/document/webhooks.mjs +10 -3
- package/dist/application/transform/document/webhooks.mjs.map +1 -1
- package/dist/application/transform/footer/document-footer.cjs +16 -5
- package/dist/application/transform/footer/document-footer.cjs.map +1 -1
- package/dist/application/transform/footer/document-footer.mjs +16 -5
- package/dist/application/transform/footer/document-footer.mjs.map +1 -1
- package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
- package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
- package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
- package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.cjs +23 -0
- package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
- package/dist/application/transform/footer/operation-keys.mjs +21 -0
- package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
- package/dist/application/transform/footer/type-evaluation.cjs +4 -4
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.mjs +4 -4
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
- package/dist/application/transform/helper-types.cjs +3 -3
- package/dist/application/transform/helper-types.cjs.map +1 -1
- package/dist/application/transform/helper-types.mjs +3 -3
- package/dist/application/transform/helper-types.mjs.map +1 -1
- package/dist/application/transform/numbered-names.cjs +9 -0
- package/dist/application/transform/numbered-names.cjs.map +1 -1
- package/dist/application/transform/numbered-names.mjs +9 -1
- package/dist/application/transform/numbered-names.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.cjs +5 -5
- package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-location.mjs +3 -3
- package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.cjs +47 -66
- package/dist/application/transform/ref-pointer/generated-shape.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/generated-shape.mjs +36 -50
- package/dist/application/transform/ref-pointer/generated-shape.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.cjs +2 -2
- package/dist/application/transform/ref-pointer/inline-cycles.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs +1 -1
- package/dist/application/transform/ref-pointer/inline-cycles.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/located-node.cjs +23 -0
- package/dist/application/transform/ref-pointer/located-node.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/located-node.mjs +18 -0
- package/dist/application/transform/ref-pointer/located-node.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/original-index.cjs +68 -13
- package/dist/application/transform/ref-pointer/original-index.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/original-index.mjs +70 -15
- package/dist/application/transform/ref-pointer/original-index.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.cjs +54 -13
- package/dist/application/transform/ref-pointer/pointer-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-walk.mjs +46 -7
- package/dist/application/transform/ref-pointer/pointer-walk.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/property-shape.cjs +52 -0
- package/dist/application/transform/ref-pointer/property-shape.cjs.map +1 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs +45 -0
- package/dist/application/transform/ref-pointer/property-shape.mjs.map +1 -0
- package/dist/application/transform/ref-pointer/typed-walk.cjs +79 -21
- package/dist/application/transform/ref-pointer/typed-walk.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/typed-walk.mjs +76 -18
- package/dist/application/transform/ref-pointer/typed-walk.mjs.map +1 -1
- package/dist/application/transform/ref-type.cjs +2 -1
- package/dist/application/transform/ref-type.cjs.map +1 -1
- package/dist/application/transform/ref-type.mjs +2 -1
- package/dist/application/transform/ref-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +1 -1
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +2 -2
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +1 -1
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +2 -2
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/index-signature-type.cjs +21 -0
- package/dist/application/transform/schema/index-signature-type.cjs.map +1 -0
- package/dist/application/transform/schema/index-signature-type.mjs +19 -0
- package/dist/application/transform/schema/index-signature-type.mjs.map +1 -0
- package/dist/application/transform/schema/input-location.cjs +23 -0
- package/dist/application/transform/schema/input-location.cjs.map +1 -0
- package/dist/application/transform/schema/input-location.mjs +21 -0
- package/dist/application/transform/schema/input-location.mjs.map +1 -0
- package/dist/application/transform/schema/object-type.cjs +18 -8
- package/dist/application/transform/schema/object-type.cjs.map +1 -1
- package/dist/application/transform/schema/object-type.mjs +19 -9
- package/dist/application/transform/schema/object-type.mjs.map +1 -1
- package/dist/application/transform/schema/ref-siblings.cjs +47 -0
- package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
- package/dist/application/transform/schema/ref-siblings.mjs +45 -0
- package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
- package/dist/application/transform/schema/schema-transform.cjs +6 -3
- package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
- package/dist/application/transform/schema/schema-transform.mjs +6 -3
- package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +2 -30
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +3 -31
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +5 -1
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +5 -1
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/cli/api-logger.cjs +13 -0
- package/dist/cli/api-logger.cjs.map +1 -0
- package/dist/cli/api-logger.mjs +11 -0
- package/dist/cli/api-logger.mjs.map +1 -0
- package/dist/cli/api-settings.cjs +57 -9
- package/dist/cli/api-settings.cjs.map +1 -1
- package/dist/cli/api-settings.mjs +56 -11
- package/dist/cli/api-settings.mjs.map +1 -1
- package/dist/cli/api-writes.cjs +72 -0
- package/dist/cli/api-writes.cjs.map +1 -0
- package/dist/cli/api-writes.mjs +69 -0
- package/dist/cli/api-writes.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +51 -11
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +51 -11
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/cli-errors.cjs +29 -1
- package/dist/cli/cli-errors.cjs.map +1 -1
- package/dist/cli/cli-errors.mjs +29 -2
- package/dist/cli/cli-errors.mjs.map +1 -1
- package/dist/cli/cli-output.cjs +111 -4
- package/dist/cli/cli-output.cjs.map +1 -1
- package/dist/cli/cli-output.mjs +104 -5
- package/dist/cli/cli-output.mjs.map +1 -1
- package/dist/cli/main.cjs +13 -3
- package/dist/cli/main.cjs.map +1 -1
- package/dist/cli/main.mjs +14 -4
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +94 -37
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +99 -42
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/ref-limits.cjs +15 -1
- package/dist/cli/ref-limits.cjs.map +1 -1
- package/dist/cli/ref-limits.mjs +15 -2
- package/dist/cli/ref-limits.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +37 -14
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +39 -16
- package/dist/cli/run-cli.mjs.map +1 -1
- package/dist/domain/append-all.cjs +10 -0
- package/dist/domain/append-all.cjs.map +1 -0
- package/dist/domain/append-all.mjs +8 -0
- package/dist/domain/append-all.mjs.map +1 -0
- package/dist/domain/cause-secrets.cjs +52 -0
- package/dist/domain/cause-secrets.cjs.map +1 -0
- package/dist/domain/cause-secrets.mjs +50 -0
- package/dist/domain/cause-secrets.mjs.map +1 -0
- package/dist/domain/errors.cjs +11 -3
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +11 -3
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/identifier-text.cjs.map +1 -1
- package/dist/domain/ir/identifier-text.mjs +1 -1
- package/dist/domain/ir/identifier-text.mjs.map +1 -1
- package/dist/domain/ir/ir-shape.cjs +187 -0
- package/dist/domain/ir/ir-shape.cjs.map +1 -0
- package/dist/domain/ir/ir-shape.mjs +184 -0
- package/dist/domain/ir/ir-shape.mjs.map +1 -0
- package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
- package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
- package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
- package/dist/domain/location-text.cjs +9 -0
- package/dist/domain/location-text.cjs.map +1 -0
- package/dist/domain/location-text.mjs +7 -0
- package/dist/domain/location-text.mjs.map +1 -0
- package/dist/domain/openapi/alias-expansion.cjs +3 -1
- package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
- package/dist/domain/openapi/alias-expansion.mjs +3 -1
- package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.cjs +3 -3
- package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
- package/dist/domain/openapi/discriminated-union.mjs +4 -4
- package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
- package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
- package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
- package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
- package/dist/domain/openapi/document-places.cjs +55 -0
- package/dist/domain/openapi/document-places.cjs.map +1 -0
- package/dist/domain/openapi/document-places.mjs +53 -0
- package/dist/domain/openapi/document-places.mjs.map +1 -0
- package/dist/domain/openapi/json-pointer.cjs +43 -1
- package/dist/domain/openapi/json-pointer.cjs.map +1 -1
- package/dist/domain/openapi/json-pointer.mjs +40 -2
- package/dist/domain/openapi/json-pointer.mjs.map +1 -1
- package/dist/domain/openapi/schema-dialect.cjs +15 -0
- package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
- package/dist/domain/openapi/schema-dialect.mjs +12 -0
- package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
- package/dist/domain/openapi/unsupported-features.cjs +1 -1
- package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
- package/dist/domain/openapi/unsupported-features.mjs +2 -2
- package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
- package/dist/domain/output-fixes.cjs +20 -0
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +20 -0
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/terminal-text.cjs +31 -0
- package/dist/domain/terminal-text.cjs.map +1 -0
- package/dist/domain/terminal-text.mjs +29 -0
- package/dist/domain/terminal-text.mjs.map +1 -0
- package/dist/domain/url-secrets.cjs +48 -0
- package/dist/domain/url-secrets.cjs.map +1 -0
- package/dist/domain/url-secrets.mjs +45 -0
- package/dist/domain/url-secrets.mjs.map +1 -0
- package/dist/domain/warnings.cjs +1 -0
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +1 -0
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.d.cts +46 -20
- package/dist/index.d.mts +46 -20
- package/dist/index.d.ts +46 -20
- package/package.json +4 -5
- package/src/adapters/node-file-system/file-claims.ts +138 -0
- package/src/adapters/node-file-system/file-identity.ts +137 -0
- package/src/adapters/node-file-system/node-file-system.ts +158 -18
- package/src/adapters/pipe-safe-writer/pipe-safe-writer.ts +29 -0
- package/src/adapters/redocly-loader/bundled-mapping-copies.ts +60 -0
- package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
- package/src/adapters/redocly-loader/component-schemas.ts +19 -0
- package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
- package/src/adapters/redocly-loader/mapping-schema-names.ts +25 -0
- package/src/adapters/redocly-loader/query-named-components.ts +201 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +64 -38
- package/src/adapters/redocly-loader/ref-access.ts +51 -4
- package/src/adapters/redocly-loader/ref-holders.ts +76 -15
- package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +85 -13
- package/src/adapters/redocly-loader/remote-node-limit.ts +102 -0
- package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
- package/src/adapters/redocly-loader/schema-source.ts +35 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
- package/src/adapters/terminal-logger/terminal-logger.ts +17 -6
- package/src/api/default-ports.ts +33 -4
- package/src/api/discriminator-enum-parent.ts +3 -3
- package/src/api/discriminator-other-owners.ts +5 -3
- package/src/api/discriminator-patch.ts +5 -1
- package/src/api/discriminator-scan.ts +16 -8
- package/src/api/document-refs.ts +29 -1
- package/src/api/document-run.ts +10 -19
- package/src/api/legacy-utils.ts +5 -1
- package/src/api/openapi-ts.ts +26 -8
- package/src/api/ref-limit-options.ts +76 -0
- package/src/api/run-context.ts +3 -0
- package/src/api/schema-callbacks.ts +60 -17
- package/src/api/transform-context.ts +7 -3
- package/src/api/transform-schema.ts +79 -12
- package/src/application/ports/file-system.ts +47 -0
- package/src/application/ports/schema-loader.ts +11 -1
- package/src/application/print/text-writer.ts +10 -3
- package/src/application/stack-overflow.ts +9 -5
- package/src/application/transform/declared-value-types.ts +42 -0
- package/src/application/transform/document/components.ts +2 -2
- package/src/application/transform/document/declared-type-names.ts +36 -0
- package/src/application/transform/document/defs-root.ts +2 -2
- package/src/application/transform/document/document.ts +8 -5
- package/src/application/transform/document/enum-names-given-back.ts +91 -0
- package/src/application/transform/document/exploded-query-values.ts +88 -0
- package/src/application/transform/document/global-type-references.ts +1 -1
- package/src/application/transform/document/header.ts +25 -5
- package/src/application/transform/document/media-type.ts +4 -3
- package/src/application/transform/document/operation-keys-written.ts +27 -0
- package/src/application/transform/document/operation.ts +2 -2
- package/src/application/transform/document/parameter-entries.ts +70 -0
- package/src/application/transform/document/parameter.ts +21 -9
- package/src/application/transform/document/parameters.ts +56 -66
- package/src/application/transform/document/path-item.ts +16 -34
- package/src/application/transform/document/path-template-key.ts +152 -0
- package/src/application/transform/document/path-template-refs.ts +106 -0
- package/src/application/transform/document/paths-enum.ts +24 -10
- package/src/application/transform/document/paths.ts +59 -125
- package/src/application/transform/document/referenced-parameter.ts +146 -0
- package/src/application/transform/document/request-body.ts +2 -2
- package/src/application/transform/document/response.ts +3 -3
- package/src/application/transform/document/responses.ts +2 -2
- package/src/application/transform/document/root-type-aliases.ts +17 -38
- package/src/application/transform/document/type-resolution.ts +2 -1
- package/src/application/transform/document/webhooks.ts +19 -6
- package/src/application/transform/footer/document-footer.ts +36 -9
- package/src/application/transform/footer/enum-name-claims.ts +62 -0
- package/src/application/transform/footer/operation-keys.ts +28 -0
- package/src/application/transform/footer/type-evaluation.ts +4 -4
- package/src/application/transform/helper-types.ts +8 -7
- package/src/application/transform/numbered-names.ts +15 -0
- package/src/application/transform/ref-pointer/generated-location.ts +3 -3
- package/src/application/transform/ref-pointer/generated-shape.ts +67 -78
- package/src/application/transform/ref-pointer/inline-cycles.ts +1 -1
- package/src/application/transform/ref-pointer/located-node.ts +38 -0
- package/src/application/transform/ref-pointer/original-index.ts +100 -17
- package/src/application/transform/ref-pointer/pointer-type.ts +1 -1
- package/src/application/transform/ref-pointer/pointer-walk.ts +82 -8
- package/src/application/transform/ref-pointer/property-shape.ts +97 -0
- package/src/application/transform/ref-pointer/typed-walk.ts +117 -25
- package/src/application/transform/ref-type.ts +2 -1
- package/src/application/transform/schema/access-flags.ts +5 -2
- package/src/application/transform/schema/composition-type.ts +2 -2
- package/src/application/transform/schema/enum-rule.ts +6 -2
- package/src/application/transform/schema/index-signature-type.ts +31 -0
- package/src/application/transform/schema/input-location.ts +35 -0
- package/src/application/transform/schema/object-type.ts +22 -12
- package/src/application/transform/schema/ref-siblings.ts +76 -0
- package/src/application/transform/schema/schema-context.ts +3 -0
- package/src/application/transform/schema/schema-transform.ts +6 -3
- package/src/application/transform/schema/unevaluated-properties.ts +4 -44
- package/src/application/transform/schema-comment.ts +5 -1
- package/src/application/transform/transform-context.ts +5 -0
- package/src/cli/api-logger.ts +17 -0
- package/src/cli/api-settings.ts +80 -13
- package/src/cli/api-writes.ts +117 -0
- package/src/cli/cli-arguments.ts +90 -14
- package/src/cli/cli-dependencies.ts +26 -4
- package/src/cli/cli-errors.ts +42 -1
- package/src/cli/cli-output.ts +195 -15
- package/src/cli/main.ts +14 -5
- package/src/cli/redocly-apis.ts +177 -52
- package/src/cli/ref-limits.ts +21 -2
- package/src/cli/run-cli.ts +76 -15
- package/src/domain/append-all.ts +10 -0
- package/src/domain/cause-secrets.ts +86 -0
- package/src/domain/errors.ts +16 -5
- package/src/domain/ir/identifier-text.ts +6 -5
- package/src/domain/ir/ir-shape.ts +299 -0
- package/src/domain/ir/newer-identifier-ranges.ts +183 -30
- package/src/domain/location-text.ts +12 -0
- package/src/domain/openapi/alias-expansion.ts +4 -1
- package/src/domain/openapi/discriminated-union.ts +6 -4
- package/src/domain/openapi/discriminator-conflicts.ts +21 -7
- package/src/domain/openapi/document-object.ts +2 -0
- package/src/domain/openapi/document-places.ts +78 -0
- package/src/domain/openapi/json-pointer.ts +96 -7
- package/src/domain/openapi/schema-dialect.ts +22 -0
- package/src/domain/openapi/unsupported-features.ts +2 -2
- package/src/domain/output-fixes.ts +28 -2
- package/src/domain/terminal-text.ts +44 -0
- package/src/domain/url-secrets.ts +72 -0
- package/src/domain/warnings.ts +1 -0
- package/src/types/generator-options.ts +1 -1
- package/dist/cli/main.d.cts +0 -2
- package/dist/cli/main.d.mts +0 -2
- package/dist/cli/main.d.ts +0 -2
- package/dist/domain/url-credentials.cjs +0 -10
- package/dist/domain/url-credentials.cjs.map +0 -1
- package/dist/domain/url-credentials.mjs +0 -8
- package/dist/domain/url-credentials.mjs.map +0 -1
- package/src/domain/url-credentials.ts +0 -18
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { generatedMember } from "./generated-shape.js";
|
|
3
|
+
import { childLocation, followLocated, isJsonObject } from "./located-node.js";
|
|
3
4
|
import {
|
|
5
|
+
type ContentForm,
|
|
6
|
+
headerParameterContentForm,
|
|
7
|
+
isExcludedOperation,
|
|
4
8
|
isOptionalHeader,
|
|
5
9
|
isOptionalRequestBody,
|
|
6
10
|
isParameterList,
|
|
7
11
|
isTypedAsSchema,
|
|
8
|
-
|
|
12
|
+
leadingLocated,
|
|
9
13
|
leadingSegmentsOf,
|
|
10
14
|
type RefPointer,
|
|
11
15
|
startsInSchema,
|
|
@@ -22,6 +26,8 @@ type Step = "fails" | "compiles" | "continue";
|
|
|
22
26
|
|
|
23
27
|
interface OriginalWalk {
|
|
24
28
|
readonly node: unknown;
|
|
29
|
+
/** The node's JSON Pointer (`LocatedNode`). */
|
|
30
|
+
readonly location: string | undefined;
|
|
25
31
|
readonly isSchema: boolean;
|
|
26
32
|
}
|
|
27
33
|
|
|
@@ -35,7 +41,7 @@ function schemaStep(walk: OriginalWalk, segment: string, isLast: boolean, input:
|
|
|
35
41
|
if (segment === "properties") {
|
|
36
42
|
return { step: "continue" as Step, walk };
|
|
37
43
|
}
|
|
38
|
-
const member = generatedMember(walk
|
|
44
|
+
const member = generatedMember(walk, segment, input.options, input.refs);
|
|
39
45
|
if (member.kind === "missing") {
|
|
40
46
|
return { step: "fails" as Step, walk };
|
|
41
47
|
}
|
|
@@ -43,49 +49,126 @@ function schemaStep(walk: OriginalWalk, segment: string, isLast: boolean, input:
|
|
|
43
49
|
return { step: "compiles" as Step, walk };
|
|
44
50
|
}
|
|
45
51
|
const isAbsentValue = member.kind === "index" && member.node === undefined;
|
|
46
|
-
const isUnsafe =
|
|
52
|
+
const isUnsafe =
|
|
53
|
+
member.kind === "property" ? member.isOptional || member.isMarked : isAbsentValue;
|
|
47
54
|
return {
|
|
48
55
|
step: (isUnsafe && !isLast ? "fails" : "continue") as Step,
|
|
49
|
-
walk: { ...walk, node: member.node },
|
|
56
|
+
walk: { ...walk, node: member.node, location: member.location },
|
|
50
57
|
};
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
function containerStep(walk: OriginalWalk, index: number, input: WalkInput) {
|
|
54
61
|
const segment = input.pointer.segments[index] as string;
|
|
55
62
|
const isLast = index === input.pointer.segments.length - 1;
|
|
63
|
+
if (isExcludedOperation(input.pointer, index, walk.node, input)) {
|
|
64
|
+
return { step: "fails" as Step, walk };
|
|
65
|
+
}
|
|
56
66
|
const isOptional =
|
|
57
67
|
(segment === "requestBody" && isOptionalRequestBody(walk.node, input.refs)) ||
|
|
58
68
|
isOptionalHeader(input.pointer, index, walk.node);
|
|
59
69
|
if (isOptional && !isLast) {
|
|
60
70
|
return { step: "fails" as Step, walk };
|
|
61
71
|
}
|
|
62
|
-
const child =
|
|
72
|
+
const child = followLocated(
|
|
73
|
+
{
|
|
74
|
+
node: isJsonObject(walk.node) ? walk.node[segment] : undefined,
|
|
75
|
+
location: childLocation(walk.location, segment),
|
|
76
|
+
},
|
|
77
|
+
input.refs,
|
|
78
|
+
);
|
|
63
79
|
return {
|
|
64
|
-
step: (child === undefined ? "compiles" : "continue") as Step,
|
|
65
|
-
walk: { ...walk,
|
|
80
|
+
step: (child.node === undefined ? "compiles" : "continue") as Step,
|
|
81
|
+
walk: { ...walk, ...child },
|
|
66
82
|
};
|
|
67
83
|
}
|
|
68
84
|
|
|
85
|
+
/** The schema of the first media type of a `content` map, `$ref`s followed. */
|
|
86
|
+
function firstMediaTypeSchema(walk: OriginalWalk, refs: RefResolver): OriginalWalk | null {
|
|
87
|
+
const content = isJsonObject(walk.node) ? walk.node.content : undefined;
|
|
88
|
+
if (!isJsonObject(content)) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const [mediaType] = Object.keys(content);
|
|
92
|
+
if (mediaType === undefined) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const location = childLocation(childLocation(walk.location, "content"), mediaType);
|
|
96
|
+
const entry = followLocated({ node: content[mediaType], location }, refs);
|
|
97
|
+
return ownSchema({ ...entry, isSchema: false }, refs);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The schema a header or parameter is typed by, `$ref`s followed. */
|
|
101
|
+
function ownSchema(walk: OriginalWalk, refs: RefResolver): OriginalWalk {
|
|
102
|
+
const schema = isJsonObject(walk.node) ? walk.node.schema : undefined;
|
|
103
|
+
const location = childLocation(walk.location, "schema");
|
|
104
|
+
return { ...followLocated({ node: schema, location }, refs), isSchema: true };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The schema whose type a header or parameter is, when not its media type members. */
|
|
108
|
+
function contentSchema(
|
|
109
|
+
walk: OriginalWalk,
|
|
110
|
+
form: Exclude<ContentForm, "media-type-members">,
|
|
111
|
+
refs: RefResolver,
|
|
112
|
+
): OriginalWalk | null {
|
|
113
|
+
switch (form) {
|
|
114
|
+
case "first-media-type":
|
|
115
|
+
return firstMediaTypeSchema(walk, refs);
|
|
116
|
+
case "schema":
|
|
117
|
+
return ownSchema(walk, refs);
|
|
118
|
+
case "string":
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The original indexes the `content` of a header or parameter by name. The media type members
|
|
125
|
+
* have no `content` unless a media type is named so, and `string` and `unknown` (no media type)
|
|
126
|
+
* have none; the schema of the first media type, or the `schema` next to `content`, is walked on.
|
|
127
|
+
*/
|
|
128
|
+
function contentStep(walk: OriginalWalk, form: ContentForm, isLast: boolean, input: WalkInput) {
|
|
129
|
+
const content = isJsonObject(walk.node) ? walk.node.content : undefined;
|
|
130
|
+
if (form === "media-type-members") {
|
|
131
|
+
const hasMember = isJsonObject(content) && Object.hasOwn(content, "content");
|
|
132
|
+
return { step: (hasMember ? "compiles" : "fails") as Step, walk };
|
|
133
|
+
}
|
|
134
|
+
const schema = contentSchema(walk, form, input.refs);
|
|
135
|
+
return schema === null
|
|
136
|
+
? { step: "fails" as Step, walk }
|
|
137
|
+
: schemaStep(schema, "content", isLast, input);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* A step outside a schema: a header's or parameter's `content`, a schema's container, or another.
|
|
142
|
+
*/
|
|
143
|
+
function documentStep(walk: OriginalWalk, index: number, input: WalkInput) {
|
|
144
|
+
const segment = input.pointer.segments[index] as string;
|
|
145
|
+
const isLast = index === input.pointer.segments.length - 1;
|
|
146
|
+
const form = headerParameterContentForm(input.pointer, index, walk.node, input.options);
|
|
147
|
+
if (form !== null) {
|
|
148
|
+
return contentStep(walk, form, isLast, input);
|
|
149
|
+
}
|
|
150
|
+
if (isTypedAsSchema(input.pointer, index) && isJsonObject(walk.node)) {
|
|
151
|
+
// The container's type is its schema's type: the segment indexes that type.
|
|
152
|
+
return schemaStep(ownSchema(walk, input.refs), segment, isLast, input);
|
|
153
|
+
}
|
|
154
|
+
return containerStep(walk, index, input);
|
|
155
|
+
}
|
|
156
|
+
|
|
69
157
|
/** True when the original type of the `$ref` does not compile for sure. */
|
|
70
158
|
export function originalIndexFails(input: WalkInput): boolean {
|
|
71
159
|
const { segments } = input.pointer;
|
|
72
160
|
let walk: OriginalWalk = {
|
|
73
|
-
|
|
161
|
+
...leadingLocated(input.pointer, input.refs),
|
|
74
162
|
isSchema: startsInSchema(input.pointer),
|
|
75
163
|
};
|
|
76
164
|
for (let index = leadingSegmentsOf(input.pointer); index < segments.length; index++) {
|
|
77
|
-
const segment = segments[index] as string;
|
|
78
|
-
const isLast = index === segments.length - 1;
|
|
79
165
|
if (!walk.isSchema && isParameterList(input.pointer, index)) {
|
|
80
166
|
return true;
|
|
81
167
|
}
|
|
82
|
-
|
|
83
|
-
// The container's type is its schema's type: the segment indexes that type.
|
|
84
|
-
walk = { node: followRefs(walk.node.schema, input.refs), isSchema: true };
|
|
85
|
-
}
|
|
168
|
+
const isLast = index === segments.length - 1;
|
|
86
169
|
const result = walk.isSchema
|
|
87
|
-
? schemaStep(walk,
|
|
88
|
-
:
|
|
170
|
+
? schemaStep(walk, segments[index] as string, isLast, input)
|
|
171
|
+
: documentStep(walk, index, input);
|
|
89
172
|
if (result.step !== "continue") {
|
|
90
173
|
return result.step === "fails";
|
|
91
174
|
}
|
|
@@ -4,8 +4,8 @@ import { FIX } from "../../../domain/output-fixes.js";
|
|
|
4
4
|
import { InvalidRefError, refType } from "../ref-type.js";
|
|
5
5
|
import type { SchemaRequest } from "../schema/schema-rule.js";
|
|
6
6
|
import { generatedLocationOf } from "./generated-location.js";
|
|
7
|
-
import { isJsonObject } from "./generated-shape.js";
|
|
8
7
|
import { hasInlineCycle } from "./inline-cycles.js";
|
|
8
|
+
import { isJsonObject } from "./located-node.js";
|
|
9
9
|
import { originalIndexFails } from "./original-index.js";
|
|
10
10
|
import { leadingSegmentsOf, pointerNode, type RefPointer, refPointerOf } from "./pointer-walk.js";
|
|
11
11
|
import { typedWalk } from "./typed-walk.js";
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { placeOf } from "../../../domain/openapi/document-places.js";
|
|
2
|
+
import { parseRefPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
|
|
3
|
+
import { QUERYSTRING_LOCATION } from "../../../domain/openapi/parameter-object.js";
|
|
4
|
+
import { FIX } from "../../../domain/output-fixes.js";
|
|
5
|
+
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
6
|
+
import {
|
|
7
|
+
childLocation,
|
|
8
|
+
followLocated,
|
|
9
|
+
followRefs,
|
|
10
|
+
isJsonObject,
|
|
11
|
+
type LocatedNode,
|
|
12
|
+
} from "./located-node.js";
|
|
4
13
|
|
|
5
14
|
/** The parts of a `$ref` pointer that both the original and the new types walk. */
|
|
6
15
|
|
|
@@ -27,13 +36,18 @@ export function refPointerOf(ref: string): RefPointer | null {
|
|
|
27
36
|
return rootSegment === undefined ? null : { rootSegment, segments };
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
/** The document node at the end of the leading segments, `$ref`s followed. */
|
|
31
|
-
export function
|
|
32
|
-
let
|
|
39
|
+
/** The document node at the end of the leading segments, `$ref`s followed, with its location. */
|
|
40
|
+
export function leadingLocated(pointer: RefPointer, refs: RefResolver): LocatedNode {
|
|
41
|
+
let located: LocatedNode = {
|
|
42
|
+
node: refs.resolve(`#/${pointer.rootSegment}`),
|
|
43
|
+
location: childLocation(ROOT_POINTER, pointer.rootSegment),
|
|
44
|
+
};
|
|
33
45
|
for (const segment of pointer.segments.slice(0, leadingSegmentsOf(pointer))) {
|
|
34
|
-
|
|
46
|
+
const { node, location } = located;
|
|
47
|
+
const child = isJsonObject(node) ? node[segment] : undefined;
|
|
48
|
+
located = followLocated({ node: child, location: childLocation(location, segment) }, refs);
|
|
35
49
|
}
|
|
36
|
-
return
|
|
50
|
+
return located;
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
/** The node at the whole pointer, without following a `$ref` at its end. */
|
|
@@ -62,6 +76,47 @@ export function isTypedAsSchema(pointer: RefPointer, index: number): boolean {
|
|
|
62
76
|
return owner === "content" || owner === "headers" || isComponentParameter;
|
|
63
77
|
}
|
|
64
78
|
|
|
79
|
+
/**
|
|
80
|
+
* How the generated type of a header or component parameter holds its `content` (header.ts,
|
|
81
|
+
* parameter.ts): one member per media type, the type of the first media type, `string` (a
|
|
82
|
+
* parameter without the `parameter-header-content` fix), or not at all (a `schema` wins).
|
|
83
|
+
*/
|
|
84
|
+
export type ContentForm = "media-type-members" | "first-media-type" | "string" | "schema";
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The form of the `content` at `index` when it belongs to a header or a component parameter; null
|
|
88
|
+
* for any other segment. An `in: querystring` parameter is typed by its `content` even next to a
|
|
89
|
+
* `schema`.
|
|
90
|
+
*/
|
|
91
|
+
export function headerParameterContentForm(
|
|
92
|
+
pointer: RefPointer,
|
|
93
|
+
index: number,
|
|
94
|
+
owner: unknown,
|
|
95
|
+
options: SchemaOptions,
|
|
96
|
+
): ContentForm | null {
|
|
97
|
+
const isHeader = pointer.segments[index - 2] === "headers";
|
|
98
|
+
const isComponentParameter =
|
|
99
|
+
pointer.rootSegment === "components" && index === 2 && pointer.segments[0] === "parameters";
|
|
100
|
+
const isOwnContent = pointer.segments[index] === "content" && (isHeader || isComponentParameter);
|
|
101
|
+
if (!isOwnContent || !isJsonObject(owner)) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const isFixed = options.fixes.has(FIX.PARAMETER_HEADER_CONTENT);
|
|
105
|
+
if (isHeader) {
|
|
106
|
+
if (owner.schema) {
|
|
107
|
+
return "schema";
|
|
108
|
+
}
|
|
109
|
+
return isFixed ? "first-media-type" : "media-type-members";
|
|
110
|
+
}
|
|
111
|
+
if (owner.in === QUERYSTRING_LOCATION) {
|
|
112
|
+
return "first-media-type";
|
|
113
|
+
}
|
|
114
|
+
if (owner.schema !== undefined) {
|
|
115
|
+
return "schema";
|
|
116
|
+
}
|
|
117
|
+
return isFixed ? "first-media-type" : "string";
|
|
118
|
+
}
|
|
119
|
+
|
|
65
120
|
/**
|
|
66
121
|
* Whether the segment at `index` is an operation's or path item's `parameters` list, indexed by
|
|
67
122
|
* position next. The generated type groups parameters by `in` (`query`, `path`), so it has no
|
|
@@ -86,6 +141,25 @@ export function isOptionalHeader(pointer: RefPointer, index: number, headers: un
|
|
|
86
141
|
return isJsonObject(header) && header.$ref === undefined && header.required !== true;
|
|
87
142
|
}
|
|
88
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Whether the segment at `index` names an operation that `--exclude-deprecated` leaves out: the
|
|
146
|
+
* path item types it `never`, which has no member to index (`isIncludedOperation`).
|
|
147
|
+
*/
|
|
148
|
+
export function isExcludedOperation(
|
|
149
|
+
pointer: RefPointer,
|
|
150
|
+
index: number,
|
|
151
|
+
pathItem: unknown,
|
|
152
|
+
input: { readonly options: SchemaOptions; readonly refs: RefResolver },
|
|
153
|
+
): boolean {
|
|
154
|
+
const segments = [pointer.rootSegment, ...pointer.segments.slice(0, index + 1)];
|
|
155
|
+
if (!input.options.excludeDeprecated || placeOf(segments) !== "operation") {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const segment = pointer.segments[index] as string;
|
|
159
|
+
const operation = isJsonObject(pathItem) ? followRefs(pathItem[segment], input.refs) : undefined;
|
|
160
|
+
return isJsonObject(operation) && Boolean(operation.deprecated);
|
|
161
|
+
}
|
|
162
|
+
|
|
89
163
|
/** A `requestBody` the operation does not mark `required` is an optional member. */
|
|
90
164
|
export function isOptionalRequestBody(container: unknown, refs: RefResolver): boolean {
|
|
91
165
|
if (!isJsonObject(container) || container.requestBody === undefined) {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Schema } from "../../../domain/openapi/schema-object.js";
|
|
2
|
+
import { propertyAccessFlags } from "../schema/access-flags.js";
|
|
3
|
+
import { isInputLocation } from "../schema/input-location.js";
|
|
4
|
+
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
5
|
+
import {
|
|
6
|
+
followLocated,
|
|
7
|
+
followRefs,
|
|
8
|
+
isJsonObject,
|
|
9
|
+
type JsonObject,
|
|
10
|
+
type LocatedNode,
|
|
11
|
+
} from "./located-node.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What the generated type of an object schema makes of one of its properties: optional, left
|
|
15
|
+
* out, wrapped in a read or write marker, or a value that may be `undefined` or `null`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** `nullable: true` or a `type` list with `null`: the generated type includes `null`. */
|
|
19
|
+
export function isNullableSchema(node: unknown): boolean {
|
|
20
|
+
if (!isJsonObject(node)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return node.nullable === true || (Array.isArray(node.type) && node.type.includes("null"));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether the generated type has the property as optional, as `objectType` decides: a `default`
|
|
28
|
+
* makes a property required except in an input location, where the client may leave it out.
|
|
29
|
+
*/
|
|
30
|
+
export function isOptionalProperty(
|
|
31
|
+
owner: LocatedNode & { node: JsonObject },
|
|
32
|
+
key: string,
|
|
33
|
+
options: SchemaOptions,
|
|
34
|
+
): boolean {
|
|
35
|
+
const { node } = owner;
|
|
36
|
+
const required = Array.isArray(node.required) ? node.required : undefined;
|
|
37
|
+
const property = (node.properties as JsonObject)[key];
|
|
38
|
+
const hasDefault = isJsonObject(property) && property.default !== undefined;
|
|
39
|
+
const isDefaultRequired =
|
|
40
|
+
hasDefault && options.defaultNonNullable && !isInputLocation(owner.location, options.fixes);
|
|
41
|
+
const isRequired =
|
|
42
|
+
required?.includes(key) === true ||
|
|
43
|
+
(required === undefined && options.propertiesRequiredByDefault) ||
|
|
44
|
+
isDefaultRequired;
|
|
45
|
+
return !isRequired;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Whether `--exclude-deprecated` leaves the property out: its object, or the one its `$ref`
|
|
50
|
+
* names, is deprecated (`objectType`). The key is then not in the generated type at all.
|
|
51
|
+
*/
|
|
52
|
+
export function isExcludedProperty(
|
|
53
|
+
property: unknown,
|
|
54
|
+
options: SchemaOptions,
|
|
55
|
+
refs: RefResolver,
|
|
56
|
+
): boolean {
|
|
57
|
+
const resolved = followRefs(property, refs);
|
|
58
|
+
return options.excludeDeprecated && isJsonObject(resolved) && Boolean(resolved.deprecated);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether `--read-write-markers` wraps the type of a property or `$defs` member: one that is only
|
|
63
|
+
* `readOnly` or only `writeOnly` is `$Read<T>` or `$Write<T>` (object-type.ts).
|
|
64
|
+
*/
|
|
65
|
+
export function isMarkedProperty(value: unknown, options: SchemaOptions, refs: RefResolver) {
|
|
66
|
+
if (!options.readWriteMarkers || !isJsonObject(value)) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const flags = propertyAccessFlags(value as Schema, { options, refs });
|
|
70
|
+
return flags.isReadOnly !== flags.isWriteOnly;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Whether a value is there: `present`, `absent` (may be `undefined` or `null`) or `unknown`. */
|
|
74
|
+
export type Presence = "present" | "absent" | "unknown";
|
|
75
|
+
|
|
76
|
+
/** The presence of a value of `schema` itself: `absent` when its type includes `null`. */
|
|
77
|
+
export function schemaPresence(schema: unknown, refs: RefResolver): Presence {
|
|
78
|
+
return isNullableSchema(followRefs(schema, refs)) ? "absent" : "present";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The presence of property `key` of `schema`: optional or nullable is `absent`. */
|
|
82
|
+
export function propertyPresence(
|
|
83
|
+
schema: LocatedNode,
|
|
84
|
+
key: string,
|
|
85
|
+
options: SchemaOptions,
|
|
86
|
+
refs: RefResolver,
|
|
87
|
+
): Presence {
|
|
88
|
+
const owner = followLocated(schema, refs);
|
|
89
|
+
const { node } = owner;
|
|
90
|
+
const properties = isJsonObject(node) && isJsonObject(node.properties) ? node.properties : {};
|
|
91
|
+
if (!isJsonObject(node) || !Object.hasOwn(properties, key)) {
|
|
92
|
+
return "unknown";
|
|
93
|
+
}
|
|
94
|
+
return isOptionalProperty({ ...owner, node }, key, options)
|
|
95
|
+
? "absent"
|
|
96
|
+
: schemaPresence(properties[key], refs);
|
|
97
|
+
}
|
|
@@ -2,25 +2,34 @@ import { irIndexedAccess, irKeyword, irReference } from "../../../domain/ir/cons
|
|
|
2
2
|
import type { IrKeyword, IrType } from "../../../domain/ir/nodes.js";
|
|
3
3
|
import { indexBy, indexKeyword, rootType } from "../ref-type.js";
|
|
4
4
|
import type { RefResolver, SchemaOptions } from "../schema/schema-context.js";
|
|
5
|
+
import { isArrayShape, isObjectShape } from "./generated-shape.js";
|
|
5
6
|
import {
|
|
7
|
+
childLocation,
|
|
8
|
+
followLocated,
|
|
6
9
|
followRefs,
|
|
7
|
-
isArrayShape,
|
|
8
10
|
isJsonObject,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
propertyPresence,
|
|
12
|
-
schemaPresence,
|
|
13
|
-
} from "./generated-shape.js";
|
|
11
|
+
type LocatedNode,
|
|
12
|
+
} from "./located-node.js";
|
|
14
13
|
import {
|
|
14
|
+
type ContentForm,
|
|
15
|
+
headerParameterContentForm,
|
|
16
|
+
isExcludedOperation,
|
|
15
17
|
isOptionalHeader,
|
|
16
18
|
isOptionalRequestBody,
|
|
17
19
|
isParameterList,
|
|
18
20
|
isTypedAsSchema,
|
|
19
|
-
|
|
21
|
+
leadingLocated,
|
|
20
22
|
leadingSegmentsOf,
|
|
21
23
|
type RefPointer,
|
|
22
24
|
startsInSchema,
|
|
23
25
|
} from "./pointer-walk.js";
|
|
26
|
+
import {
|
|
27
|
+
isExcludedProperty,
|
|
28
|
+
isMarkedProperty,
|
|
29
|
+
type Presence,
|
|
30
|
+
propertyPresence,
|
|
31
|
+
schemaPresence,
|
|
32
|
+
} from "./property-shape.js";
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
35
|
* The type of a `$ref` pointer as the generated types have it: the `schema` of a media type,
|
|
@@ -36,9 +45,18 @@ export interface TypedWalk {
|
|
|
36
45
|
readonly type: IrType;
|
|
37
46
|
/** The document node the type stands for (not followed through a `$ref`). */
|
|
38
47
|
readonly node: unknown;
|
|
48
|
+
/** The node's JSON Pointer, where the generator writes its type (`LocatedNode`). */
|
|
49
|
+
readonly location: string | undefined;
|
|
39
50
|
readonly isSchema: boolean;
|
|
40
51
|
/** The segment is a property or `$defs` name, not a keyword. */
|
|
41
52
|
readonly isName: boolean;
|
|
53
|
+
/** The location of the map of names (`properties` or `$defs`) when `isName`. */
|
|
54
|
+
readonly namesLocation?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The node is the `content` of a header or parameter typed as its first media type, so the
|
|
57
|
+
* next segment must name that media type and adds no member.
|
|
58
|
+
*/
|
|
59
|
+
readonly isFirstMediaType?: boolean;
|
|
42
60
|
readonly presence: Presence;
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -58,19 +76,32 @@ function present(walk: TypedWalk): IrType {
|
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
function indexEntries(walk: TypedWalk, key: IrKeyword, keyword: string, refs: RefResolver) {
|
|
61
|
-
const owner =
|
|
62
|
-
const child = isJsonObject(owner) ? owner[keyword] : undefined;
|
|
79
|
+
const owner = followLocated(walk, refs);
|
|
80
|
+
const child = isJsonObject(owner.node) ? owner.node[keyword] : undefined;
|
|
63
81
|
return {
|
|
64
82
|
...walk,
|
|
65
83
|
type: irIndexedAccess(present(walk), irKeyword(key)),
|
|
66
84
|
node: child,
|
|
85
|
+
location: childLocation(owner.location, keyword),
|
|
67
86
|
presence: schemaPresence(child, refs),
|
|
68
87
|
};
|
|
69
88
|
}
|
|
70
89
|
|
|
90
|
+
/**
|
|
91
|
+
* A property `--exclude-deprecated` left out has no member to index, and the `$Read<T>` or
|
|
92
|
+
* `$Write<T>` of a marked property has no member but the marker's: such a pointer is typed in
|
|
93
|
+
* place.
|
|
94
|
+
*/
|
|
71
95
|
function nameStep(walk: TypedWalk, name: string, isLast: boolean, input: TypedWalkInput) {
|
|
72
|
-
const owner =
|
|
73
|
-
const
|
|
96
|
+
const owner = followLocated(walk, input.refs);
|
|
97
|
+
const { node } = owner;
|
|
98
|
+
const properties = isJsonObject(node) && isJsonObject(node.properties) ? node.properties : {};
|
|
99
|
+
const value = properties[name];
|
|
100
|
+
const { options, refs } = input;
|
|
101
|
+
const isMarkedOnTheWay = !isLast && isMarkedProperty(value, options, refs);
|
|
102
|
+
if (isExcludedProperty(value, options, refs) || isMarkedOnTheWay) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
74
105
|
const type =
|
|
75
106
|
walk.presence === "present"
|
|
76
107
|
? indexKeyword(walk.type, name, isLast)
|
|
@@ -78,19 +109,25 @@ function nameStep(walk: TypedWalk, name: string, isLast: boolean, input: TypedWa
|
|
|
78
109
|
return {
|
|
79
110
|
...walk,
|
|
80
111
|
type,
|
|
81
|
-
node:
|
|
112
|
+
node: value,
|
|
113
|
+
location: childLocation(walk.namesLocation, name),
|
|
82
114
|
isName: false,
|
|
83
|
-
presence: propertyPresence(walk
|
|
115
|
+
presence: propertyPresence(walk, name, input.options, input.refs),
|
|
84
116
|
};
|
|
85
117
|
}
|
|
86
118
|
|
|
87
119
|
/** `$defs` is optional (`NonNullable` when more follows); its members are present. */
|
|
88
|
-
function defsStep(walk: TypedWalk, owner:
|
|
89
|
-
const
|
|
120
|
+
function defsStep(walk: TypedWalk, owner: LocatedNode, isLast: boolean): TypedWalk {
|
|
121
|
+
const { node } = owner;
|
|
122
|
+
const defs = isJsonObject(node) && isJsonObject(node[DEFS_KEYWORD]) ? node[DEFS_KEYWORD] : {};
|
|
123
|
+
const namesLocation = childLocation(owner.location, DEFS_KEYWORD);
|
|
90
124
|
return {
|
|
91
125
|
...walk,
|
|
92
126
|
type: indexKeyword(present(walk), DEFS_KEYWORD, isLast),
|
|
127
|
+
// A node of its own, not in the document: its properties are the definitions.
|
|
93
128
|
node: { properties: defs, required: Object.keys(defs) },
|
|
129
|
+
location: namesLocation,
|
|
130
|
+
namesLocation,
|
|
94
131
|
isName: true,
|
|
95
132
|
presence: "present",
|
|
96
133
|
};
|
|
@@ -115,13 +152,13 @@ function hasKeywordMember(owner: unknown, segment: string): boolean {
|
|
|
115
152
|
}
|
|
116
153
|
|
|
117
154
|
function keywordStep(walk: TypedWalk, segment: string, isLast: boolean, input: TypedWalkInput) {
|
|
118
|
-
const owner =
|
|
119
|
-
if (!hasKeywordMember(owner, segment)) {
|
|
155
|
+
const owner = followLocated(walk, input.refs);
|
|
156
|
+
if (!hasKeywordMember(owner.node, segment)) {
|
|
120
157
|
return null;
|
|
121
158
|
}
|
|
122
159
|
switch (segment) {
|
|
123
160
|
case "properties":
|
|
124
|
-
return { ...walk, isName: true };
|
|
161
|
+
return { ...walk, isName: true, namesLocation: childLocation(owner.location, segment) };
|
|
125
162
|
case "items":
|
|
126
163
|
return indexEntries(walk, "number", "items", input.refs);
|
|
127
164
|
case "additionalProperties":
|
|
@@ -143,10 +180,65 @@ function containerStep(walk: TypedWalk, index: number, input: TypedWalkInput): T
|
|
|
143
180
|
...walk,
|
|
144
181
|
type: indexBy(present(walk), segment),
|
|
145
182
|
node: isJsonObject(owner) ? owner[segment] : undefined,
|
|
183
|
+
location: childLocation(followLocated(walk, input.refs).location, segment),
|
|
146
184
|
presence: isOptional ? "absent" : "present",
|
|
147
185
|
};
|
|
148
186
|
}
|
|
149
187
|
|
|
188
|
+
/**
|
|
189
|
+
* The `content` of a header or parameter: no member of its own, since the type holds its media
|
|
190
|
+
* types (or the first one's type). Untyped where the type is `string` or a `schema`'s, and as the
|
|
191
|
+
* last segment of the first media type form, whose type is not the map's.
|
|
192
|
+
*/
|
|
193
|
+
function contentStep(walk: TypedWalk, form: ContentForm, isLast: boolean, refs: RefResolver) {
|
|
194
|
+
const isMapTyped = form === "media-type-members" || (form === "first-media-type" && !isLast);
|
|
195
|
+
if (!isMapTyped) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const owner = followLocated(walk, refs);
|
|
199
|
+
return {
|
|
200
|
+
...walk,
|
|
201
|
+
node: isJsonObject(owner.node) ? owner.node.content : undefined,
|
|
202
|
+
location: childLocation(owner.location, "content"),
|
|
203
|
+
isFirstMediaType: form === "first-media-type",
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The first media type of such a `content` is the type itself; another one has no type. */
|
|
208
|
+
function firstMediaTypeStep(walk: TypedWalk, segment: string): TypedWalk | null {
|
|
209
|
+
const content = isJsonObject(walk.node) ? walk.node : {};
|
|
210
|
+
if (Object.keys(content)[0] !== segment) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const location = childLocation(walk.location, segment);
|
|
214
|
+
return { ...walk, node: content[segment], location, isFirstMediaType: false };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function schemaStep(walk: TypedWalk, refs: RefResolver): TypedWalk {
|
|
218
|
+
const owner = followLocated(walk, refs);
|
|
219
|
+
const schema = isJsonObject(owner.node) ? owner.node.schema : undefined;
|
|
220
|
+
const location = childLocation(owner.location, "schema");
|
|
221
|
+
// The container's type is its schema's type: an optional header stays optional.
|
|
222
|
+
const presence = walk.presence === "absent" ? "absent" : schemaPresence(schema, refs);
|
|
223
|
+
return { ...walk, node: schema, location, isSchema: true, presence };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function documentStep(walk: TypedWalk, index: number, input: TypedWalkInput): TypedWalk | null {
|
|
227
|
+
const owner = followRefs(walk.node, input.refs);
|
|
228
|
+
const form = headerParameterContentForm(input.pointer, index, owner, input.options);
|
|
229
|
+
if (form !== null) {
|
|
230
|
+
const isLast = index === input.pointer.segments.length - 1;
|
|
231
|
+
return contentStep(walk, form, isLast, input.refs);
|
|
232
|
+
}
|
|
233
|
+
if (
|
|
234
|
+
isParameterList(input.pointer, index) ||
|
|
235
|
+
isExcludedOperation(input.pointer, index, owner, input)
|
|
236
|
+
) {
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
return containerStep(walk, index, input);
|
|
240
|
+
}
|
|
241
|
+
|
|
150
242
|
function step(walk: TypedWalk, index: number, input: TypedWalkInput): TypedWalk | null {
|
|
151
243
|
const { segments } = input.pointer;
|
|
152
244
|
const segment = segments[index] as string;
|
|
@@ -156,20 +248,19 @@ function step(walk: TypedWalk, index: number, input: TypedWalkInput): TypedWalk
|
|
|
156
248
|
? nameStep(walk, segment, isLast, input)
|
|
157
249
|
: keywordStep(walk, segment, isLast, input);
|
|
158
250
|
}
|
|
251
|
+
if (walk.isFirstMediaType) {
|
|
252
|
+
return firstMediaTypeStep(walk, segment);
|
|
253
|
+
}
|
|
159
254
|
if (segment === "schema" && isTypedAsSchema(input.pointer, index)) {
|
|
160
|
-
|
|
161
|
-
const schema = isJsonObject(owner) ? owner.schema : undefined;
|
|
162
|
-
// The container's type is its schema's type: an optional header stays optional.
|
|
163
|
-
const presence = walk.presence === "absent" ? "absent" : schemaPresence(schema, input.refs);
|
|
164
|
-
return { ...walk, node: schema, isSchema: true, presence };
|
|
255
|
+
return schemaStep(walk, input.refs);
|
|
165
256
|
}
|
|
166
|
-
return
|
|
257
|
+
return documentStep(walk, index, input);
|
|
167
258
|
}
|
|
168
259
|
|
|
169
260
|
/** Walk the whole pointer; see the module comment. */
|
|
170
261
|
export function typedWalk(input: TypedWalkInput): TypedWalkResult {
|
|
171
262
|
const { pointer } = input;
|
|
172
|
-
const node =
|
|
263
|
+
const { node, location } = leadingLocated(pointer, input.refs);
|
|
173
264
|
const isSchema = startsInSchema(pointer);
|
|
174
265
|
let walk: TypedWalk = {
|
|
175
266
|
type: indexBy(
|
|
@@ -177,6 +268,7 @@ export function typedWalk(input: TypedWalkInput): TypedWalkResult {
|
|
|
177
268
|
...pointer.segments.slice(0, leadingSegmentsOf(pointer)),
|
|
178
269
|
),
|
|
179
270
|
node,
|
|
271
|
+
location,
|
|
180
272
|
isSchema,
|
|
181
273
|
isName: false,
|
|
182
274
|
presence: isSchema ? schemaPresence(node, input.refs) : "present",
|
|
@@ -68,7 +68,8 @@ export function indexKeyword(type: IrType, segment: string, isLast: boolean): Ir
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export function rootType(rootSegment: string, isDeep: boolean): IrType {
|
|
71
|
-
|
|
71
|
+
const root = irReference(rootSegment);
|
|
72
|
+
return isDeep ? irReference("FlattenedDeepRequired", [root]) : root;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
/**
|
|
@@ -30,7 +30,7 @@ function merged(left: AccessFlags, right: AccessFlags): AccessFlags {
|
|
|
30
30
|
*/
|
|
31
31
|
function appliedFlags(
|
|
32
32
|
schema: Schema | undefined,
|
|
33
|
-
context: SchemaContext,
|
|
33
|
+
context: Pick<SchemaContext, "refs">,
|
|
34
34
|
seen: ReadonlySet<Schema>,
|
|
35
35
|
): AccessFlags {
|
|
36
36
|
if (typeof schema !== "object" || schema === null || seen.has(schema)) {
|
|
@@ -52,7 +52,10 @@ function appliedFlags(
|
|
|
52
52
|
* it count, as in openapi-typescript; with it, also those of the schemas its `$ref` and `allOf`
|
|
53
53
|
* apply (upstream #1938).
|
|
54
54
|
*/
|
|
55
|
-
export function propertyAccessFlags(
|
|
55
|
+
export function propertyAccessFlags(
|
|
56
|
+
value: Schema,
|
|
57
|
+
context: Pick<SchemaContext, "options" | "refs">,
|
|
58
|
+
): AccessFlags {
|
|
56
59
|
if (typeof value !== "object") {
|
|
57
60
|
return NO_FLAGS;
|
|
58
61
|
}
|