@redocly/openapi-core 1.18.1 → 1.20.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/CHANGELOG.md +22 -0
- package/__tests__/utils.ts +14 -7
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +7 -3
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +19 -15
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +1 -0
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +18 -14
- package/lib/benchmark/benches/recommended-oas3.bench.js +2 -2
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +2 -2
- package/lib/benchmark/utils.d.ts +3 -3
- package/lib/benchmark/utils.js +10 -7
- package/lib/bundle.d.ts +2 -2
- package/lib/bundle.js +127 -120
- package/lib/config/all.js +13 -1
- package/lib/config/builtIn.js +18 -17
- package/lib/config/config-resolvers.d.ts +1 -1
- package/lib/config/config-resolvers.js +241 -158
- package/lib/config/config.d.ts +4 -3
- package/lib/config/config.js +53 -34
- package/lib/config/load.d.ts +1 -1
- package/lib/config/load.js +105 -117
- package/lib/config/minimal.js +13 -0
- package/lib/config/recommended-strict.js +14 -1
- package/lib/config/recommended.js +14 -1
- package/lib/config/rules.d.ts +3 -3
- package/lib/config/rules.js +1 -2
- package/lib/config/types.d.ts +17 -4
- package/lib/config/utils.d.ts +3 -1
- package/lib/config/utils.js +78 -49
- package/lib/decorators/async3/index.d.ts +1 -0
- package/lib/decorators/async3/index.js +4 -0
- package/lib/decorators/common/filters/filter-helper.d.ts +1 -1
- package/lib/decorators/common/filters/filter-helper.js +2 -3
- package/lib/decorators/common/filters/filter-in.d.ts +1 -1
- package/lib/decorators/common/filters/filter-in.js +1 -1
- package/lib/decorators/common/filters/filter-out.d.ts +1 -1
- package/lib/decorators/common/filters/filter-out.js +1 -1
- package/lib/decorators/common/info-description-override.d.ts +1 -1
- package/lib/decorators/common/info-override.d.ts +1 -1
- package/lib/decorators/common/info-override.js +1 -12
- package/lib/decorators/common/media-type-examples-override.d.ts +1 -1
- package/lib/decorators/common/media-type-examples-override.js +8 -2
- package/lib/decorators/common/operation-description-override.d.ts +1 -1
- package/lib/decorators/common/registry-dependencies.d.ts +1 -1
- package/lib/decorators/common/remove-x-internal.d.ts +1 -1
- package/lib/decorators/common/remove-x-internal.js +4 -5
- package/lib/decorators/common/tag-description-override.d.ts +1 -1
- package/lib/decorators/oas2/index.d.ts +1 -1
- package/lib/decorators/oas2/remove-unused-components.js +1 -2
- package/lib/decorators/oas3/index.d.ts +1 -1
- package/lib/decorators/oas3/remove-unused-components.js +1 -2
- package/lib/env.d.ts +0 -1
- package/lib/env.js +1 -1
- package/lib/format/codeframes.d.ts +1 -1
- package/lib/format/codeframes.js +10 -8
- package/lib/format/format.d.ts +1 -1
- package/lib/format/format.js +24 -16
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -4
- package/lib/js-yaml/index.d.ts +1 -1
- package/lib/js-yaml/index.js +1 -1
- package/lib/lint.d.ts +3 -1
- package/lib/lint.js +92 -99
- package/lib/logger.js +2 -2
- package/lib/oas-types.d.ts +9 -5
- package/lib/oas-types.js +22 -12
- package/lib/redocly/domains.d.ts +1 -1
- package/lib/redocly/domains.js +6 -6
- package/lib/redocly/index.d.ts +1 -1
- package/lib/redocly/index.js +60 -73
- package/lib/redocly/registry-api.js +64 -82
- package/lib/ref-utils.d.ts +2 -2
- package/lib/ref-utils.js +14 -13
- package/lib/resolve.d.ts +2 -2
- package/lib/resolve.js +186 -205
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +10 -8
- package/lib/rules/arazzo/index.js +2 -0
- package/lib/rules/async2/channels-kebab-case.d.ts +1 -1
- package/lib/rules/async2/index.js +2 -0
- package/lib/rules/async2/no-channel-trailing-slash.d.ts +1 -1
- package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
- package/lib/rules/async3/channels-kebab-case.js +19 -0
- package/lib/rules/async3/index.d.ts +3 -0
- package/lib/rules/async3/index.js +24 -0
- package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
- package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
- package/lib/rules/common/assertions/asserts.d.ts +2 -2
- package/lib/rules/common/assertions/asserts.js +5 -5
- package/lib/rules/common/assertions/index.d.ts +4 -4
- package/lib/rules/common/assertions/utils.d.ts +1 -1
- package/lib/rules/common/assertions/utils.js +43 -28
- package/lib/rules/common/info-contact.d.ts +1 -1
- package/lib/rules/common/info-license-strict.d.ts +2 -0
- package/lib/rules/common/info-license-strict.js +26 -0
- package/lib/rules/common/info-license-url.d.ts +1 -1
- package/lib/rules/common/info-license.d.ts +1 -1
- package/lib/rules/common/no-ambiguous-paths.d.ts +1 -1
- package/lib/rules/common/no-enum-type-mismatch.d.ts +1 -1
- package/lib/rules/common/no-http-verbs-in-paths.d.ts +1 -1
- package/lib/rules/common/no-identical-paths.d.ts +1 -1
- package/lib/rules/common/no-invalid-parameter-examples.js +1 -2
- package/lib/rules/common/no-invalid-schema-examples.js +1 -2
- package/lib/rules/common/no-path-trailing-slash.d.ts +1 -1
- package/lib/rules/common/no-required-schema-properties-undefined.d.ts +1 -1
- package/lib/rules/common/no-required-schema-properties-undefined.js +1 -2
- package/lib/rules/common/operation-2xx-response.d.ts +1 -1
- package/lib/rules/common/operation-4xx-response.d.ts +1 -1
- package/lib/rules/common/operation-description.d.ts +1 -1
- package/lib/rules/common/operation-operationId-unique.d.ts +1 -1
- package/lib/rules/common/operation-operationId-url-safe.d.ts +1 -1
- package/lib/rules/common/operation-operationId-url-safe.js +1 -0
- package/lib/rules/common/operation-operationId.d.ts +1 -1
- package/lib/rules/common/operation-parameters-unique.d.ts +1 -1
- package/lib/rules/common/operation-singular-tag.d.ts +1 -1
- package/lib/rules/common/operation-summary.d.ts +1 -1
- package/lib/rules/common/operation-tag-defined.d.ts +1 -1
- package/lib/rules/common/operation-tag-defined.js +1 -2
- package/lib/rules/common/parameter-description.d.ts +1 -1
- package/lib/rules/common/path-declaration-must-exist.d.ts +1 -1
- package/lib/rules/common/path-excludes-patterns.d.ts +1 -1
- package/lib/rules/common/path-http-verbs-order.d.ts +1 -1
- package/lib/rules/common/path-http-verbs-order.js +1 -1
- package/lib/rules/common/path-not-include-query.d.ts +1 -1
- package/lib/rules/common/path-params-defined.d.ts +1 -1
- package/lib/rules/common/path-segment-plural.d.ts +1 -1
- package/lib/rules/common/paths-kebab-case.d.ts +1 -1
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +1 -1
- package/lib/rules/common/required-string-property-missing-min-length.js +2 -2
- package/lib/rules/common/response-contains-header.d.ts +1 -1
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/security-defined.d.ts +1 -1
- package/lib/rules/common/security-defined.js +3 -7
- package/lib/rules/common/spec-strict-refs.d.ts +1 -1
- package/lib/rules/common/spec.d.ts +2 -2
- package/lib/rules/common/spec.js +6 -7
- package/lib/rules/common/tag-description.d.ts +1 -1
- package/lib/rules/common/tags-alphabetical.d.ts +1 -1
- package/lib/rules/no-unresolved-refs.d.ts +3 -3
- package/lib/rules/no-unresolved-refs.js +3 -4
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas2/index.d.ts +1 -1
- package/lib/rules/oas2/index.js +2 -0
- package/lib/rules/oas2/response-contains-property.d.ts +1 -1
- package/lib/rules/oas2/response-contains-property.js +1 -2
- package/lib/rules/oas3/array-parameter-serialization.d.ts +1 -1
- package/lib/rules/oas3/array-parameter-serialization.js +1 -2
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
- package/lib/rules/oas3/component-name-unique.d.ts +1 -1
- package/lib/rules/oas3/component-name-unique.js +2 -4
- package/lib/rules/oas3/index.d.ts +1 -1
- package/lib/rules/oas3/index.js +2 -0
- package/lib/rules/oas3/no-empty-servers.d.ts +1 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.d.ts +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.d.ts +1 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.js +1 -2
- package/lib/rules/oas3/no-server-example.com.d.ts +1 -1
- package/lib/rules/oas3/no-server-example.com.js +1 -0
- package/lib/rules/oas3/no-server-trailing-slash.d.ts +1 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +1 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -2
- package/lib/rules/oas3/no-undefined-server-variable.d.ts +1 -1
- package/lib/rules/oas3/no-undefined-server-variable.js +2 -3
- package/lib/rules/oas3/no-unused-components.d.ts +1 -1
- package/lib/rules/oas3/no-unused-components.js +1 -2
- package/lib/rules/oas3/response-contains-property.d.ts +1 -1
- package/lib/rules/oas3/response-contains-property.js +1 -2
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +1 -1
- package/lib/rules/other/stats.d.ts +3 -3
- package/lib/rules/other/stats.js +5 -3
- package/lib/rules/spot/parameters-no-body-inside-in.d.ts +2 -0
- package/lib/rules/spot/parameters-no-body-inside-in.js +18 -0
- package/lib/rules/utils.d.ts +4 -2
- package/lib/rules/utils.js +41 -13
- package/lib/types/arazzo.d.ts +1 -2275
- package/lib/types/arazzo.js +246 -309
- package/lib/types/asyncapi2.d.ts +17 -0
- package/lib/types/{asyncapi.js → asyncapi2.js} +59 -53
- package/lib/types/asyncapi3.d.ts +2 -0
- package/lib/types/asyncapi3.js +347 -0
- package/lib/types/index.js +19 -10
- package/lib/types/json-schema-adapter.d.ts +1 -1
- package/lib/types/json-schema-adapter.js +4 -18
- package/lib/types/oas2.js +6 -6
- package/lib/types/oas3.d.ts +4 -0
- package/lib/types/oas3.js +19 -19
- package/lib/types/oas3_1.d.ts +3 -0
- package/lib/types/oas3_1.js +20 -14
- package/lib/types/redocly-yaml.d.ts +8 -6
- package/lib/types/redocly-yaml.js +135 -36
- package/lib/typings/arazzo.d.ts +145 -27
- package/lib/typings/asyncapi3.d.ts +53 -0
- package/lib/typings/asyncapi3.js +2 -0
- package/lib/typings/common.d.ts +1 -1
- package/lib/typings/swagger.d.ts +2 -2
- package/lib/utils.d.ts +4 -3
- package/lib/utils.js +55 -72
- package/lib/visitors.d.ts +29 -1
- package/lib/visitors.js +21 -8
- package/lib/walk.d.ts +3 -3
- package/lib/walk.js +30 -23
- package/package.json +3 -3
- package/src/__tests__/bundle.test.ts +144 -2
- package/src/__tests__/lint.test.ts +29 -21
- package/src/__tests__/walk.test.ts +25 -25
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +7 -1
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +7 -1
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +8 -1
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +18 -13
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +17 -11
- package/src/benchmark/fork.js +4 -0
- package/src/benchmark/utils.ts +6 -5
- package/src/bundle.ts +19 -4
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +32 -2
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +24 -0
- package/src/config/__tests__/config-resolvers.test.ts +82 -0
- package/src/config/__tests__/config.test.ts +11 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-commonjs-export-function.yaml +2 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-esm.yaml +2 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin-esm.mjs +10 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin-with-export-function.cjs +10 -0
- package/src/config/__tests__/resolve-plugins.test.ts +4 -1
- package/src/config/all.ts +13 -1
- package/src/config/builtIn.ts +9 -8
- package/src/config/config-resolvers.ts +92 -21
- package/src/config/config.ts +31 -13
- package/src/config/load.ts +2 -2
- package/src/config/minimal.ts +13 -0
- package/src/config/recommended-strict.ts +14 -1
- package/src/config/recommended.ts +14 -1
- package/src/config/rules.ts +12 -4
- package/src/config/types.ts +34 -5
- package/src/config/utils.ts +28 -2
- package/src/decorators/__tests__/filter-in.test.ts +29 -26
- package/src/decorators/__tests__/filter-out.test.ts +32 -23
- package/src/decorators/__tests__/media-type-examples-override.test.ts +45 -45
- package/src/decorators/__tests__/remove-x-internal.test.ts +8 -5
- package/src/decorators/async3/index.ts +1 -0
- package/src/decorators/common/filters/filter-helper.ts +2 -1
- package/src/decorators/common/filters/filter-in.ts +2 -1
- package/src/decorators/common/filters/filter-out.ts +2 -1
- package/src/decorators/common/info-description-override.ts +3 -2
- package/src/decorators/common/info-override.ts +1 -1
- package/src/decorators/common/media-type-examples-override.ts +4 -3
- package/src/decorators/common/operation-description-override.ts +5 -4
- package/src/decorators/common/registry-dependencies.ts +2 -2
- package/src/decorators/common/remove-x-internal.ts +5 -4
- package/src/decorators/common/tag-description-override.ts +3 -2
- package/src/decorators/oas2/__tests__/remove-unused-components.test.ts +3 -3
- package/src/decorators/oas2/index.ts +2 -1
- package/src/decorators/oas2/remove-unused-components.ts +1 -1
- package/src/decorators/oas3/__tests__/remove-unused-components.test.ts +4 -4
- package/src/decorators/oas3/index.ts +2 -1
- package/src/decorators/oas3/remove-unused-components.ts +1 -1
- package/src/format/codeframes.ts +2 -1
- package/src/format/format.ts +9 -4
- package/src/index.ts +2 -1
- package/src/js-yaml/index.ts +3 -1
- package/src/lint.ts +28 -4
- package/src/logger.ts +2 -2
- package/src/oas-types.ts +41 -22
- package/src/redocly/domains.ts +1 -1
- package/src/redocly/index.ts +3 -3
- package/src/redocly/registry-api.ts +5 -3
- package/src/ref-utils.ts +4 -2
- package/src/resolve.ts +6 -4
- package/src/rules/__tests__/no-unresolved-refs.test.ts +21 -7
- package/src/rules/ajv.ts +2 -1
- package/src/rules/arazzo/__tests__/parameters-no-body-inside-in.test.ts +76 -0
- package/src/rules/arazzo/index.ts +6 -3
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +9 -5
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +3 -3
- package/src/rules/async2/channels-kebab-case.ts +2 -2
- package/src/rules/async2/index.ts +9 -6
- package/src/rules/async2/no-channel-trailing-slash.ts +2 -2
- package/src/rules/async3/__tests__/channels-kebab-case.test.ts +145 -0
- package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +96 -0
- package/src/rules/async3/channels-kebab-case.ts +19 -0
- package/src/rules/async3/index.ts +26 -0
- package/src/rules/async3/no-channel-trailing-slash.ts +16 -0
- package/src/rules/common/__tests__/info-license-strict.test.ts +141 -0
- package/src/rules/common/__tests__/info-license.test.ts +2 -2
- package/src/rules/common/__tests__/license-url.test.ts +2 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +5 -5
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
- package/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts +1 -1
- package/src/rules/common/__tests__/no-invalid-schema-examples.test.ts +1 -1
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +4 -4
- package/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts +11 -11
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +8 -6
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +9 -7
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +5 -5
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +6 -4
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
- package/src/rules/common/__tests__/security-defined.test.ts +14 -8
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +1 -1
- package/src/rules/common/__tests__/spec.test.ts +10 -10
- package/src/rules/common/__tests__/tag-description.test.ts +2 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +6 -4
- package/src/rules/common/assertions/asserts.ts +5 -9
- package/src/rules/common/assertions/index.ts +12 -4
- package/src/rules/common/assertions/utils.ts +4 -2
- package/src/rules/common/info-contact.ts +2 -1
- package/src/rules/common/info-license-strict.ts +24 -0
- package/src/rules/common/info-license-url.ts +2 -1
- package/src/rules/common/info-license.ts +2 -1
- package/src/rules/common/no-ambiguous-paths.ts +4 -4
- package/src/rules/common/no-enum-type-mismatch.ts +5 -4
- package/src/rules/common/no-http-verbs-in-paths.ts +5 -4
- package/src/rules/common/no-identical-paths.ts +4 -4
- package/src/rules/common/no-invalid-parameter-examples.ts +3 -2
- package/src/rules/common/no-path-trailing-slash.ts +2 -2
- package/src/rules/common/no-required-schema-properties-undefined.ts +5 -4
- package/src/rules/common/operation-2xx-response.ts +3 -2
- package/src/rules/common/operation-4xx-response.ts +3 -2
- package/src/rules/common/operation-description.ts +5 -4
- package/src/rules/common/operation-operationId-unique.ts +4 -4
- package/src/rules/common/operation-operationId-url-safe.ts +5 -4
- package/src/rules/common/operation-operationId.ts +5 -4
- package/src/rules/common/operation-parameters-unique.ts +4 -4
- package/src/rules/common/operation-singular-tag.ts +4 -4
- package/src/rules/common/operation-summary.ts +5 -4
- package/src/rules/common/operation-tag-defined.ts +4 -4
- package/src/rules/common/parameter-description.ts +4 -4
- package/src/rules/common/path-declaration-must-exist.ts +2 -2
- package/src/rules/common/path-excludes-patterns.ts +4 -4
- package/src/rules/common/path-http-verbs-order.ts +4 -4
- package/src/rules/common/path-not-include-query.ts +2 -2
- package/src/rules/common/path-params-defined.ts +4 -4
- package/src/rules/common/path-segment-plural.ts +3 -2
- package/src/rules/common/paths-kebab-case.ts +2 -2
- package/src/rules/common/required-string-property-missing-min-length.ts +4 -4
- package/src/rules/common/response-contains-header.ts +5 -4
- package/src/rules/common/scalar-property-missing-example.ts +2 -1
- package/src/rules/common/security-defined.ts +5 -5
- package/src/rules/common/spec-strict-refs.ts +2 -1
- package/src/rules/common/spec.ts +4 -3
- package/src/rules/common/tag-description.ts +2 -1
- package/src/rules/common/tags-alphabetical.ts +4 -4
- package/src/rules/no-unresolved-refs.ts +4 -3
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -5
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +14 -8
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +14 -8
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +3 -1
- package/src/rules/oas2/boolean-parameter-prefixes.ts +1 -1
- package/src/rules/oas2/index.ts +8 -6
- package/src/rules/oas2/request-mime-type.ts +2 -1
- package/src/rules/oas2/response-contains-property.ts +3 -2
- package/src/rules/oas2/response-mime-type.ts +2 -1
- package/src/rules/oas3/__tests__/array-parameter-serialization.test.ts +18 -6
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -5
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +6 -6
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +34 -24
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +3 -3
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +34 -22
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +34 -20
- package/src/rules/oas3/__tests__/spec/spec.test.ts +12 -3
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +9 -3
- package/src/rules/oas3/__tests__/utils/lint-document-for-test.ts +1 -1
- package/src/rules/oas3/array-parameter-serialization.ts +3 -2
- package/src/rules/oas3/boolean-parameter-prefixes.ts +1 -1
- package/src/rules/oas3/component-name-unique.ts +3 -3
- package/src/rules/oas3/index.ts +42 -38
- package/src/rules/oas3/no-empty-servers.ts +1 -1
- package/src/rules/oas3/no-example-value-and-externalValue.ts +1 -1
- package/src/rules/oas3/no-invalid-media-type-examples.ts +6 -4
- package/src/rules/oas3/no-server-example.com.ts +2 -1
- package/src/rules/oas3/no-server-trailing-slash.ts +1 -1
- package/src/rules/oas3/no-server-variables-empty-enum.ts +2 -2
- package/src/rules/oas3/no-undefined-server-variable.ts +1 -1
- package/src/rules/oas3/no-unused-components.ts +2 -2
- package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +2 -1
- package/src/rules/oas3/request-mime-type.ts +2 -1
- package/src/rules/oas3/response-contains-property.ts +3 -2
- package/src/rules/oas3/response-mime-type.ts +2 -1
- package/src/rules/oas3/spec-components-invalid-map-name.ts +3 -3
- package/src/rules/other/stats.ts +8 -6
- package/src/rules/spot/parameters-no-body-inside-in.ts +17 -0
- package/src/rules/utils.ts +41 -4
- package/src/types/arazzo.ts +257 -334
- package/src/types/{asyncapi.ts → asyncapi2.ts} +41 -35
- package/src/types/asyncapi3.ts +383 -0
- package/src/types/json-schema-adapter.ts +2 -2
- package/src/types/oas3.ts +4 -4
- package/src/types/oas3_1.ts +5 -4
- package/src/types/redocly-yaml.ts +21 -4
- package/src/typings/arazzo.ts +169 -41
- package/src/typings/asyncapi3.ts +61 -0
- package/src/typings/common.ts +1 -0
- package/src/typings/swagger.ts +2 -2
- package/src/utils.ts +5 -3
- package/src/visitors.ts +58 -1
- package/src/walk.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/types/asyncapi.d.ts +0 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { listOf, mapOf } from '.';
|
|
2
2
|
import { isMappingRef } from '../ref-utils';
|
|
3
3
|
|
|
4
|
+
import type { NodeType } from '.';
|
|
5
|
+
|
|
4
6
|
const Root: NodeType = {
|
|
5
7
|
properties: {
|
|
6
8
|
asyncapi: null, // TODO: validate semver format and supported version
|
|
@@ -61,7 +63,7 @@ const ChannelBindings: NodeType = {
|
|
|
61
63
|
additionalProperties: { type: 'object' },
|
|
62
64
|
};
|
|
63
65
|
|
|
64
|
-
const Tag: NodeType = {
|
|
66
|
+
export const Tag: NodeType = {
|
|
65
67
|
properties: {
|
|
66
68
|
name: { type: 'string' },
|
|
67
69
|
description: { type: 'string' },
|
|
@@ -70,7 +72,7 @@ const Tag: NodeType = {
|
|
|
70
72
|
required: ['name'],
|
|
71
73
|
};
|
|
72
74
|
|
|
73
|
-
const ExternalDocs: NodeType = {
|
|
75
|
+
export const ExternalDocs: NodeType = {
|
|
74
76
|
properties: {
|
|
75
77
|
description: { type: 'string' },
|
|
76
78
|
url: { type: 'string' },
|
|
@@ -126,13 +128,14 @@ const Server: NodeType = {
|
|
|
126
128
|
required: ['url', 'protocol'],
|
|
127
129
|
};
|
|
128
130
|
|
|
129
|
-
const ServerMap: NodeType = {
|
|
131
|
+
export const ServerMap: NodeType = {
|
|
130
132
|
properties: {},
|
|
131
133
|
additionalProperties: (_value: any, key: string) =>
|
|
134
|
+
// eslint-disable-next-line no-useless-escape
|
|
132
135
|
key.match(/^[A-Za-z0-9_\-]+$/) ? 'Server' : undefined,
|
|
133
136
|
};
|
|
134
137
|
|
|
135
|
-
const ServerVariable: NodeType = {
|
|
138
|
+
export const ServerVariable: NodeType = {
|
|
136
139
|
properties: {
|
|
137
140
|
enum: {
|
|
138
141
|
type: 'array',
|
|
@@ -160,7 +163,7 @@ const Info: NodeType = {
|
|
|
160
163
|
required: ['title', 'version'],
|
|
161
164
|
};
|
|
162
165
|
|
|
163
|
-
const Contact: NodeType = {
|
|
166
|
+
export const Contact: NodeType = {
|
|
164
167
|
properties: {
|
|
165
168
|
name: { type: 'string' },
|
|
166
169
|
url: { type: 'string' },
|
|
@@ -168,7 +171,7 @@ const Contact: NodeType = {
|
|
|
168
171
|
},
|
|
169
172
|
};
|
|
170
173
|
|
|
171
|
-
const License: NodeType = {
|
|
174
|
+
export const License: NodeType = {
|
|
172
175
|
properties: {
|
|
173
176
|
name: { type: 'string' },
|
|
174
177
|
url: { type: 'string' },
|
|
@@ -184,7 +187,7 @@ const Parameter: NodeType = {
|
|
|
184
187
|
},
|
|
185
188
|
};
|
|
186
189
|
|
|
187
|
-
const CorrelationId: NodeType = {
|
|
190
|
+
export const CorrelationId: NodeType = {
|
|
188
191
|
properties: {
|
|
189
192
|
description: { type: 'string' },
|
|
190
193
|
location: { type: 'string' },
|
|
@@ -208,7 +211,7 @@ const Message: NodeType = {
|
|
|
208
211
|
tags: 'TagList',
|
|
209
212
|
externalDocs: 'ExternalDocs',
|
|
210
213
|
bindings: 'MessageBindings',
|
|
211
|
-
|
|
214
|
+
examples: 'MessageExampleList',
|
|
212
215
|
traits: 'MessageTraitList',
|
|
213
216
|
},
|
|
214
217
|
additionalProperties: {},
|
|
@@ -301,7 +304,7 @@ const MessageTrait: NodeType = {
|
|
|
301
304
|
tags: 'TagList',
|
|
302
305
|
externalDocs: 'ExternalDocs',
|
|
303
306
|
bindings: 'MessageBindings',
|
|
304
|
-
|
|
307
|
+
examples: 'MessageExampleList',
|
|
305
308
|
},
|
|
306
309
|
additionalProperties: {},
|
|
307
310
|
};
|
|
@@ -322,7 +325,7 @@ const Operation: NodeType = {
|
|
|
322
325
|
required: [],
|
|
323
326
|
};
|
|
324
327
|
|
|
325
|
-
const MessageExample: NodeType = {
|
|
328
|
+
export const MessageExample: NodeType = {
|
|
326
329
|
properties: {
|
|
327
330
|
payload: { isExample: true },
|
|
328
331
|
summary: { type: 'string' },
|
|
@@ -331,7 +334,7 @@ const MessageExample: NodeType = {
|
|
|
331
334
|
},
|
|
332
335
|
};
|
|
333
336
|
|
|
334
|
-
const Schema: NodeType = {
|
|
337
|
+
export const Schema: NodeType = {
|
|
335
338
|
properties: {
|
|
336
339
|
$id: { type: 'string' },
|
|
337
340
|
$schema: { type: 'string' },
|
|
@@ -401,14 +404,14 @@ const Schema: NodeType = {
|
|
|
401
404
|
},
|
|
402
405
|
};
|
|
403
406
|
|
|
404
|
-
const SchemaProperties: NodeType = {
|
|
407
|
+
export const SchemaProperties: NodeType = {
|
|
405
408
|
properties: {},
|
|
406
409
|
additionalProperties: (value: any) => {
|
|
407
410
|
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
408
411
|
},
|
|
409
412
|
};
|
|
410
413
|
|
|
411
|
-
const DiscriminatorMapping: NodeType = {
|
|
414
|
+
export const DiscriminatorMapping: NodeType = {
|
|
412
415
|
properties: {},
|
|
413
416
|
additionalProperties: (value: any) => {
|
|
414
417
|
if (isMappingRef(value)) {
|
|
@@ -419,7 +422,7 @@ const DiscriminatorMapping: NodeType = {
|
|
|
419
422
|
},
|
|
420
423
|
};
|
|
421
424
|
|
|
422
|
-
const Discriminator: NodeType = {
|
|
425
|
+
export const Discriminator: NodeType = {
|
|
423
426
|
properties: {
|
|
424
427
|
propertyName: { type: 'string' },
|
|
425
428
|
mapping: 'DiscriminatorMapping',
|
|
@@ -435,7 +438,6 @@ const Components: NodeType = {
|
|
|
435
438
|
correlationIds: 'NamedCorrelationIds',
|
|
436
439
|
messageTraits: 'NamedMessageTraits',
|
|
437
440
|
operationTraits: 'NamedOperationTraits',
|
|
438
|
-
streamHeaders: 'NamedStreamHeaders',
|
|
439
441
|
securitySchemes: 'NamedSecuritySchemes',
|
|
440
442
|
servers: 'ServerMap',
|
|
441
443
|
serverVariables: 'ServerVariablesMap',
|
|
@@ -484,7 +486,7 @@ const AuthorizationCode: NodeType = {
|
|
|
484
486
|
required: ['authorizationUrl', 'tokenUrl', 'scopes'],
|
|
485
487
|
};
|
|
486
488
|
|
|
487
|
-
const SecuritySchemeFlows: NodeType = {
|
|
489
|
+
export const SecuritySchemeFlows: NodeType = {
|
|
488
490
|
properties: {
|
|
489
491
|
implicit: 'ImplicitFlow',
|
|
490
492
|
password: 'PasswordFlow',
|
|
@@ -555,7 +557,7 @@ const SecurityScheme: NodeType = {
|
|
|
555
557
|
extensionsPrefix: 'x-',
|
|
556
558
|
};
|
|
557
559
|
|
|
558
|
-
const Dependencies: NodeType = {
|
|
560
|
+
export const Dependencies: NodeType = {
|
|
559
561
|
properties: {},
|
|
560
562
|
additionalProperties: (value: any) => {
|
|
561
563
|
return Array.isArray(value) ? { type: 'array', items: { type: 'string' } } : 'Schema';
|
|
@@ -987,22 +989,7 @@ OperationBindings.properties.mercure = MercureOperationBinding;
|
|
|
987
989
|
// pulsar
|
|
988
990
|
|
|
989
991
|
// --- End per-protocol node types
|
|
990
|
-
|
|
991
|
-
export const AsyncApi2Types: Record<string, NodeType> = {
|
|
992
|
-
Root,
|
|
993
|
-
Tag,
|
|
994
|
-
TagList: listOf('Tag'),
|
|
995
|
-
ServerMap,
|
|
996
|
-
ExternalDocs,
|
|
997
|
-
Server,
|
|
998
|
-
ServerVariable,
|
|
999
|
-
ServerVariablesMap: mapOf('ServerVariable'),
|
|
1000
|
-
SecurityRequirement,
|
|
1001
|
-
SecurityRequirementList: listOf('SecurityRequirement'),
|
|
1002
|
-
Info,
|
|
1003
|
-
Contact,
|
|
1004
|
-
License,
|
|
1005
|
-
|
|
992
|
+
export const AsyncApi2Bindings: Record<string, NodeType> = {
|
|
1006
993
|
HttpServerBinding,
|
|
1007
994
|
HttpChannelBinding,
|
|
1008
995
|
HttpMessageBinding,
|
|
@@ -1078,6 +1065,25 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1078
1065
|
|
|
1079
1066
|
ServerBindings,
|
|
1080
1067
|
ChannelBindings,
|
|
1068
|
+
MessageBindings,
|
|
1069
|
+
OperationBindings,
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
export const AsyncApi2Types: Record<string, NodeType> = {
|
|
1073
|
+
...AsyncApi2Bindings,
|
|
1074
|
+
Root,
|
|
1075
|
+
Tag,
|
|
1076
|
+
TagList: listOf('Tag'),
|
|
1077
|
+
ServerMap,
|
|
1078
|
+
ExternalDocs,
|
|
1079
|
+
Server,
|
|
1080
|
+
ServerVariable,
|
|
1081
|
+
ServerVariablesMap: mapOf('ServerVariable'),
|
|
1082
|
+
SecurityRequirement,
|
|
1083
|
+
SecurityRequirementList: listOf('SecurityRequirement'),
|
|
1084
|
+
Info,
|
|
1085
|
+
Contact,
|
|
1086
|
+
License,
|
|
1081
1087
|
ChannelMap,
|
|
1082
1088
|
Channel,
|
|
1083
1089
|
Parameter,
|
|
@@ -1096,7 +1102,6 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1096
1102
|
NamedParameters: mapOf('Parameter'),
|
|
1097
1103
|
NamedSecuritySchemes: mapOf('SecurityScheme'),
|
|
1098
1104
|
NamedCorrelationIds: mapOf('CorrelationId'),
|
|
1099
|
-
NamedStreamHeaders: mapOf('StreamHeader'),
|
|
1100
1105
|
ImplicitFlow,
|
|
1101
1106
|
PasswordFlow,
|
|
1102
1107
|
ClientCredentials,
|
|
@@ -1110,6 +1115,7 @@ export const AsyncApi2Types: Record<string, NodeType> = {
|
|
|
1110
1115
|
OperationTraitList: listOf('OperationTrait'),
|
|
1111
1116
|
MessageTrait,
|
|
1112
1117
|
MessageTraitList: listOf('MessageTrait'),
|
|
1118
|
+
MessageExampleList: listOf('MessageExample'),
|
|
1113
1119
|
CorrelationId,
|
|
1114
1120
|
Dependencies,
|
|
1115
1121
|
};
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { listOf, mapOf } from '.';
|
|
2
|
+
import {
|
|
3
|
+
AsyncApi2Bindings,
|
|
4
|
+
Schema,
|
|
5
|
+
Dependencies,
|
|
6
|
+
Discriminator,
|
|
7
|
+
DiscriminatorMapping,
|
|
8
|
+
SchemaProperties,
|
|
9
|
+
CorrelationId,
|
|
10
|
+
Tag,
|
|
11
|
+
ServerMap,
|
|
12
|
+
ExternalDocs,
|
|
13
|
+
SecuritySchemeFlows,
|
|
14
|
+
ServerVariable,
|
|
15
|
+
Contact,
|
|
16
|
+
License,
|
|
17
|
+
MessageExample,
|
|
18
|
+
} from './asyncapi2';
|
|
19
|
+
|
|
20
|
+
import type { NodeType } from '.';
|
|
21
|
+
|
|
22
|
+
const Root: NodeType = {
|
|
23
|
+
properties: {
|
|
24
|
+
asyncapi: { type: 'string', enum: ['3.0.0'] },
|
|
25
|
+
info: 'Info',
|
|
26
|
+
id: { type: 'string' },
|
|
27
|
+
servers: 'ServerMap',
|
|
28
|
+
channels: 'NamedChannels',
|
|
29
|
+
components: 'Components',
|
|
30
|
+
operations: 'NamedOperations',
|
|
31
|
+
defaultContentType: { type: 'string' },
|
|
32
|
+
},
|
|
33
|
+
required: ['asyncapi', 'info'],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const Channel: NodeType = {
|
|
37
|
+
properties: {
|
|
38
|
+
address: { type: 'string' },
|
|
39
|
+
messages: 'NamedMessages',
|
|
40
|
+
title: { type: 'string' },
|
|
41
|
+
summary: { type: 'string' },
|
|
42
|
+
description: { type: 'string' },
|
|
43
|
+
servers: 'ServerList',
|
|
44
|
+
parameters: 'ParametersMap',
|
|
45
|
+
bindings: 'ChannelBindings',
|
|
46
|
+
tags: 'TagList',
|
|
47
|
+
externalDocs: 'ExternalDocs',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const Server: NodeType = {
|
|
52
|
+
properties: {
|
|
53
|
+
host: { type: 'string' },
|
|
54
|
+
pathname: { type: 'string' },
|
|
55
|
+
protocol: { type: 'string' },
|
|
56
|
+
protocolVersion: { type: 'string' },
|
|
57
|
+
description: { type: 'string' },
|
|
58
|
+
variables: 'ServerVariablesMap',
|
|
59
|
+
security: 'SecuritySchemeList',
|
|
60
|
+
bindings: 'ServerBindings',
|
|
61
|
+
externalDocs: 'ExternalDocs',
|
|
62
|
+
tags: 'TagList',
|
|
63
|
+
},
|
|
64
|
+
required: ['host', 'protocol'],
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const Info: NodeType = {
|
|
68
|
+
properties: {
|
|
69
|
+
title: { type: 'string' },
|
|
70
|
+
version: { type: 'string' },
|
|
71
|
+
description: { type: 'string' },
|
|
72
|
+
termsOfService: { type: 'string' },
|
|
73
|
+
contact: 'Contact',
|
|
74
|
+
license: 'License',
|
|
75
|
+
tags: 'TagList',
|
|
76
|
+
externalDocs: 'ExternalDocs',
|
|
77
|
+
},
|
|
78
|
+
required: ['title', 'version'],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const Parameter: NodeType = {
|
|
82
|
+
properties: {
|
|
83
|
+
description: { type: 'string' },
|
|
84
|
+
enum: { type: 'array', items: { type: 'string' } },
|
|
85
|
+
default: { type: 'string' },
|
|
86
|
+
examples: { type: 'array', items: { type: 'string' } },
|
|
87
|
+
location: { type: 'string' },
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const Message: NodeType = {
|
|
92
|
+
properties: {
|
|
93
|
+
headers: 'Schema',
|
|
94
|
+
payload: (value: Record<string, unknown>) => {
|
|
95
|
+
if (!!value && value?.['schemaFormat']) {
|
|
96
|
+
return {
|
|
97
|
+
properties: {
|
|
98
|
+
schema: 'Schema',
|
|
99
|
+
schemaFormat: { type: 'string' },
|
|
100
|
+
},
|
|
101
|
+
required: ['schema', 'schemaFormat'],
|
|
102
|
+
};
|
|
103
|
+
} else {
|
|
104
|
+
return 'Schema';
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
correlationId: 'CorrelationId',
|
|
108
|
+
|
|
109
|
+
contentType: { type: 'string' },
|
|
110
|
+
name: { type: 'string' },
|
|
111
|
+
title: { type: 'string' },
|
|
112
|
+
summary: { type: 'string' },
|
|
113
|
+
description: { type: 'string' },
|
|
114
|
+
tags: 'TagList',
|
|
115
|
+
externalDocs: 'ExternalDocs',
|
|
116
|
+
bindings: 'MessageBindings',
|
|
117
|
+
examples: 'MessageExampleList',
|
|
118
|
+
traits: 'MessageTraitList',
|
|
119
|
+
},
|
|
120
|
+
additionalProperties: {},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const OperationTrait: NodeType = {
|
|
124
|
+
properties: {
|
|
125
|
+
tags: 'TagList',
|
|
126
|
+
title: { type: 'string' },
|
|
127
|
+
summary: { type: 'string' },
|
|
128
|
+
description: { type: 'string' },
|
|
129
|
+
externalDocs: 'ExternalDocs',
|
|
130
|
+
security: 'SecuritySchemeList',
|
|
131
|
+
|
|
132
|
+
bindings: 'OperationBindings',
|
|
133
|
+
},
|
|
134
|
+
required: [],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const MessageTrait: NodeType = {
|
|
138
|
+
properties: {
|
|
139
|
+
headers: (value: unknown) => {
|
|
140
|
+
if (typeof value === 'function' || (typeof value === 'object' && !!value)) {
|
|
141
|
+
return {
|
|
142
|
+
properties: {
|
|
143
|
+
schema: 'Schema',
|
|
144
|
+
schemaFormat: { type: 'string' },
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
} else {
|
|
148
|
+
return 'Schema';
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
correlationId: 'CorrelationId',
|
|
152
|
+
|
|
153
|
+
contentType: { type: 'string' },
|
|
154
|
+
name: { type: 'string' },
|
|
155
|
+
title: { type: 'string' },
|
|
156
|
+
summary: { type: 'string' },
|
|
157
|
+
description: { type: 'string' },
|
|
158
|
+
tags: 'TagList',
|
|
159
|
+
externalDocs: 'ExternalDocs',
|
|
160
|
+
bindings: 'MessageBindings',
|
|
161
|
+
examples: 'MessageExampleList',
|
|
162
|
+
},
|
|
163
|
+
additionalProperties: {},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const Operation: NodeType = {
|
|
167
|
+
properties: {
|
|
168
|
+
action: { type: 'string', enum: ['send', 'receive'] },
|
|
169
|
+
channel: 'Channel',
|
|
170
|
+
title: { type: 'string' },
|
|
171
|
+
tags: 'TagList',
|
|
172
|
+
summary: { type: 'string' },
|
|
173
|
+
description: { type: 'string' },
|
|
174
|
+
externalDocs: 'ExternalDocs',
|
|
175
|
+
operationId: { type: 'string' },
|
|
176
|
+
security: 'SecuritySchemeList',
|
|
177
|
+
|
|
178
|
+
bindings: 'OperationBindings',
|
|
179
|
+
traits: 'OperationTraitList',
|
|
180
|
+
messages: 'MessageList',
|
|
181
|
+
reply: 'OperationReply',
|
|
182
|
+
},
|
|
183
|
+
required: ['action', 'channel'],
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const OperationReply: NodeType = {
|
|
187
|
+
properties: {
|
|
188
|
+
channel: 'Channel',
|
|
189
|
+
messages: 'MessageList',
|
|
190
|
+
address: 'OperationReplyAddress',
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const OperationReplyAddress: NodeType = {
|
|
195
|
+
properties: {
|
|
196
|
+
location: { type: 'string' },
|
|
197
|
+
description: { type: 'string' },
|
|
198
|
+
},
|
|
199
|
+
required: ['location'],
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const Components: NodeType = {
|
|
203
|
+
properties: {
|
|
204
|
+
messages: 'NamedMessages',
|
|
205
|
+
parameters: 'NamedParameters',
|
|
206
|
+
schemas: 'NamedSchemas',
|
|
207
|
+
replies: 'NamedOperationReplies',
|
|
208
|
+
replyAddresses: 'NamedOperationRelyAddresses',
|
|
209
|
+
correlationIds: 'NamedCorrelationIds',
|
|
210
|
+
messageTraits: 'NamedMessageTraits',
|
|
211
|
+
operationTraits: 'NamedOperationTraits',
|
|
212
|
+
tags: 'NamedTags',
|
|
213
|
+
externalDocs: 'NamedExternalDocs',
|
|
214
|
+
securitySchemes: 'NamedSecuritySchemes',
|
|
215
|
+
servers: 'ServerMap',
|
|
216
|
+
serverVariables: 'ServerVariablesMap',
|
|
217
|
+
channels: 'NamedChannels',
|
|
218
|
+
operations: 'NamedOperations',
|
|
219
|
+
serverBindings: 'ServerBindings',
|
|
220
|
+
channelBindings: 'ChannelBindings',
|
|
221
|
+
operationBindings: 'OperationBindings',
|
|
222
|
+
messageBindings: 'MessageBindings',
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const ImplicitFlow: NodeType = {
|
|
227
|
+
properties: {
|
|
228
|
+
refreshUrl: { type: 'string' },
|
|
229
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
230
|
+
authorizationUrl: { type: 'string' },
|
|
231
|
+
},
|
|
232
|
+
required: ['authorizationUrl', 'availableScopes'],
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const PasswordFlow: NodeType = {
|
|
236
|
+
properties: {
|
|
237
|
+
refreshUrl: { type: 'string' },
|
|
238
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
239
|
+
tokenUrl: { type: 'string' },
|
|
240
|
+
},
|
|
241
|
+
required: ['tokenUrl', 'availableScopes'],
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const ClientCredentials: NodeType = {
|
|
245
|
+
properties: {
|
|
246
|
+
refreshUrl: { type: 'string' },
|
|
247
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
248
|
+
tokenUrl: { type: 'string' },
|
|
249
|
+
},
|
|
250
|
+
required: ['tokenUrl', 'availableScopes'],
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const AuthorizationCode: NodeType = {
|
|
254
|
+
properties: {
|
|
255
|
+
refreshUrl: { type: 'string' },
|
|
256
|
+
authorizationUrl: { type: 'string' },
|
|
257
|
+
availableScopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
258
|
+
tokenUrl: { type: 'string' },
|
|
259
|
+
},
|
|
260
|
+
required: ['authorizationUrl', 'tokenUrl', 'availableScopes'],
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const SecurityScheme: NodeType = {
|
|
264
|
+
properties: {
|
|
265
|
+
type: {
|
|
266
|
+
enum: [
|
|
267
|
+
'userPassword',
|
|
268
|
+
'apiKey',
|
|
269
|
+
'X509',
|
|
270
|
+
'symmetricEncryption',
|
|
271
|
+
'asymmetricEncryption',
|
|
272
|
+
'httpApiKey',
|
|
273
|
+
'http',
|
|
274
|
+
'oauth2',
|
|
275
|
+
'openIdConnect',
|
|
276
|
+
'plain',
|
|
277
|
+
'scramSha256',
|
|
278
|
+
'scramSha512',
|
|
279
|
+
'gssapi',
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
description: { type: 'string' },
|
|
283
|
+
name: { type: 'string' },
|
|
284
|
+
in: { type: 'string', enum: ['query', 'header', 'cookie', 'user', 'password'] },
|
|
285
|
+
scheme: { type: 'string' },
|
|
286
|
+
bearerFormat: { type: 'string' },
|
|
287
|
+
flows: 'SecuritySchemeFlows',
|
|
288
|
+
openIdConnectUrl: { type: 'string' },
|
|
289
|
+
scopes: { type: 'array', items: { type: 'string' } },
|
|
290
|
+
},
|
|
291
|
+
required(value) {
|
|
292
|
+
switch (value?.type) {
|
|
293
|
+
case 'apiKey':
|
|
294
|
+
return ['type', 'in'];
|
|
295
|
+
case 'httpApiKey':
|
|
296
|
+
return ['type', 'name', 'in'];
|
|
297
|
+
case 'http':
|
|
298
|
+
return ['type', 'scheme'];
|
|
299
|
+
case 'oauth2':
|
|
300
|
+
return ['type', 'flows'];
|
|
301
|
+
case 'openIdConnect':
|
|
302
|
+
return ['type', 'openIdConnectUrl'];
|
|
303
|
+
default:
|
|
304
|
+
return ['type'];
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
allowed(value) {
|
|
308
|
+
switch (value?.type) {
|
|
309
|
+
case 'apiKey':
|
|
310
|
+
return ['type', 'in', 'description'];
|
|
311
|
+
case 'httpApiKey':
|
|
312
|
+
return ['type', 'name', 'in', 'description'];
|
|
313
|
+
case 'http':
|
|
314
|
+
return ['type', 'scheme', 'bearerFormat', 'description'];
|
|
315
|
+
case 'oauth2':
|
|
316
|
+
return ['type', 'flows', 'description', 'scopes'];
|
|
317
|
+
case 'openIdConnect':
|
|
318
|
+
return ['type', 'openIdConnectUrl', 'description', 'scopes'];
|
|
319
|
+
default:
|
|
320
|
+
return ['type', 'description'];
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
extensionsPrefix: 'x-',
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const AsyncApi3Types: Record<string, NodeType> = {
|
|
327
|
+
// from asyncapi2
|
|
328
|
+
...AsyncApi2Bindings,
|
|
329
|
+
CorrelationId,
|
|
330
|
+
SecuritySchemeFlows,
|
|
331
|
+
ServerVariable,
|
|
332
|
+
Contact,
|
|
333
|
+
License,
|
|
334
|
+
MessageExample,
|
|
335
|
+
Tag,
|
|
336
|
+
Dependencies,
|
|
337
|
+
Schema,
|
|
338
|
+
Discriminator,
|
|
339
|
+
DiscriminatorMapping,
|
|
340
|
+
SchemaProperties,
|
|
341
|
+
ServerMap,
|
|
342
|
+
ExternalDocs,
|
|
343
|
+
Root,
|
|
344
|
+
|
|
345
|
+
Channel,
|
|
346
|
+
Parameter,
|
|
347
|
+
Info,
|
|
348
|
+
Server,
|
|
349
|
+
MessageTrait,
|
|
350
|
+
Operation,
|
|
351
|
+
OperationReply,
|
|
352
|
+
OperationReplyAddress,
|
|
353
|
+
Components,
|
|
354
|
+
ImplicitFlow,
|
|
355
|
+
PasswordFlow,
|
|
356
|
+
ClientCredentials,
|
|
357
|
+
AuthorizationCode,
|
|
358
|
+
SecurityScheme,
|
|
359
|
+
Message,
|
|
360
|
+
OperationTrait,
|
|
361
|
+
ServerVariablesMap: mapOf('ServerVariable'),
|
|
362
|
+
NamedTags: mapOf('Tag'),
|
|
363
|
+
NamedExternalDocs: mapOf('ExternalDocs'),
|
|
364
|
+
NamedChannels: mapOf('Channel'),
|
|
365
|
+
ParametersMap: mapOf('Parameter'),
|
|
366
|
+
NamedOperations: mapOf('Operation'),
|
|
367
|
+
NamedOperationReplies: mapOf('OperationReply'),
|
|
368
|
+
NamedOperationRelyAddresses: mapOf('OperationReplyAddress'),
|
|
369
|
+
NamedSchemas: mapOf('Schema'),
|
|
370
|
+
NamedMessages: mapOf('Message'),
|
|
371
|
+
NamedMessageTraits: mapOf('MessageTrait'),
|
|
372
|
+
NamedOperationTraits: mapOf('OperationTrait'),
|
|
373
|
+
NamedParameters: mapOf('Parameter'),
|
|
374
|
+
NamedSecuritySchemes: mapOf('SecurityScheme'),
|
|
375
|
+
NamedCorrelationIds: mapOf('CorrelationId'),
|
|
376
|
+
ServerList: listOf('Server'),
|
|
377
|
+
SecuritySchemeList: listOf('SecurityScheme'),
|
|
378
|
+
MessageList: listOf('Message'),
|
|
379
|
+
OperationTraitList: listOf('OperationTrait'),
|
|
380
|
+
MessageTraitList: listOf('MessageTrait'),
|
|
381
|
+
MessageExampleList: listOf('MessageExample'),
|
|
382
|
+
TagList: listOf('Tag'),
|
|
383
|
+
};
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import Ajv from '@redocly/ajv/dist/2020';
|
|
4
4
|
import { isPlainObject } from '../utils';
|
|
5
5
|
|
|
6
|
-
import type { NodeType, PropType, ResolveTypeFn } from '.';
|
|
7
6
|
import type { JSONSchema } from 'json-schema-to-ts';
|
|
8
|
-
import {
|
|
7
|
+
import type { NodeType, PropType, ResolveTypeFn } from '.';
|
|
8
|
+
import type { Oas3Schema } from '../typings/openapi';
|
|
9
9
|
|
|
10
10
|
const ajv = new Ajv({
|
|
11
11
|
strictSchema: false,
|
package/src/types/oas3.ts
CHANGED
|
@@ -44,7 +44,7 @@ const TagGroup: NodeType = {
|
|
|
44
44
|
extensionsPrefix: 'x-',
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
const ExternalDocs: NodeType = {
|
|
47
|
+
export const ExternalDocs: NodeType = {
|
|
48
48
|
properties: {
|
|
49
49
|
description: { type: 'string' },
|
|
50
50
|
url: { type: 'string' },
|
|
@@ -369,7 +369,7 @@ const Schema: NodeType = {
|
|
|
369
369
|
extensionsPrefix: 'x-',
|
|
370
370
|
};
|
|
371
371
|
|
|
372
|
-
const Xml: NodeType = {
|
|
372
|
+
export const Xml: NodeType = {
|
|
373
373
|
properties: {
|
|
374
374
|
name: { type: 'string' },
|
|
375
375
|
namespace: { type: 'string' },
|
|
@@ -385,7 +385,7 @@ const SchemaProperties: NodeType = {
|
|
|
385
385
|
additionalProperties: 'Schema',
|
|
386
386
|
};
|
|
387
387
|
|
|
388
|
-
const DiscriminatorMapping: NodeType = {
|
|
388
|
+
export const DiscriminatorMapping: NodeType = {
|
|
389
389
|
properties: {},
|
|
390
390
|
additionalProperties: (value: any) => {
|
|
391
391
|
if (isMappingRef(value)) {
|
|
@@ -396,7 +396,7 @@ const DiscriminatorMapping: NodeType = {
|
|
|
396
396
|
},
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
-
const Discriminator: NodeType = {
|
|
399
|
+
export const Discriminator: NodeType = {
|
|
400
400
|
properties: {
|
|
401
401
|
propertyName: { type: 'string' },
|
|
402
402
|
mapping: 'DiscriminatorMapping',
|
package/src/types/oas3_1.ts
CHANGED
|
@@ -87,7 +87,7 @@ const Operation: NodeType = {
|
|
|
87
87
|
extensionsPrefix: 'x-',
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
const Schema: NodeType = {
|
|
90
|
+
export const Schema: NodeType = {
|
|
91
91
|
properties: {
|
|
92
92
|
$id: { type: 'string' },
|
|
93
93
|
$anchor: { type: 'string' },
|
|
@@ -139,7 +139,7 @@ const Schema: NodeType = {
|
|
|
139
139
|
contains: 'Schema',
|
|
140
140
|
minContains: { type: 'integer', minimum: 0 },
|
|
141
141
|
maxContains: { type: 'integer', minimum: 0 },
|
|
142
|
-
patternProperties: '
|
|
142
|
+
patternProperties: 'PatternProperties',
|
|
143
143
|
propertyNames: 'Schema',
|
|
144
144
|
unevaluatedItems: (value: unknown) => {
|
|
145
145
|
if (typeof value === 'boolean') {
|
|
@@ -186,7 +186,7 @@ const Schema: NodeType = {
|
|
|
186
186
|
extensionsPrefix: 'x-',
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
-
const SchemaProperties: NodeType = {
|
|
189
|
+
export const SchemaProperties: NodeType = {
|
|
190
190
|
properties: {},
|
|
191
191
|
additionalProperties: (value: any) => {
|
|
192
192
|
if (typeof value === 'boolean') {
|
|
@@ -267,7 +267,7 @@ const SecurityScheme: NodeType = {
|
|
|
267
267
|
extensionsPrefix: 'x-',
|
|
268
268
|
};
|
|
269
269
|
|
|
270
|
-
const DependentRequired: NodeType = {
|
|
270
|
+
export const DependentRequired: NodeType = {
|
|
271
271
|
properties: {},
|
|
272
272
|
additionalProperties: { type: 'array', items: { type: 'string' } },
|
|
273
273
|
};
|
|
@@ -278,6 +278,7 @@ export const Oas3_1Types: Record<Oas3_1NodeType, NodeType> = {
|
|
|
278
278
|
Root,
|
|
279
279
|
Schema,
|
|
280
280
|
SchemaProperties,
|
|
281
|
+
PatternProperties: SchemaProperties,
|
|
281
282
|
License,
|
|
282
283
|
Components,
|
|
283
284
|
NamedPathItems: mapOf('PathItem'),
|