@redocly/openapi-core 1.34.4 → 2.0.0-next.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/README.md +42 -4
- package/lib/bundle.d.ts +16 -15
- package/lib/bundle.d.ts.map +1 -0
- package/lib/bundle.js +88 -109
- package/lib/bundle.js.map +1 -0
- package/lib/config/all.d.ts +3 -2
- package/lib/config/all.d.ts.map +1 -0
- package/lib/config/all.js +5 -3
- package/lib/config/all.js.map +1 -0
- package/lib/config/builtIn.d.ts +3 -2
- package/lib/config/builtIn.d.ts.map +1 -0
- package/lib/config/builtIn.js +44 -49
- package/lib/config/builtIn.js.map +1 -0
- package/lib/config/bundle-extends.d.ts +8 -0
- package/lib/config/bundle-extends.d.ts.map +1 -0
- package/lib/config/bundle-extends.js +27 -0
- package/lib/config/bundle-extends.js.map +1 -0
- package/lib/config/config-resolvers.d.ts +15 -27
- package/lib/config/config-resolvers.d.ts.map +1 -0
- package/lib/config/config-resolvers.js +259 -373
- package/lib/config/config-resolvers.js.map +1 -0
- package/lib/config/config.d.ts +22 -26
- package/lib/config/config.d.ts.map +1 -0
- package/lib/config/config.js +104 -112
- package/lib/config/config.js.map +1 -0
- package/lib/config/index.d.ts +8 -7
- package/lib/config/index.d.ts.map +1 -0
- package/lib/config/index.js +8 -23
- package/lib/config/index.js.map +1 -0
- package/lib/config/load.d.ts +8 -19
- package/lib/config/load.d.ts.map +1 -0
- package/lib/config/load.js +62 -107
- package/lib/config/load.js.map +1 -0
- package/lib/config/minimal.d.ts +3 -2
- package/lib/config/minimal.d.ts.map +1 -0
- package/lib/config/minimal.js +5 -3
- package/lib/config/minimal.js.map +1 -0
- package/lib/config/recommended-strict.d.ts +3 -2
- package/lib/config/recommended-strict.d.ts.map +1 -0
- package/lib/config/recommended-strict.js +5 -3
- package/lib/config/recommended-strict.js.map +1 -0
- package/lib/config/recommended.d.ts +3 -2
- package/lib/config/recommended.d.ts.map +1 -0
- package/lib/config/recommended.js +5 -3
- package/lib/config/recommended.js.map +1 -0
- package/lib/config/rules.d.ts +5 -4
- package/lib/config/rules.d.ts.map +1 -0
- package/lib/config/rules.js +4 -6
- package/lib/config/rules.js.map +1 -0
- package/lib/config/spec.d.ts +3 -2
- package/lib/config/spec.d.ts.map +1 -0
- package/lib/config/spec.js +6 -4
- package/lib/config/spec.js.map +1 -0
- package/lib/config/types.d.ts +19 -62
- package/lib/config/types.d.ts.map +1 -0
- package/lib/config/types.js +2 -2
- package/lib/config/types.js.map +1 -0
- package/lib/config/utils.d.ts +5 -9
- package/lib/config/utils.d.ts.map +1 -0
- package/lib/config/utils.js +56 -258
- package/lib/config/utils.js.map +1 -0
- package/lib/config/visitors.d.ts +36 -0
- package/lib/config/visitors.d.ts.map +1 -0
- package/lib/config/visitors.js +88 -0
- package/lib/config/visitors.js.map +1 -0
- package/lib/decorators/arazzo/index.d.ts +1 -0
- package/lib/decorators/arazzo/index.d.ts.map +1 -0
- package/lib/decorators/arazzo/index.js +2 -4
- package/lib/decorators/arazzo/index.js.map +1 -0
- package/lib/decorators/async2/index.d.ts +1 -0
- package/lib/decorators/async2/index.d.ts.map +1 -0
- package/lib/decorators/async2/index.js +2 -4
- package/lib/decorators/async2/index.js.map +1 -0
- package/lib/decorators/async3/index.d.ts +1 -0
- package/lib/decorators/async3/index.d.ts.map +1 -0
- package/lib/decorators/async3/index.js +2 -4
- package/lib/decorators/async3/index.js.map +1 -0
- package/lib/decorators/common/filters/filter-helper.d.ts +2 -1
- package/lib/decorators/common/filters/filter-helper.d.ts.map +1 -0
- package/lib/decorators/common/filters/filter-helper.js +9 -12
- package/lib/decorators/common/filters/filter-helper.js.map +1 -0
- package/lib/decorators/common/filters/filter-in.d.ts +2 -1
- package/lib/decorators/common/filters/filter-in.d.ts.map +1 -0
- package/lib/decorators/common/filters/filter-in.js +5 -8
- package/lib/decorators/common/filters/filter-in.js.map +1 -0
- package/lib/decorators/common/filters/filter-out.d.ts +2 -1
- package/lib/decorators/common/filters/filter-out.d.ts.map +1 -0
- package/lib/decorators/common/filters/filter-out.js +5 -8
- package/lib/decorators/common/filters/filter-out.js.map +1 -0
- package/lib/decorators/common/info-description-override.d.ts +2 -1
- package/lib/decorators/common/info-description-override.d.ts.map +1 -0
- package/lib/decorators/common/info-description-override.js +4 -7
- package/lib/decorators/common/info-description-override.js.map +1 -0
- package/lib/decorators/common/info-override.d.ts +2 -1
- package/lib/decorators/common/info-override.d.ts.map +1 -0
- package/lib/decorators/common/info-override.js +2 -5
- package/lib/decorators/common/info-override.js.map +1 -0
- package/lib/decorators/common/media-type-examples-override.d.ts +2 -1
- package/lib/decorators/common/media-type-examples-override.d.ts.map +1 -0
- package/lib/decorators/common/media-type-examples-override.js +7 -10
- package/lib/decorators/common/media-type-examples-override.js.map +1 -0
- package/lib/decorators/common/operation-description-override.d.ts +2 -1
- package/lib/decorators/common/operation-description-override.d.ts.map +1 -0
- package/lib/decorators/common/operation-description-override.js +4 -7
- package/lib/decorators/common/operation-description-override.js.map +1 -0
- package/lib/decorators/common/remove-x-internal.d.ts +2 -1
- package/lib/decorators/common/remove-x-internal.d.ts.map +1 -0
- package/lib/decorators/common/remove-x-internal.js +11 -14
- package/lib/decorators/common/remove-x-internal.js.map +1 -0
- package/lib/decorators/common/tag-description-override.d.ts +2 -1
- package/lib/decorators/common/tag-description-override.d.ts.map +1 -0
- package/lib/decorators/common/tag-description-override.js +4 -7
- package/lib/decorators/common/tag-description-override.js.map +1 -0
- package/lib/decorators/oas2/index.d.ts +2 -2
- package/lib/decorators/oas2/index.d.ts.map +1 -0
- package/lib/decorators/oas2/index.js +16 -20
- package/lib/decorators/oas2/index.js.map +1 -0
- package/lib/decorators/oas2/remove-unused-components.d.ts +2 -1
- package/lib/decorators/oas2/remove-unused-components.d.ts.map +1 -0
- package/lib/decorators/oas2/remove-unused-components.js +4 -7
- package/lib/decorators/oas2/remove-unused-components.js.map +1 -0
- package/lib/decorators/oas3/index.d.ts +2 -2
- package/lib/decorators/oas3/index.d.ts.map +1 -0
- package/lib/decorators/oas3/index.js +18 -22
- package/lib/decorators/oas3/index.js.map +1 -0
- package/lib/decorators/oas3/remove-unused-components.d.ts +2 -1
- package/lib/decorators/oas3/remove-unused-components.d.ts.map +1 -0
- package/lib/decorators/oas3/remove-unused-components.js +5 -8
- package/lib/decorators/oas3/remove-unused-components.js.map +1 -0
- package/lib/decorators/overlay1/index.d.ts +1 -0
- package/lib/decorators/overlay1/index.d.ts.map +1 -0
- package/lib/decorators/overlay1/index.js +2 -4
- package/lib/decorators/overlay1/index.js.map +1 -0
- package/lib/env.d.ts +1 -0
- package/lib/env.d.ts.map +1 -0
- package/lib/env.js +3 -5
- package/lib/env.js.map +1 -0
- package/lib/format/codeframes.d.ts +2 -1
- package/lib/format/codeframes.d.ts.map +1 -0
- package/lib/format/codeframes.js +15 -19
- package/lib/format/codeframes.js.map +1 -0
- package/lib/format/format.d.ts +2 -1
- package/lib/format/format.d.ts.map +1 -0
- package/lib/format/format.js +57 -62
- package/lib/format/format.js.map +1 -0
- package/lib/index.d.ts +31 -26
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +25 -98
- package/lib/index.js.map +1 -0
- package/lib/js-yaml/index.d.ts +1 -0
- package/lib/js-yaml/index.d.ts.map +1 -0
- package/lib/js-yaml/index.js +7 -11
- package/lib/js-yaml/index.js.map +1 -0
- package/lib/lint.d.ts +12 -13
- package/lib/lint.d.ts.map +1 -0
- package/lib/lint.js +46 -50
- package/lib/lint.js.map +1 -0
- package/lib/logger.d.ts +2 -1
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +15 -17
- package/lib/logger.js.map +1 -0
- package/lib/oas-types.d.ts +395 -3
- package/lib/oas-types.d.ts.map +1 -0
- package/lib/oas-types.js +28 -32
- package/lib/oas-types.js.map +1 -0
- package/lib/ref-utils.d.ts +5 -2
- package/lib/ref-utils.d.ts.map +1 -0
- package/lib/ref-utils.js +30 -33
- package/lib/ref-utils.js.map +1 -0
- package/lib/resolve.d.ts +7 -9
- package/lib/resolve.d.ts.map +1 -0
- package/lib/resolve.js +40 -47
- package/lib/resolve.js.map +1 -0
- package/lib/rules/ajv.d.ts +4 -3
- package/lib/rules/ajv.d.ts.map +1 -0
- package/lib/rules/ajv.js +7 -10
- package/lib/rules/ajv.js.map +1 -0
- package/lib/rules/arazzo/criteria-unique.d.ts +2 -1
- package/lib/rules/arazzo/criteria-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/criteria-unique.js +2 -5
- package/lib/rules/arazzo/criteria-unique.js.map +1 -0
- package/lib/rules/arazzo/index.d.ts +2 -1
- package/lib/rules/arazzo/index.d.ts.map +1 -0
- package/lib/rules/arazzo/index.js +39 -35
- package/lib/rules/arazzo/index.js.map +1 -0
- package/lib/rules/arazzo/parameters-unique.d.ts +2 -1
- package/lib/rules/arazzo/parameters-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/parameters-unique.js +2 -5
- package/lib/rules/arazzo/parameters-unique.js.map +1 -0
- package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -1
- package/lib/rules/arazzo/requestBody-replacements-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/requestBody-replacements-unique.js +2 -5
- package/lib/rules/arazzo/requestBody-replacements-unique.js.map +1 -0
- package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -1
- package/lib/rules/arazzo/sourceDescription-type.d.ts.map +1 -0
- package/lib/rules/arazzo/sourceDescription-type.js +2 -5
- package/lib/rules/arazzo/sourceDescription-type.js.map +1 -0
- package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -1
- package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/sourceDescriptions-name-unique.js +2 -5
- package/lib/rules/arazzo/sourceDescriptions-name-unique.js.map +1 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -1
- package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts.map +1 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.js +2 -5
- package/lib/rules/arazzo/sourceDescriptions-not-empty.js.map +1 -0
- package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -1
- package/lib/rules/arazzo/step-onFailure-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/step-onFailure-unique.js +2 -5
- package/lib/rules/arazzo/step-onFailure-unique.js.map +1 -0
- package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -1
- package/lib/rules/arazzo/step-onSuccess-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/step-onSuccess-unique.js +2 -5
- package/lib/rules/arazzo/step-onSuccess-unique.js.map +1 -0
- package/lib/rules/arazzo/stepId-unique.d.ts +2 -1
- package/lib/rules/arazzo/stepId-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/stepId-unique.js +2 -5
- package/lib/rules/arazzo/stepId-unique.js.map +1 -0
- package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -1
- package/lib/rules/arazzo/workflow-dependsOn.d.ts.map +1 -0
- package/lib/rules/arazzo/workflow-dependsOn.js +2 -5
- package/lib/rules/arazzo/workflow-dependsOn.js.map +1 -0
- package/lib/rules/arazzo/workflowId-unique.d.ts +2 -1
- package/lib/rules/arazzo/workflowId-unique.d.ts.map +1 -0
- package/lib/rules/arazzo/workflowId-unique.js +2 -5
- package/lib/rules/arazzo/workflowId-unique.js.map +1 -0
- package/lib/rules/async2/channels-kebab-case.d.ts +2 -1
- package/lib/rules/async2/channels-kebab-case.d.ts.map +1 -0
- package/lib/rules/async2/channels-kebab-case.js +2 -5
- package/lib/rules/async2/channels-kebab-case.js.map +1 -0
- package/lib/rules/async2/index.d.ts +2 -1
- package/lib/rules/async2/index.d.ts.map +1 -0
- package/lib/rules/async2/index.js +21 -26
- package/lib/rules/async2/index.js.map +1 -0
- package/lib/rules/async2/no-channel-trailing-slash.d.ts +2 -1
- package/lib/rules/async2/no-channel-trailing-slash.d.ts.map +1 -0
- package/lib/rules/async2/no-channel-trailing-slash.js +2 -5
- package/lib/rules/async2/no-channel-trailing-slash.js.map +1 -0
- package/lib/rules/async3/channels-kebab-case.d.ts +2 -1
- package/lib/rules/async3/channels-kebab-case.d.ts.map +1 -0
- package/lib/rules/async3/channels-kebab-case.js +2 -5
- package/lib/rules/async3/channels-kebab-case.js.map +1 -0
- package/lib/rules/async3/index.d.ts +2 -1
- package/lib/rules/async3/index.d.ts.map +1 -0
- package/lib/rules/async3/index.js +21 -26
- package/lib/rules/async3/index.js.map +1 -0
- package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -1
- package/lib/rules/async3/no-channel-trailing-slash.d.ts.map +1 -0
- package/lib/rules/async3/no-channel-trailing-slash.js +3 -6
- package/lib/rules/async3/no-channel-trailing-slash.js.map +1 -0
- package/lib/rules/common/assertions/asserts.d.ts +3 -3
- package/lib/rules/common/assertions/asserts.d.ts.map +1 -0
- package/lib/rules/common/assertions/asserts.js +35 -51
- package/lib/rules/common/assertions/asserts.js.map +1 -0
- package/lib/rules/common/assertions/index.d.ts +4 -3
- package/lib/rules/common/assertions/index.d.ts.map +1 -0
- package/lib/rules/common/assertions/index.js +7 -10
- package/lib/rules/common/assertions/index.js.map +1 -0
- package/lib/rules/common/assertions/utils.d.ts +5 -4
- package/lib/rules/common/assertions/utils.d.ts.map +1 -0
- package/lib/rules/common/assertions/utils.js +21 -29
- package/lib/rules/common/assertions/utils.js.map +1 -0
- package/lib/rules/common/info-contact.d.ts +2 -1
- package/lib/rules/common/info-contact.d.ts.map +1 -0
- package/lib/rules/common/info-contact.js +4 -7
- package/lib/rules/common/info-contact.js.map +1 -0
- package/lib/rules/common/info-license-strict.d.ts +2 -1
- package/lib/rules/common/info-license-strict.d.ts.map +1 -0
- package/lib/rules/common/info-license-strict.js +7 -10
- package/lib/rules/common/info-license-strict.js.map +1 -0
- package/lib/rules/common/info-license-url.d.ts +2 -1
- package/lib/rules/common/info-license-url.d.ts.map +1 -0
- package/lib/rules/common/info-license-url.js +4 -7
- package/lib/rules/common/info-license-url.js.map +1 -0
- package/lib/rules/common/info-license.d.ts +2 -1
- package/lib/rules/common/info-license.d.ts.map +1 -0
- package/lib/rules/common/info-license.js +4 -7
- package/lib/rules/common/info-license.js.map +1 -0
- package/lib/rules/common/no-ambiguous-paths.d.ts +2 -1
- package/lib/rules/common/no-ambiguous-paths.d.ts.map +1 -0
- package/lib/rules/common/no-ambiguous-paths.js +2 -5
- package/lib/rules/common/no-ambiguous-paths.js.map +1 -0
- package/lib/rules/common/no-enum-type-mismatch.d.ts +2 -1
- package/lib/rules/common/no-enum-type-mismatch.d.ts.map +1 -0
- package/lib/rules/common/no-enum-type-mismatch.js +6 -9
- package/lib/rules/common/no-enum-type-mismatch.js.map +1 -0
- package/lib/rules/common/no-http-verbs-in-paths.d.ts +2 -1
- package/lib/rules/common/no-http-verbs-in-paths.d.ts.map +1 -0
- package/lib/rules/common/no-http-verbs-in-paths.js +5 -8
- package/lib/rules/common/no-http-verbs-in-paths.js.map +1 -0
- package/lib/rules/common/no-identical-paths.d.ts +2 -1
- package/lib/rules/common/no-identical-paths.d.ts.map +1 -0
- package/lib/rules/common/no-identical-paths.js +2 -5
- package/lib/rules/common/no-identical-paths.js.map +1 -0
- package/lib/rules/common/no-invalid-parameter-examples.d.ts +1 -0
- package/lib/rules/common/no-invalid-parameter-examples.d.ts.map +1 -0
- package/lib/rules/common/no-invalid-parameter-examples.js +5 -9
- package/lib/rules/common/no-invalid-parameter-examples.js.map +1 -0
- package/lib/rules/common/no-invalid-schema-examples.d.ts +2 -1
- package/lib/rules/common/no-invalid-schema-examples.d.ts.map +1 -0
- package/lib/rules/common/no-invalid-schema-examples.js +5 -9
- package/lib/rules/common/no-invalid-schema-examples.js.map +1 -0
- package/lib/rules/common/no-path-trailing-slash.d.ts +2 -1
- package/lib/rules/common/no-path-trailing-slash.d.ts.map +1 -0
- package/lib/rules/common/no-path-trailing-slash.js +2 -5
- package/lib/rules/common/no-path-trailing-slash.js.map +1 -0
- package/lib/rules/common/no-required-schema-properties-undefined.d.ts +2 -1
- package/lib/rules/common/no-required-schema-properties-undefined.d.ts.map +1 -0
- package/lib/rules/common/no-required-schema-properties-undefined.js +6 -8
- package/lib/rules/common/no-required-schema-properties-undefined.js.map +1 -0
- package/lib/rules/common/no-schema-type-mismatch.d.ts +2 -1
- package/lib/rules/common/no-schema-type-mismatch.d.ts.map +1 -0
- package/lib/rules/common/no-schema-type-mismatch.js +2 -5
- package/lib/rules/common/no-schema-type-mismatch.js.map +1 -0
- package/lib/rules/common/operation-2xx-response.d.ts +2 -1
- package/lib/rules/common/operation-2xx-response.d.ts.map +1 -0
- package/lib/rules/common/operation-2xx-response.js +5 -8
- package/lib/rules/common/operation-2xx-response.js.map +1 -0
- package/lib/rules/common/operation-4xx-response.d.ts +2 -1
- package/lib/rules/common/operation-4xx-response.d.ts.map +1 -0
- package/lib/rules/common/operation-4xx-response.js +5 -8
- package/lib/rules/common/operation-4xx-response.js.map +1 -0
- package/lib/rules/common/operation-description.d.ts +2 -1
- package/lib/rules/common/operation-description.d.ts.map +1 -0
- package/lib/rules/common/operation-description.js +4 -7
- package/lib/rules/common/operation-description.js.map +1 -0
- package/lib/rules/common/operation-operationId-unique.d.ts +2 -1
- package/lib/rules/common/operation-operationId-unique.d.ts.map +1 -0
- package/lib/rules/common/operation-operationId-unique.js +2 -5
- package/lib/rules/common/operation-operationId-unique.js.map +1 -0
- package/lib/rules/common/operation-operationId-url-safe.d.ts +2 -1
- package/lib/rules/common/operation-operationId-url-safe.d.ts.map +1 -0
- package/lib/rules/common/operation-operationId-url-safe.js +2 -5
- package/lib/rules/common/operation-operationId-url-safe.js.map +1 -0
- package/lib/rules/common/operation-operationId.d.ts +2 -1
- package/lib/rules/common/operation-operationId.d.ts.map +1 -0
- package/lib/rules/common/operation-operationId.js +4 -7
- package/lib/rules/common/operation-operationId.js.map +1 -0
- package/lib/rules/common/operation-parameters-unique.d.ts +2 -1
- package/lib/rules/common/operation-parameters-unique.d.ts.map +1 -0
- package/lib/rules/common/operation-parameters-unique.js +2 -5
- package/lib/rules/common/operation-parameters-unique.js.map +1 -0
- package/lib/rules/common/operation-singular-tag.d.ts +2 -1
- package/lib/rules/common/operation-singular-tag.d.ts.map +1 -0
- package/lib/rules/common/operation-singular-tag.js +2 -5
- package/lib/rules/common/operation-singular-tag.js.map +1 -0
- package/lib/rules/common/operation-summary.d.ts +2 -1
- package/lib/rules/common/operation-summary.d.ts.map +1 -0
- package/lib/rules/common/operation-summary.js +4 -7
- package/lib/rules/common/operation-summary.js.map +1 -0
- package/lib/rules/common/operation-tag-defined.d.ts +2 -1
- package/lib/rules/common/operation-tag-defined.d.ts.map +1 -0
- package/lib/rules/common/operation-tag-defined.js +2 -5
- package/lib/rules/common/operation-tag-defined.js.map +1 -0
- package/lib/rules/common/parameter-description.d.ts +2 -1
- package/lib/rules/common/parameter-description.d.ts.map +1 -0
- package/lib/rules/common/parameter-description.js +2 -5
- package/lib/rules/common/parameter-description.js.map +1 -0
- package/lib/rules/common/path-declaration-must-exist.d.ts +2 -1
- package/lib/rules/common/path-declaration-must-exist.d.ts.map +1 -0
- package/lib/rules/common/path-declaration-must-exist.js +2 -5
- package/lib/rules/common/path-declaration-must-exist.js.map +1 -0
- package/lib/rules/common/path-excludes-patterns.d.ts +2 -1
- package/lib/rules/common/path-excludes-patterns.d.ts.map +1 -0
- package/lib/rules/common/path-excludes-patterns.js +2 -5
- package/lib/rules/common/path-excludes-patterns.js.map +1 -0
- package/lib/rules/common/path-http-verbs-order.d.ts +2 -1
- package/lib/rules/common/path-http-verbs-order.d.ts.map +1 -0
- package/lib/rules/common/path-http-verbs-order.js +2 -5
- package/lib/rules/common/path-http-verbs-order.js.map +1 -0
- package/lib/rules/common/path-not-include-query.d.ts +2 -1
- package/lib/rules/common/path-not-include-query.d.ts.map +1 -0
- package/lib/rules/common/path-not-include-query.js +2 -5
- package/lib/rules/common/path-not-include-query.js.map +1 -0
- package/lib/rules/common/path-params-defined.d.ts +2 -1
- package/lib/rules/common/path-params-defined.d.ts.map +1 -0
- package/lib/rules/common/path-params-defined.js +2 -5
- package/lib/rules/common/path-params-defined.js.map +1 -0
- package/lib/rules/common/path-segment-plural.d.ts +2 -1
- package/lib/rules/common/path-segment-plural.d.ts.map +1 -0
- package/lib/rules/common/path-segment-plural.js +6 -9
- package/lib/rules/common/path-segment-plural.js.map +1 -0
- package/lib/rules/common/paths-kebab-case.d.ts +2 -1
- package/lib/rules/common/paths-kebab-case.d.ts.map +1 -0
- package/lib/rules/common/paths-kebab-case.js +2 -5
- package/lib/rules/common/paths-kebab-case.js.map +1 -0
- package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -1
- package/lib/rules/common/required-string-property-missing-min-length.d.ts.map +1 -0
- package/lib/rules/common/required-string-property-missing-min-length.js +2 -5
- package/lib/rules/common/required-string-property-missing-min-length.js.map +1 -0
- package/lib/rules/common/response-contains-header.d.ts +2 -1
- package/lib/rules/common/response-contains-header.d.ts.map +1 -0
- package/lib/rules/common/response-contains-header.js +5 -8
- package/lib/rules/common/response-contains-header.js.map +1 -0
- package/lib/rules/common/scalar-property-missing-example.d.ts +2 -1
- package/lib/rules/common/scalar-property-missing-example.d.ts.map +1 -0
- package/lib/rules/common/scalar-property-missing-example.js +6 -8
- package/lib/rules/common/scalar-property-missing-example.js.map +1 -0
- package/lib/rules/common/security-defined.d.ts +2 -1
- package/lib/rules/common/security-defined.d.ts.map +1 -0
- package/lib/rules/common/security-defined.js +2 -5
- package/lib/rules/common/security-defined.js.map +1 -0
- package/lib/rules/common/spec-strict-refs.d.ts +2 -1
- package/lib/rules/common/spec-strict-refs.d.ts.map +1 -0
- package/lib/rules/common/spec-strict-refs.js +4 -7
- package/lib/rules/common/spec-strict-refs.js.map +1 -0
- package/lib/rules/common/struct.d.ts +2 -1
- package/lib/rules/common/struct.d.ts.map +1 -0
- package/lib/rules/common/struct.js +19 -22
- package/lib/rules/common/struct.js.map +1 -0
- package/lib/rules/common/tag-description.d.ts +2 -1
- package/lib/rules/common/tag-description.d.ts.map +1 -0
- package/lib/rules/common/tag-description.js +4 -7
- package/lib/rules/common/tag-description.js.map +1 -0
- package/lib/rules/common/tags-alphabetical.d.ts +2 -1
- package/lib/rules/common/tags-alphabetical.d.ts.map +1 -0
- package/lib/rules/common/tags-alphabetical.js +2 -5
- package/lib/rules/common/tags-alphabetical.js.map +1 -0
- package/lib/rules/no-unresolved-refs.d.ts +4 -3
- package/lib/rules/no-unresolved-refs.d.ts.map +1 -0
- package/lib/rules/no-unresolved-refs.js +5 -9
- package/lib/rules/no-unresolved-refs.js.map +1 -0
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +2 -1
- package/lib/rules/oas2/boolean-parameter-prefixes.d.ts.map +1 -0
- package/lib/rules/oas2/boolean-parameter-prefixes.js +2 -5
- package/lib/rules/oas2/boolean-parameter-prefixes.js.map +1 -0
- package/lib/rules/oas2/index.d.ts +2 -1
- package/lib/rules/oas2/index.d.ts.map +1 -0
- package/lib/rules/oas2/index.js +94 -99
- package/lib/rules/oas2/index.js.map +1 -0
- package/lib/rules/oas2/request-mime-type.d.ts +2 -1
- package/lib/rules/oas2/request-mime-type.d.ts.map +1 -0
- package/lib/rules/oas2/request-mime-type.js +5 -8
- package/lib/rules/oas2/request-mime-type.js.map +1 -0
- package/lib/rules/oas2/response-contains-property.d.ts +2 -1
- package/lib/rules/oas2/response-contains-property.d.ts.map +1 -0
- package/lib/rules/oas2/response-contains-property.js +5 -8
- package/lib/rules/oas2/response-contains-property.js.map +1 -0
- package/lib/rules/oas2/response-mime-type.d.ts +2 -1
- package/lib/rules/oas2/response-mime-type.d.ts.map +1 -0
- package/lib/rules/oas2/response-mime-type.js +5 -8
- package/lib/rules/oas2/response-mime-type.js.map +1 -0
- package/lib/rules/oas3/array-parameter-serialization.d.ts +2 -1
- package/lib/rules/oas3/array-parameter-serialization.d.ts.map +1 -0
- package/lib/rules/oas3/array-parameter-serialization.js +4 -7
- package/lib/rules/oas3/array-parameter-serialization.js.map +1 -0
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +2 -1
- package/lib/rules/oas3/boolean-parameter-prefixes.d.ts.map +1 -0
- package/lib/rules/oas3/boolean-parameter-prefixes.js +2 -5
- package/lib/rules/oas3/boolean-parameter-prefixes.js.map +1 -0
- package/lib/rules/oas3/component-name-unique.d.ts +2 -1
- package/lib/rules/oas3/component-name-unique.d.ts.map +1 -0
- package/lib/rules/oas3/component-name-unique.js +2 -5
- package/lib/rules/oas3/component-name-unique.js.map +1 -0
- package/lib/rules/oas3/index.d.ts +2 -1
- package/lib/rules/oas3/index.d.ts.map +1 -0
- package/lib/rules/oas3/index.js +118 -123
- package/lib/rules/oas3/index.js.map +1 -0
- package/lib/rules/oas3/no-empty-servers.d.ts +2 -1
- package/lib/rules/oas3/no-empty-servers.d.ts.map +1 -0
- package/lib/rules/oas3/no-empty-servers.js +2 -5
- package/lib/rules/oas3/no-empty-servers.js.map +1 -0
- package/lib/rules/oas3/no-example-value-and-externalValue.d.ts +2 -1
- package/lib/rules/oas3/no-example-value-and-externalValue.d.ts.map +1 -0
- package/lib/rules/oas3/no-example-value-and-externalValue.js +2 -5
- package/lib/rules/oas3/no-example-value-and-externalValue.js.map +1 -0
- package/lib/rules/oas3/no-invalid-media-type-examples.d.ts +2 -1
- package/lib/rules/oas3/no-invalid-media-type-examples.d.ts.map +1 -0
- package/lib/rules/oas3/no-invalid-media-type-examples.js +6 -10
- package/lib/rules/oas3/no-invalid-media-type-examples.js.map +1 -0
- package/lib/rules/oas3/no-server-example.com.d.ts +2 -1
- package/lib/rules/oas3/no-server-example.com.d.ts.map +1 -0
- package/lib/rules/oas3/no-server-example.com.js +2 -5
- package/lib/rules/oas3/no-server-example.com.js.map +1 -0
- package/lib/rules/oas3/no-server-trailing-slash.d.ts +2 -1
- package/lib/rules/oas3/no-server-trailing-slash.d.ts.map +1 -0
- package/lib/rules/oas3/no-server-trailing-slash.js +2 -5
- package/lib/rules/oas3/no-server-trailing-slash.js.map +1 -0
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -1
- package/lib/rules/oas3/no-server-variables-empty-enum.d.ts.map +1 -0
- package/lib/rules/oas3/no-server-variables-empty-enum.js +2 -5
- package/lib/rules/oas3/no-server-variables-empty-enum.js.map +1 -0
- package/lib/rules/oas3/no-undefined-server-variable.d.ts +2 -1
- package/lib/rules/oas3/no-undefined-server-variable.d.ts.map +1 -0
- package/lib/rules/oas3/no-undefined-server-variable.js +3 -6
- package/lib/rules/oas3/no-undefined-server-variable.js.map +1 -0
- package/lib/rules/oas3/no-unused-components.d.ts +2 -1
- package/lib/rules/oas3/no-unused-components.d.ts.map +1 -0
- package/lib/rules/oas3/no-unused-components.js +2 -5
- package/lib/rules/oas3/no-unused-components.js.map +1 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +2 -1
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts.map +1 -0
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +6 -9
- package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js.map +1 -0
- package/lib/rules/oas3/request-mime-type.d.ts +2 -1
- package/lib/rules/oas3/request-mime-type.d.ts.map +1 -0
- package/lib/rules/oas3/request-mime-type.js +6 -9
- package/lib/rules/oas3/request-mime-type.js.map +1 -0
- package/lib/rules/oas3/response-contains-property.d.ts +2 -1
- package/lib/rules/oas3/response-contains-property.d.ts.map +1 -0
- package/lib/rules/oas3/response-contains-property.js +5 -8
- package/lib/rules/oas3/response-contains-property.js.map +1 -0
- package/lib/rules/oas3/response-mime-type.d.ts +2 -1
- package/lib/rules/oas3/response-mime-type.d.ts.map +1 -0
- package/lib/rules/oas3/response-mime-type.js +6 -9
- package/lib/rules/oas3/response-mime-type.js.map +1 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -1
- package/lib/rules/oas3/spec-components-invalid-map-name.d.ts.map +1 -0
- package/lib/rules/oas3/spec-components-invalid-map-name.js +2 -5
- package/lib/rules/oas3/spec-components-invalid-map-name.js.map +1 -0
- package/lib/rules/other/stats.d.ts +4 -3
- package/lib/rules/other/stats.d.ts.map +1 -0
- package/lib/rules/other/stats.js +2 -5
- package/lib/rules/other/stats.js.map +1 -0
- package/lib/rules/overlay1/index.d.ts +2 -1
- package/lib/rules/overlay1/index.d.ts.map +1 -0
- package/lib/rules/overlay1/index.js +9 -11
- package/lib/rules/overlay1/index.js.map +1 -0
- package/lib/rules/respect/no-criteria-xpath.d.ts +2 -1
- package/lib/rules/respect/no-criteria-xpath.d.ts.map +1 -0
- package/lib/rules/respect/no-criteria-xpath.js +2 -5
- package/lib/rules/respect/no-criteria-xpath.js.map +1 -0
- package/lib/rules/respect/no-x-security-scheme-name-in-workflow.d.ts +3 -0
- package/lib/rules/respect/no-x-security-scheme-name-in-workflow.d.ts.map +1 -0
- package/lib/rules/respect/no-x-security-scheme-name-in-workflow.js +21 -0
- package/lib/rules/respect/no-x-security-scheme-name-in-workflow.js.map +1 -0
- package/lib/rules/respect/no-x-security-scheme-name-without-openapi.d.ts +3 -0
- package/lib/rules/respect/no-x-security-scheme-name-without-openapi.d.ts.map +1 -0
- package/lib/rules/respect/no-x-security-scheme-name-without-openapi.js +25 -0
- package/lib/rules/respect/no-x-security-scheme-name-without-openapi.js.map +1 -0
- package/lib/rules/respect/respect-supported-versions.d.ts +2 -1
- package/lib/rules/respect/respect-supported-versions.d.ts.map +1 -0
- package/lib/rules/respect/respect-supported-versions.js +7 -10
- package/lib/rules/respect/respect-supported-versions.js.map +1 -0
- package/lib/rules/respect/x-security-scheme-required-values.d.ts +3 -0
- package/lib/rules/respect/x-security-scheme-required-values.d.ts.map +1 -0
- package/lib/rules/respect/x-security-scheme-required-values.js +60 -0
- package/lib/rules/respect/x-security-scheme-required-values.js.map +1 -0
- package/lib/rules/utils.d.ts +4 -4
- package/lib/rules/utils.d.ts.map +1 -0
- package/lib/rules/utils.js +20 -43
- package/lib/rules/utils.js.map +1 -0
- package/lib/types/arazzo.d.ts +2 -1
- package/lib/types/arazzo.d.ts.map +1 -0
- package/lib/types/arazzo.js +40 -23
- package/lib/types/arazzo.js.map +1 -0
- package/lib/types/asyncapi2.d.ts +2 -1
- package/lib/types/asyncapi2.d.ts.map +1 -0
- package/lib/types/asyncapi2.js +54 -56
- package/lib/types/asyncapi2.js.map +1 -0
- package/lib/types/asyncapi3.d.ts +2 -1
- package/lib/types/asyncapi3.d.ts.map +1 -0
- package/lib/types/asyncapi3.js +41 -43
- package/lib/types/asyncapi3.js.map +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +7 -13
- package/lib/types/index.js.map +1 -0
- package/lib/types/json-schema-adapter.d.ts +2 -1
- package/lib/types/json-schema-adapter.d.ts.map +1 -0
- package/lib/types/json-schema-adapter.js +15 -17
- package/lib/types/json-schema-adapter.js.map +1 -0
- package/lib/types/oas2.d.ts +85 -3
- package/lib/types/oas2.d.ts.map +1 -0
- package/lib/types/oas2.js +17 -19
- package/lib/types/oas2.js.map +1 -0
- package/lib/types/oas3.d.ts +159 -3
- package/lib/types/oas3.d.ts.map +1 -0
- package/lib/types/oas3.js +44 -46
- package/lib/types/oas3.js.map +1 -0
- package/lib/types/oas3_1.d.ts +162 -3
- package/lib/types/oas3_1.d.ts.map +1 -0
- package/lib/types/oas3_1.js +19 -21
- package/lib/types/oas3_1.js.map +1 -0
- package/lib/types/overlay.d.ts +2 -1
- package/lib/types/overlay.d.ts.map +1 -0
- package/lib/types/overlay.js +4 -6
- package/lib/types/overlay.js.map +1 -0
- package/lib/types/redocly-yaml.d.ts +6 -10
- package/lib/types/redocly-yaml.d.ts.map +1 -0
- package/lib/types/redocly-yaml.js +74 -813
- package/lib/types/redocly-yaml.js.map +1 -0
- package/lib/typings/arazzo.d.ts +41 -0
- package/lib/typings/arazzo.d.ts.map +1 -0
- package/lib/typings/arazzo.js +3 -5
- package/lib/typings/arazzo.js.map +1 -0
- package/lib/typings/asyncapi.d.ts +1 -0
- package/lib/typings/asyncapi.d.ts.map +1 -0
- package/lib/typings/asyncapi.js +2 -2
- package/lib/typings/asyncapi.js.map +1 -0
- package/lib/typings/asyncapi3.d.ts +1 -0
- package/lib/typings/asyncapi3.d.ts.map +1 -0
- package/lib/typings/asyncapi3.js +2 -2
- package/lib/typings/asyncapi3.js.map +1 -0
- package/lib/typings/common.d.ts +1 -0
- package/lib/typings/common.d.ts.map +1 -0
- package/lib/typings/common.js +2 -2
- package/lib/typings/common.js.map +1 -0
- package/lib/typings/openapi.d.ts +45 -15
- package/lib/typings/openapi.d.ts.map +1 -0
- package/lib/typings/openapi.js +2 -2
- package/lib/typings/openapi.js.map +1 -0
- package/lib/typings/overlay.d.ts +1 -0
- package/lib/typings/overlay.d.ts.map +1 -0
- package/lib/typings/overlay.js +2 -4
- package/lib/typings/overlay.js.map +1 -0
- package/lib/typings/swagger.d.ts +2 -1
- package/lib/typings/swagger.d.ts.map +1 -0
- package/lib/typings/swagger.js +2 -2
- package/lib/typings/swagger.js.map +1 -0
- package/lib/utils/error.d.ts +3 -0
- package/lib/utils/error.d.ts.map +1 -0
- package/lib/utils/error.js +3 -0
- package/lib/utils/error.js.map +1 -0
- package/lib/utils.d.ts +6 -11
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +50 -123
- package/lib/utils.js.map +1 -0
- package/lib/visitors.d.ts +16 -15
- package/lib/visitors.d.ts.map +1 -0
- package/lib/visitors.js +4 -6
- package/lib/visitors.js.map +1 -0
- package/lib/walk.d.ts +9 -8
- package/lib/walk.d.ts.map +1 -0
- package/lib/walk.js +31 -28
- package/lib/walk.js.map +1 -0
- package/package.json +31 -10
- package/CHANGELOG.md +0 -563
- package/__tests__/utils.ts +0 -92
- package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +0 -4
- package/lib/benchmark/benches/lint-with-many-rules.bench.js +0 -38
- package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +0 -4
- package/lib/benchmark/benches/lint-with-nested-rule.bench.js +0 -44
- package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +0 -4
- package/lib/benchmark/benches/lint-with-no-rules.bench.js +0 -25
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +0 -4
- package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -37
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +0 -4
- package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +0 -36
- package/lib/benchmark/benches/recommended-oas3.bench.d.ts +0 -3
- package/lib/benchmark/benches/recommended-oas3.bench.js +0 -21
- package/lib/benchmark/benches/resolve-with-no-external.bench.d.ts +0 -3
- package/lib/benchmark/benches/resolve-with-no-external.bench.js +0 -22
- package/lib/benchmark/utils.d.ts +0 -6
- package/lib/benchmark/utils.js +0 -34
- package/lib/decorators/common/registry-dependencies.d.ts +0 -2
- package/lib/decorators/common/registry-dependencies.js +0 -24
- package/lib/output.d.ts +0 -3
- package/lib/output.js +0 -9
- package/lib/redocly/domains.d.ts +0 -14
- package/lib/redocly/domains.js +0 -41
- package/lib/redocly/index.d.ts +0 -30
- package/lib/redocly/index.js +0 -131
- package/lib/redocly/redocly-client-types.d.ts +0 -8
- package/lib/redocly/redocly-client-types.js +0 -2
- package/lib/redocly/registry-api-types.d.ts +0 -29
- package/lib/redocly/registry-api-types.js +0 -2
- package/lib/redocly/registry-api.d.ts +0 -17
- package/lib/redocly/registry-api.js +0 -100
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +0 -461
- package/src/__tests__/bundle.test.ts +0 -478
- package/src/__tests__/codeframes.test.ts +0 -530
- package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +0 -5
- package/src/__tests__/fixtures/extension.js +0 -24
- package/src/__tests__/fixtures/lint/openapi.yaml +0 -10
- package/src/__tests__/fixtures/redocly.yaml +0 -2
- package/src/__tests__/fixtures/refs/definitions.yaml +0 -3
- package/src/__tests__/fixtures/refs/examples.yaml +0 -8
- package/src/__tests__/fixtures/refs/external-request-body.yaml +0 -13
- package/src/__tests__/fixtures/refs/externalref.yaml +0 -35
- package/src/__tests__/fixtures/refs/hosted.yaml +0 -35
- package/src/__tests__/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +0 -21
- package/src/__tests__/fixtures/refs/openapi-with-external-refs.yaml +0 -33
- package/src/__tests__/fixtures/refs/openapi-with-special-names-in-props.yaml +0 -19
- package/src/__tests__/fixtures/refs/openapi-with-url-refs.yaml +0 -18
- package/src/__tests__/fixtures/refs/param-b.yaml +0 -1
- package/src/__tests__/fixtures/refs/param-c.yaml +0 -1
- package/src/__tests__/fixtures/refs/rename.yaml +0 -1
- package/src/__tests__/fixtures/refs/requestBody.yaml +0 -9
- package/src/__tests__/fixtures/refs/schema-a.yaml +0 -1
- package/src/__tests__/fixtures/refs/simple.yaml +0 -1
- package/src/__tests__/fixtures/refs/vendor.schema.yaml +0 -20
- package/src/__tests__/fixtures/resolve/External.yaml +0 -10
- package/src/__tests__/fixtures/resolve/External2.yaml +0 -4
- package/src/__tests__/fixtures/resolve/description.md +0 -3
- package/src/__tests__/fixtures/resolve/externalInfo.yaml +0 -4
- package/src/__tests__/fixtures/resolve/externalLicense.yaml +0 -1
- package/src/__tests__/fixtures/resolve/openapi-with-back.yaml +0 -13
- package/src/__tests__/fixtures/resolve/openapi-with-md-description.yaml +0 -5
- package/src/__tests__/fixtures/resolve/openapi.yaml +0 -28
- package/src/__tests__/fixtures/resolve/schemas/type-a.yaml +0 -10
- package/src/__tests__/fixtures/resolve/schemas/type-b.yaml +0 -6
- package/src/__tests__/fixtures/resolve/transitive/a.yaml +0 -1
- package/src/__tests__/fixtures/resolve/transitive/components.yaml +0 -5
- package/src/__tests__/fixtures/resolve/transitive/schemas.yaml +0 -3
- package/src/__tests__/format.test.ts +0 -147
- package/src/__tests__/js-yaml.test.ts +0 -73
- package/src/__tests__/lint.test.ts +0 -1772
- package/src/__tests__/logger-browser.test.ts +0 -53
- package/src/__tests__/logger.test.ts +0 -47
- package/src/__tests__/login.test.ts +0 -17
- package/src/__tests__/normalizeVisitors.test.ts +0 -169
- package/src/__tests__/output-browser.test.ts +0 -18
- package/src/__tests__/output.test.ts +0 -15
- package/src/__tests__/ref-utils.test.ts +0 -142
- package/src/__tests__/resolve-http.test.ts +0 -77
- package/src/__tests__/resolve.test.ts +0 -431
- package/src/__tests__/utils-browser.test.ts +0 -11
- package/src/__tests__/utils.test.ts +0 -144
- package/src/__tests__/walk.test.ts +0 -1596
- package/src/benchmark/benches/lint-with-many-rules.bench.ts +0 -41
- package/src/benchmark/benches/lint-with-nested-rule.bench.ts +0 -45
- package/src/benchmark/benches/lint-with-no-rules.bench.ts +0 -27
- package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +0 -40
- package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +0 -38
- package/src/benchmark/benches/rebilly.yaml +0 -32272
- package/src/benchmark/benches/recommended-oas3.bench.ts +0 -22
- package/src/benchmark/benches/resolve-with-no-external.bench.ts +0 -23
- package/src/benchmark/benchmark.js +0 -311
- package/src/benchmark/colors.js +0 -29
- package/src/benchmark/fork.js +0 -87
- package/src/benchmark/utils.ts +0 -37
- package/src/bundle.ts +0 -531
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +0 -485
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +0 -232
- package/src/config/__tests__/config-resolvers.test.ts +0 -668
- package/src/config/__tests__/config.test.ts +0 -356
- package/src/config/__tests__/fixtures/ingore-file.ts +0 -8
- package/src/config/__tests__/fixtures/load-external.yaml +0 -2
- package/src/config/__tests__/fixtures/load-redocly.yaml +0 -2
- package/src/config/__tests__/fixtures/plugin-config.yaml +0 -2
- package/src/config/__tests__/fixtures/plugin.js +0 -56
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +0 -11
- package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +0 -69
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +0 -7
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-commonjs-export-function.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +0 -17
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-esm.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +0 -18
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-plugin-init.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-realm-plugin.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +0 -15
- package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +0 -9
- package/src/config/__tests__/fixtures/resolve-config/plugin-esm.mjs +0 -10
- package/src/config/__tests__/fixtures/resolve-config/plugin-with-export-function.cjs +0 -10
- package/src/config/__tests__/fixtures/resolve-config/plugin-with-init-logic.js +0 -9
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +0 -80
- package/src/config/__tests__/fixtures/resolve-config/realm-plugin.js +0 -12
- package/src/config/__tests__/fixtures/resolve-refs-in-config/config-with-refs.yaml +0 -8
- package/src/config/__tests__/fixtures/resolve-refs-in-config/rules.yaml +0 -2
- package/src/config/__tests__/fixtures/resolve-refs-in-config/seo.yaml +0 -1
- package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +0 -3
- package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +0 -4
- package/src/config/__tests__/load.test.ts +0 -320
- package/src/config/__tests__/resolve-plugins.test.ts +0 -30
- package/src/config/__tests__/utils.test.ts +0 -225
- package/src/config/all.ts +0 -234
- package/src/config/builtIn.ts +0 -59
- package/src/config/config-resolvers.ts +0 -657
- package/src/config/config.ts +0 -423
- package/src/config/index.ts +0 -7
- package/src/config/load.ts +0 -213
- package/src/config/minimal.ts +0 -210
- package/src/config/recommended-strict.ts +0 -210
- package/src/config/recommended.ts +0 -210
- package/src/config/rules.ts +0 -72
- package/src/config/spec.ts +0 -33
- package/src/config/types.ts +0 -306
- package/src/config/utils.ts +0 -439
- package/src/decorators/__tests__/filter-in.test.ts +0 -313
- package/src/decorators/__tests__/filter-out.test.ts +0 -344
- package/src/decorators/__tests__/media-type-examples-override.test.ts +0 -665
- package/src/decorators/__tests__/remove-x-internal.test.ts +0 -416
- package/src/decorators/__tests__/resources/request.yaml +0 -3
- package/src/decorators/__tests__/resources/response.yaml +0 -3
- package/src/decorators/arazzo/index.ts +0 -1
- package/src/decorators/async2/index.ts +0 -1
- package/src/decorators/async3/index.ts +0 -1
- package/src/decorators/common/filters/filter-helper.ts +0 -73
- package/src/decorators/common/filters/filter-in.ts +0 -19
- package/src/decorators/common/filters/filter-out.ts +0 -19
- package/src/decorators/common/info-description-override.ts +0 -25
- package/src/decorators/common/info-override.ts +0 -15
- package/src/decorators/common/media-type-examples-override.ts +0 -80
- package/src/decorators/common/operation-description-override.ts +0 -31
- package/src/decorators/common/registry-dependencies.ts +0 -25
- package/src/decorators/common/remove-x-internal.ts +0 -77
- package/src/decorators/common/tag-description-override.ts +0 -26
- package/src/decorators/oas2/__tests__/remove-unused-components.test.ts +0 -228
- package/src/decorators/oas2/index.ts +0 -21
- package/src/decorators/oas2/remove-unused-components.ts +0 -109
- package/src/decorators/oas3/__tests__/remove-unused-components.test.ts +0 -313
- package/src/decorators/oas3/index.ts +0 -23
- package/src/decorators/oas3/remove-unused-components.ts +0 -138
- package/src/decorators/overlay1/index.ts +0 -1
- package/src/env.ts +0 -5
- package/src/format/codeframes.ts +0 -217
- package/src/format/format.ts +0 -479
- package/src/index.ts +0 -91
- package/src/js-yaml/index.ts +0 -16
- package/src/lint.ts +0 -190
- package/src/logger.ts +0 -36
- package/src/oas-types.ts +0 -178
- package/src/output.ts +0 -7
- package/src/redocly/__tests__/domains.test.ts +0 -52
- package/src/redocly/__tests__/redocly-client.test.ts +0 -156
- package/src/redocly/domains.ts +0 -48
- package/src/redocly/index.ts +0 -177
- package/src/redocly/redocly-client-types.ts +0 -10
- package/src/redocly/registry-api-types.ts +0 -32
- package/src/redocly/registry-api.ts +0 -147
- package/src/ref-utils.ts +0 -91
- package/src/resolve.ts +0 -461
- package/src/rules/__tests__/fixtures/code-sample.php +0 -9
- package/src/rules/__tests__/fixtures/invalid-yaml.yaml +0 -1
- package/src/rules/__tests__/fixtures/ref.yaml +0 -1
- package/src/rules/__tests__/no-unresolved-refs.test.ts +0 -271
- package/src/rules/__tests__/utils.test.ts +0 -160
- package/src/rules/ajv.ts +0 -105
- package/src/rules/arazzo/__tests__/criteria-unique.test.ts +0 -160
- package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +0 -126
- package/src/rules/arazzo/__tests__/parameters-unique.test.ts +0 -113
- package/src/rules/arazzo/__tests__/requestBody-replacements-unique.test.ts +0 -108
- package/src/rules/arazzo/__tests__/respect-supported-versions.test.ts +0 -116
- package/src/rules/arazzo/__tests__/source-description-type.test.ts +0 -78
- package/src/rules/arazzo/__tests__/sourceDescription-name-unique.test.ts +0 -78
- package/src/rules/arazzo/__tests__/sourceDescriptions-not-empty.test.ts +0 -104
- package/src/rules/arazzo/__tests__/step-onFailure-unique.test.ts +0 -110
- package/src/rules/arazzo/__tests__/step-onSuccess-unique.test.ts +0 -110
- package/src/rules/arazzo/__tests__/stepId-unique.test.ts +0 -94
- package/src/rules/arazzo/__tests__/workflow-dependsOn.test.ts +0 -209
- package/src/rules/arazzo/__tests__/workflowId-unique.test.ts +0 -88
- package/src/rules/arazzo/criteria-unique.ts +0 -70
- package/src/rules/arazzo/index.ts +0 -38
- package/src/rules/arazzo/parameters-unique.ts +0 -33
- package/src/rules/arazzo/requestBody-replacements-unique.ts +0 -33
- package/src/rules/arazzo/sourceDescription-type.ts +0 -21
- package/src/rules/arazzo/sourceDescriptions-name-unique.ts +0 -23
- package/src/rules/arazzo/sourceDescriptions-not-empty.ts +0 -17
- package/src/rules/arazzo/step-onFailure-unique.ts +0 -33
- package/src/rules/arazzo/step-onSuccess-unique.ts +0 -33
- package/src/rules/arazzo/stepId-unique.ts +0 -24
- package/src/rules/arazzo/workflow-dependsOn.ts +0 -56
- package/src/rules/arazzo/workflowId-unique.ts +0 -21
- package/src/rules/async2/__tests__/channels-kebab-case.test.ts +0 -145
- package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +0 -97
- package/src/rules/async2/channels-kebab-case.ts +0 -18
- package/src/rules/async2/index.ts +0 -29
- package/src/rules/async2/no-channel-trailing-slash.ts +0 -15
- package/src/rules/async3/__tests__/channels-kebab-case.test.ts +0 -145
- package/src/rules/async3/__tests__/no-channel-trailing-slash.test.ts +0 -96
- package/src/rules/async3/channels-kebab-case.ts +0 -19
- package/src/rules/async3/index.ts +0 -29
- package/src/rules/async3/no-channel-trailing-slash.ts +0 -16
- package/src/rules/common/__tests__/info-license-strict.test.ts +0 -141
- package/src/rules/common/__tests__/info-license.test.ts +0 -62
- package/src/rules/common/__tests__/license-url.test.ts +0 -63
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +0 -96
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +0 -210
- package/src/rules/common/__tests__/no-identical-paths.test.ts +0 -58
- package/src/rules/common/__tests__/no-invalid-parameter-examples.test.ts +0 -53
- package/src/rules/common/__tests__/no-invalid-schema-examples.test.ts +0 -86
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +0 -126
- package/src/rules/common/__tests__/no-required-schema-properties-undefined.test.ts +0 -550
- package/src/rules/common/__tests__/no-schema-type-mismatch.test.ts +0 -126
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +0 -194
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +0 -233
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +0 -76
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +0 -45
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +0 -167
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +0 -72
- package/src/rules/common/__tests__/operation-tag-defined.test.ts +0 -68
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +0 -95
- package/src/rules/common/__tests__/path-not-include-query.test.ts +0 -64
- package/src/rules/common/__tests__/path-params-defined.test.ts +0 -202
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +0 -110
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +0 -264
- package/src/rules/common/__tests__/security-defined.test.ts +0 -284
- package/src/rules/common/__tests__/spec-strict-refs.test.ts +0 -69
- package/src/rules/common/__tests__/struct.test.ts +0 -657
- package/src/rules/common/__tests__/tag-description.test.ts +0 -65
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +0 -124
- package/src/rules/common/assertions/__tests__/asserts.test.ts +0 -877
- package/src/rules/common/assertions/__tests__/index.test.ts +0 -100
- package/src/rules/common/assertions/__tests__/utils.test.ts +0 -236
- package/src/rules/common/assertions/asserts.ts +0 -365
- package/src/rules/common/assertions/index.ts +0 -68
- package/src/rules/common/assertions/utils.ts +0 -333
- package/src/rules/common/info-contact.ts +0 -16
- package/src/rules/common/info-license-strict.ts +0 -24
- package/src/rules/common/info-license-url.ts +0 -11
- package/src/rules/common/info-license.ts +0 -16
- package/src/rules/common/no-ambiguous-paths.ts +0 -50
- package/src/rules/common/no-enum-type-mismatch.ts +0 -53
- package/src/rules/common/no-http-verbs-in-paths.ts +0 -37
- package/src/rules/common/no-identical-paths.ts +0 -24
- package/src/rules/common/no-invalid-parameter-examples.ts +0 -37
- package/src/rules/common/no-invalid-schema-examples.ts +0 -40
- package/src/rules/common/no-path-trailing-slash.ts +0 -15
- package/src/rules/common/no-required-schema-properties-undefined.ts +0 -54
- package/src/rules/common/no-schema-type-mismatch.ts +0 -24
- package/src/rules/common/operation-2xx-response.ts +0 -25
- package/src/rules/common/operation-4xx-response.ts +0 -25
- package/src/rules/common/operation-description.ts +0 -14
- package/src/rules/common/operation-operationId-unique.ts +0 -21
- package/src/rules/common/operation-operationId-url-safe.ts +0 -20
- package/src/rules/common/operation-operationId.ts +0 -18
- package/src/rules/common/operation-parameters-unique.ts +0 -48
- package/src/rules/common/operation-singular-tag.ts +0 -17
- package/src/rules/common/operation-summary.ts +0 -14
- package/src/rules/common/operation-tag-defined.ts +0 -31
- package/src/rules/common/parameter-description.ts +0 -22
- package/src/rules/common/path-declaration-must-exist.ts +0 -15
- package/src/rules/common/path-excludes-patterns.ts +0 -23
- package/src/rules/common/path-http-verbs-order.ts +0 -30
- package/src/rules/common/path-not-include-query.ts +0 -17
- package/src/rules/common/path-params-defined.ts +0 -65
- package/src/rules/common/path-segment-plural.ts +0 -33
- package/src/rules/common/paths-kebab-case.ts +0 -19
- package/src/rules/common/required-string-property-missing-min-length.ts +0 -44
- package/src/rules/common/response-contains-header.ts +0 -36
- package/src/rules/common/scalar-property-missing-example.ts +0 -59
- package/src/rules/common/security-defined.ts +0 -89
- package/src/rules/common/spec-strict-refs.ts +0 -31
- package/src/rules/common/struct.ts +0 -189
- package/src/rules/common/tag-description.ts +0 -11
- package/src/rules/common/tags-alphabetical.ts +0 -27
- package/src/rules/no-unresolved-refs.ts +0 -52
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +0 -112
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +0 -180
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +0 -161
- package/src/rules/oas2/__tests__/spec/fixtures/description.md +0 -1
- package/src/rules/oas2/__tests__/spec/info.test.ts +0 -355
- package/src/rules/oas2/__tests__/spec/operation.test.ts +0 -123
- package/src/rules/oas2/__tests__/spec/paths.test.ts +0 -245
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +0 -37
- package/src/rules/oas2/__tests__/spec/utils.ts +0 -32
- package/src/rules/oas2/boolean-parameter-prefixes.ts +0 -26
- package/src/rules/oas2/index.ts +0 -102
- package/src/rules/oas2/request-mime-type.ts +0 -17
- package/src/rules/oas2/response-contains-property.ts +0 -37
- package/src/rules/oas2/response-mime-type.ts +0 -17
- package/src/rules/oas3/__tests__/array-parameter-serialization.test.ts +0 -275
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +0 -113
- package/src/rules/oas3/__tests__/component-name-unique.test.ts +0 -966
- package/src/rules/oas3/__tests__/fixtures/common.yaml +0 -11
- package/src/rules/oas3/__tests__/fixtures/external-value.yaml +0 -2
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +0 -205
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +0 -65
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +0 -732
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +0 -95
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +0 -79
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +0 -131
- package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +0 -145
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +0 -401
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +0 -417
- package/src/rules/oas3/__tests__/spec/callbacks.test.ts +0 -41
- package/src/rules/oas3/__tests__/spec/fixtures/description.md +0 -1
- package/src/rules/oas3/__tests__/spec/info.test.ts +0 -391
- package/src/rules/oas3/__tests__/spec/operation.test.ts +0 -253
- package/src/rules/oas3/__tests__/spec/paths.test.ts +0 -284
- package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +0 -77
- package/src/rules/oas3/__tests__/spec/servers.test.ts +0 -505
- package/src/rules/oas3/__tests__/spec/spec.test.ts +0 -307
- package/src/rules/oas3/__tests__/spec/utils.ts +0 -32
- package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +0 -282
- package/src/rules/oas3/__tests__/utils/lint-document-for-test.ts +0 -23
- package/src/rules/oas3/array-parameter-serialization.ts +0 -47
- package/src/rules/oas3/boolean-parameter-prefixes.ts +0 -28
- package/src/rules/oas3/component-name-unique.ts +0 -162
- package/src/rules/oas3/index.ts +0 -126
- package/src/rules/oas3/no-empty-servers.ts +0 -22
- package/src/rules/oas3/no-example-value-and-externalValue.ts +0 -14
- package/src/rules/oas3/no-invalid-media-type-examples.ts +0 -54
- package/src/rules/oas3/no-server-example.com.ts +0 -16
- package/src/rules/oas3/no-server-trailing-slash.ts +0 -15
- package/src/rules/oas3/no-server-variables-empty-enum.ts +0 -66
- package/src/rules/oas3/no-undefined-server-variable.ts +0 -30
- package/src/rules/oas3/no-unused-components.ts +0 -75
- package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +0 -36
- package/src/rules/oas3/request-mime-type.ts +0 -31
- package/src/rules/oas3/response-contains-property.ts +0 -39
- package/src/rules/oas3/response-mime-type.ts +0 -31
- package/src/rules/oas3/spec-components-invalid-map-name.ts +0 -69
- package/src/rules/other/stats.ts +0 -75
- package/src/rules/overlay1/__tests__/info-contact.test.ts +0 -112
- package/src/rules/overlay1/index.ts +0 -14
- package/src/rules/respect/no-criteria-xpath.ts +0 -20
- package/src/rules/respect/respect-supported-versions.ts +0 -24
- package/src/rules/utils.ts +0 -230
- package/src/types/arazzo.ts +0 -305
- package/src/types/asyncapi2.ts +0 -1121
- package/src/types/asyncapi3.ts +0 -383
- package/src/types/index.ts +0 -144
- package/src/types/json-schema-adapter.ts +0 -217
- package/src/types/oas2.ts +0 -481
- package/src/types/oas3.ts +0 -594
- package/src/types/oas3_1.ts +0 -290
- package/src/types/overlay.ts +0 -40
- package/src/types/redocly-yaml.ts +0 -1226
- package/src/typings/arazzo.ts +0 -172
- package/src/typings/asyncapi.ts +0 -26
- package/src/typings/asyncapi3.ts +0 -61
- package/src/typings/common.ts +0 -18
- package/src/typings/openapi.ts +0 -347
- package/src/typings/overlay.ts +0 -19
- package/src/typings/swagger.ts +0 -236
- package/src/utils.ts +0 -357
- package/src/visitors.ts +0 -598
- package/src/walk.ts +0 -467
- package/tsconfig.json +0 -8
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,1596 +0,0 @@
|
|
|
1
|
-
import outdent from 'outdent';
|
|
2
|
-
import each from 'jest-each';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
|
|
5
|
-
import { lintDocument } from '../lint';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
parseYamlToDocument,
|
|
9
|
-
replaceSourceWithRef,
|
|
10
|
-
makeConfigForRuleset,
|
|
11
|
-
} from '../../__tests__/utils';
|
|
12
|
-
import { BaseResolver, Document } from '../resolve';
|
|
13
|
-
import { listOf } from '../types';
|
|
14
|
-
import { Oas3RuleSet } from '../oas-types';
|
|
15
|
-
import { createConfig } from '../config';
|
|
16
|
-
|
|
17
|
-
describe('walk order', () => {
|
|
18
|
-
it('should run visitors', async () => {
|
|
19
|
-
const visitors = {
|
|
20
|
-
Root: {
|
|
21
|
-
enter: jest.fn(),
|
|
22
|
-
leave: jest.fn(),
|
|
23
|
-
},
|
|
24
|
-
Info: {
|
|
25
|
-
enter: jest.fn(),
|
|
26
|
-
leave: jest.fn(),
|
|
27
|
-
},
|
|
28
|
-
Contact: {
|
|
29
|
-
enter: jest.fn(),
|
|
30
|
-
leave: jest.fn(),
|
|
31
|
-
},
|
|
32
|
-
License: {
|
|
33
|
-
enter: jest.fn(),
|
|
34
|
-
leave: jest.fn(),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const testRuleSet: Oas3RuleSet = {
|
|
39
|
-
test: jest.fn(() => {
|
|
40
|
-
return visitors;
|
|
41
|
-
}),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const document = parseYamlToDocument(
|
|
45
|
-
outdent`
|
|
46
|
-
openapi: 3.0.0
|
|
47
|
-
info:
|
|
48
|
-
contact: {}
|
|
49
|
-
license: {}
|
|
50
|
-
`,
|
|
51
|
-
''
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
await lintDocument({
|
|
55
|
-
externalRefResolver: new BaseResolver(),
|
|
56
|
-
document,
|
|
57
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(testRuleSet.test).toBeCalledTimes(1);
|
|
61
|
-
for (const fns of Object.values(visitors)) {
|
|
62
|
-
expect(fns.enter).toBeCalled();
|
|
63
|
-
expect(fns.leave).toBeCalled();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should run legacy visitors', async () => {
|
|
68
|
-
const visitors = {
|
|
69
|
-
DefinitionRoot: {
|
|
70
|
-
enter: jest.fn(),
|
|
71
|
-
leave: jest.fn(),
|
|
72
|
-
},
|
|
73
|
-
PathMap: {
|
|
74
|
-
enter: jest.fn(),
|
|
75
|
-
leave: jest.fn(),
|
|
76
|
-
},
|
|
77
|
-
ServerVariableMap: {
|
|
78
|
-
enter: jest.fn(),
|
|
79
|
-
leave: jest.fn(),
|
|
80
|
-
},
|
|
81
|
-
MediaTypeMap: {
|
|
82
|
-
enter: jest.fn(),
|
|
83
|
-
leave: jest.fn(),
|
|
84
|
-
},
|
|
85
|
-
ExampleMap: {
|
|
86
|
-
enter: jest.fn(),
|
|
87
|
-
leave: jest.fn(),
|
|
88
|
-
},
|
|
89
|
-
HeaderMap: {
|
|
90
|
-
enter: jest.fn(),
|
|
91
|
-
leave: jest.fn(),
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const testRuleSet: Oas3RuleSet = {
|
|
96
|
-
test: jest.fn(() => {
|
|
97
|
-
return visitors;
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const document = parseYamlToDocument(
|
|
102
|
-
outdent`
|
|
103
|
-
openapi: 3.0.0
|
|
104
|
-
servers:
|
|
105
|
-
- url: http://{test}.url
|
|
106
|
-
variables:
|
|
107
|
-
test: test
|
|
108
|
-
paths:
|
|
109
|
-
/test-path:
|
|
110
|
-
get:
|
|
111
|
-
responses:
|
|
112
|
-
200:
|
|
113
|
-
headers: {}
|
|
114
|
-
content:
|
|
115
|
-
application/json:
|
|
116
|
-
schema: {}
|
|
117
|
-
examples: {}
|
|
118
|
-
`,
|
|
119
|
-
''
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
await lintDocument({
|
|
123
|
-
externalRefResolver: new BaseResolver(),
|
|
124
|
-
document,
|
|
125
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
expect(testRuleSet.test).toBeCalledTimes(1);
|
|
129
|
-
for (const fns of Object.values(visitors)) {
|
|
130
|
-
expect(fns.enter).toBeCalled();
|
|
131
|
-
expect(fns.leave).toBeCalled();
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('should run nested visitors correctly', async () => {
|
|
136
|
-
const calls: string[] = [];
|
|
137
|
-
|
|
138
|
-
const testRuleSet: Oas3RuleSet = {
|
|
139
|
-
test: jest.fn(() => {
|
|
140
|
-
return {
|
|
141
|
-
Operation: {
|
|
142
|
-
enter: jest.fn((op) => calls.push(`enter operation: ${op.operationId}`)),
|
|
143
|
-
leave: jest.fn((op) => calls.push(`leave operation: ${op.operationId}`)),
|
|
144
|
-
Parameter: {
|
|
145
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
146
|
-
calls.push(`enter operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
147
|
-
),
|
|
148
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
149
|
-
calls.push(`leave operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
150
|
-
),
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
Parameter: {
|
|
154
|
-
enter: jest.fn((param) => calls.push(`enter param ${param.name}`)),
|
|
155
|
-
leave: jest.fn((param) => calls.push(`leave param ${param.name}`)),
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}),
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const document = parseYamlToDocument(
|
|
162
|
-
outdent`
|
|
163
|
-
openapi: 3.0.0
|
|
164
|
-
info:
|
|
165
|
-
contact: {}
|
|
166
|
-
license: {}
|
|
167
|
-
paths:
|
|
168
|
-
/pet:
|
|
169
|
-
parameters:
|
|
170
|
-
- name: path-param
|
|
171
|
-
get:
|
|
172
|
-
operationId: get
|
|
173
|
-
parameters:
|
|
174
|
-
- name: get_a
|
|
175
|
-
- name: get_b
|
|
176
|
-
post:
|
|
177
|
-
operationId: post
|
|
178
|
-
parameters:
|
|
179
|
-
- name: post_a
|
|
180
|
-
|
|
181
|
-
`,
|
|
182
|
-
''
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
await lintDocument({
|
|
186
|
-
externalRefResolver: new BaseResolver(),
|
|
187
|
-
document,
|
|
188
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
192
|
-
[
|
|
193
|
-
"enter param path-param",
|
|
194
|
-
"leave param path-param",
|
|
195
|
-
"enter operation: get",
|
|
196
|
-
"enter operation get > param get_a",
|
|
197
|
-
"enter param get_a",
|
|
198
|
-
"leave param get_a",
|
|
199
|
-
"leave operation get > param get_a",
|
|
200
|
-
"enter operation get > param get_b",
|
|
201
|
-
"enter param get_b",
|
|
202
|
-
"leave param get_b",
|
|
203
|
-
"leave operation get > param get_b",
|
|
204
|
-
"leave operation: get",
|
|
205
|
-
"enter operation: post",
|
|
206
|
-
"enter operation post > param post_a",
|
|
207
|
-
"enter param post_a",
|
|
208
|
-
"leave param post_a",
|
|
209
|
-
"leave operation post > param post_a",
|
|
210
|
-
"leave operation: post",
|
|
211
|
-
]
|
|
212
|
-
`);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('should run nested visitors correctly oas2', async () => {
|
|
216
|
-
const calls: string[] = [];
|
|
217
|
-
|
|
218
|
-
const testRuleSet: Oas3RuleSet = {
|
|
219
|
-
test: jest.fn(() => {
|
|
220
|
-
return {
|
|
221
|
-
Operation: {
|
|
222
|
-
enter: jest.fn((op) => calls.push(`enter operation: ${op.operationId}`)),
|
|
223
|
-
leave: jest.fn((op) => calls.push(`leave operation: ${op.operationId}`)),
|
|
224
|
-
Parameter: {
|
|
225
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
226
|
-
calls.push(`enter operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
227
|
-
),
|
|
228
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
229
|
-
calls.push(`leave operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
230
|
-
),
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
Parameter: {
|
|
234
|
-
enter: jest.fn((param) => calls.push(`enter param ${param.name}`)),
|
|
235
|
-
leave: jest.fn((param) => calls.push(`leave param ${param.name}`)),
|
|
236
|
-
},
|
|
237
|
-
};
|
|
238
|
-
}),
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const document = parseYamlToDocument(
|
|
242
|
-
outdent`
|
|
243
|
-
swagger: "2.0"
|
|
244
|
-
info:
|
|
245
|
-
contact: {}
|
|
246
|
-
license: {}
|
|
247
|
-
paths:
|
|
248
|
-
/pet:
|
|
249
|
-
parameters:
|
|
250
|
-
- name: path-param
|
|
251
|
-
get:
|
|
252
|
-
operationId: get
|
|
253
|
-
parameters:
|
|
254
|
-
- name: get_a
|
|
255
|
-
- name: get_b
|
|
256
|
-
post:
|
|
257
|
-
operationId: post
|
|
258
|
-
parameters:
|
|
259
|
-
- name: post_a
|
|
260
|
-
|
|
261
|
-
`,
|
|
262
|
-
''
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
await lintDocument({
|
|
266
|
-
externalRefResolver: new BaseResolver(),
|
|
267
|
-
document,
|
|
268
|
-
config: await makeConfigForRuleset(testRuleSet, undefined, 'oas2'),
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
272
|
-
[
|
|
273
|
-
"enter param path-param",
|
|
274
|
-
"leave param path-param",
|
|
275
|
-
"enter operation: get",
|
|
276
|
-
"enter operation get > param get_a",
|
|
277
|
-
"enter param get_a",
|
|
278
|
-
"leave param get_a",
|
|
279
|
-
"leave operation get > param get_a",
|
|
280
|
-
"enter operation get > param get_b",
|
|
281
|
-
"enter param get_b",
|
|
282
|
-
"leave param get_b",
|
|
283
|
-
"leave operation get > param get_b",
|
|
284
|
-
"leave operation: get",
|
|
285
|
-
"enter operation: post",
|
|
286
|
-
"enter operation post > param post_a",
|
|
287
|
-
"enter param post_a",
|
|
288
|
-
"leave param post_a",
|
|
289
|
-
"leave operation post > param post_a",
|
|
290
|
-
"leave operation: post",
|
|
291
|
-
]
|
|
292
|
-
`);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('should resolve refs', async () => {
|
|
296
|
-
const calls: string[] = [];
|
|
297
|
-
|
|
298
|
-
const testRuleSet: Oas3RuleSet = {
|
|
299
|
-
test: jest.fn(() => {
|
|
300
|
-
return {
|
|
301
|
-
Operation: {
|
|
302
|
-
enter: jest.fn((op) => calls.push(`enter operation: ${op.operationId}`)),
|
|
303
|
-
leave: jest.fn((op) => calls.push(`leave operation: ${op.operationId}`)),
|
|
304
|
-
Parameter: {
|
|
305
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
306
|
-
calls.push(`enter operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
307
|
-
),
|
|
308
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
309
|
-
calls.push(`leave operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
310
|
-
),
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
Parameter: {
|
|
314
|
-
enter: jest.fn((param) => calls.push(`enter param ${param.name}`)),
|
|
315
|
-
leave: jest.fn((param) => calls.push(`leave param ${param.name}`)),
|
|
316
|
-
},
|
|
317
|
-
};
|
|
318
|
-
}),
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const document = parseYamlToDocument(
|
|
322
|
-
outdent`
|
|
323
|
-
openapi: 3.0.0
|
|
324
|
-
info:
|
|
325
|
-
contact: {}
|
|
326
|
-
license: {}
|
|
327
|
-
paths:
|
|
328
|
-
/pet:
|
|
329
|
-
get:
|
|
330
|
-
operationId: get
|
|
331
|
-
parameters:
|
|
332
|
-
- $ref: '#/components/parameters/shared_a'
|
|
333
|
-
- name: get_b
|
|
334
|
-
post:
|
|
335
|
-
operationId: post
|
|
336
|
-
parameters:
|
|
337
|
-
- $ref: '#/components/parameters/shared_a'
|
|
338
|
-
components:
|
|
339
|
-
parameters:
|
|
340
|
-
shared_a:
|
|
341
|
-
name: shared-a
|
|
342
|
-
`,
|
|
343
|
-
''
|
|
344
|
-
);
|
|
345
|
-
|
|
346
|
-
await lintDocument({
|
|
347
|
-
externalRefResolver: new BaseResolver(),
|
|
348
|
-
document,
|
|
349
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
353
|
-
[
|
|
354
|
-
"enter operation: get",
|
|
355
|
-
"enter operation get > param shared-a",
|
|
356
|
-
"enter param shared-a",
|
|
357
|
-
"leave param shared-a",
|
|
358
|
-
"leave operation get > param shared-a",
|
|
359
|
-
"enter operation get > param get_b",
|
|
360
|
-
"enter param get_b",
|
|
361
|
-
"leave param get_b",
|
|
362
|
-
"leave operation get > param get_b",
|
|
363
|
-
"leave operation: get",
|
|
364
|
-
"enter operation: post",
|
|
365
|
-
"enter operation post > param shared-a",
|
|
366
|
-
"leave operation post > param shared-a",
|
|
367
|
-
"leave operation: post",
|
|
368
|
-
]
|
|
369
|
-
`);
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it('should visit with context same refs with gaps in visitor simple', async () => {
|
|
373
|
-
const calls: string[] = [];
|
|
374
|
-
|
|
375
|
-
const testRuleSet: Oas3RuleSet = {
|
|
376
|
-
test: jest.fn(() => {
|
|
377
|
-
return {
|
|
378
|
-
PathItem: {
|
|
379
|
-
Parameter: {
|
|
380
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
381
|
-
calls.push(`enter path ${parents.PathItem.id} > param ${param.name}`)
|
|
382
|
-
),
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
|
-
}),
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
const document = parseYamlToDocument(
|
|
390
|
-
outdent`
|
|
391
|
-
openapi: 3.0.0
|
|
392
|
-
paths:
|
|
393
|
-
/pet:
|
|
394
|
-
id: pet
|
|
395
|
-
parameters:
|
|
396
|
-
$ref: '#/components/fake_parameters_list'
|
|
397
|
-
get:
|
|
398
|
-
operationId: get
|
|
399
|
-
parameters:
|
|
400
|
-
- $ref: '#/components/parameters/shared_a'
|
|
401
|
-
- name: get_b
|
|
402
|
-
/dog:
|
|
403
|
-
id: dog
|
|
404
|
-
post:
|
|
405
|
-
operationId: post
|
|
406
|
-
parameters:
|
|
407
|
-
- $ref: '#/components/parameters/shared_a'
|
|
408
|
-
components:
|
|
409
|
-
fake_parameters_list:
|
|
410
|
-
- name: path-param
|
|
411
|
-
parameters:
|
|
412
|
-
shared_a:
|
|
413
|
-
name: shared-a
|
|
414
|
-
`,
|
|
415
|
-
''
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
await lintDocument({
|
|
419
|
-
externalRefResolver: new BaseResolver(),
|
|
420
|
-
document,
|
|
421
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
425
|
-
[
|
|
426
|
-
"enter path pet > param path-param",
|
|
427
|
-
"enter path pet > param shared-a",
|
|
428
|
-
"enter path pet > param get_b",
|
|
429
|
-
"enter path dog > param shared-a",
|
|
430
|
-
]
|
|
431
|
-
`);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('should correctly visit more specific visitor', async () => {
|
|
435
|
-
const calls: string[] = [];
|
|
436
|
-
|
|
437
|
-
const testRuleSet: Oas3RuleSet = {
|
|
438
|
-
test: jest.fn(() => {
|
|
439
|
-
return {
|
|
440
|
-
PathItem: {
|
|
441
|
-
Parameter: {
|
|
442
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
443
|
-
calls.push(`enter path ${parents.PathItem.id} > param ${param.name}`)
|
|
444
|
-
),
|
|
445
|
-
},
|
|
446
|
-
Operation: {
|
|
447
|
-
Parameter: {
|
|
448
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
449
|
-
calls.push(
|
|
450
|
-
`enter operation ${parents.Operation.operationId} > param ${param.name}`
|
|
451
|
-
)
|
|
452
|
-
),
|
|
453
|
-
},
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
};
|
|
457
|
-
}),
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
const document = parseYamlToDocument(
|
|
461
|
-
outdent`
|
|
462
|
-
openapi: 3.0.0
|
|
463
|
-
paths:
|
|
464
|
-
/pet:
|
|
465
|
-
id: pet
|
|
466
|
-
parameters:
|
|
467
|
-
- name: path-param
|
|
468
|
-
get:
|
|
469
|
-
operationId: get
|
|
470
|
-
parameters:
|
|
471
|
-
- $ref: '#/components/parameters/shared_a'
|
|
472
|
-
- name: get_b
|
|
473
|
-
- name: get_c
|
|
474
|
-
/dog:
|
|
475
|
-
id: dog
|
|
476
|
-
post:
|
|
477
|
-
operationId: post
|
|
478
|
-
parameters:
|
|
479
|
-
- $ref: '#/components/parameters/shared_b'
|
|
480
|
-
components:
|
|
481
|
-
parameters:
|
|
482
|
-
shared_a:
|
|
483
|
-
name: shared-a
|
|
484
|
-
shared_b:
|
|
485
|
-
name: shared-b
|
|
486
|
-
`,
|
|
487
|
-
''
|
|
488
|
-
);
|
|
489
|
-
|
|
490
|
-
await lintDocument({
|
|
491
|
-
externalRefResolver: new BaseResolver(),
|
|
492
|
-
document,
|
|
493
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
497
|
-
[
|
|
498
|
-
"enter path pet > param path-param",
|
|
499
|
-
"enter operation get > param shared-a",
|
|
500
|
-
"enter operation get > param get_b",
|
|
501
|
-
"enter operation get > param get_c",
|
|
502
|
-
"enter operation post > param shared-b",
|
|
503
|
-
]
|
|
504
|
-
`);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
it('should visit with context same refs with gaps in visitor and nested rule', async () => {
|
|
508
|
-
const calls: string[] = [];
|
|
509
|
-
|
|
510
|
-
const testRuleSet: Oas3RuleSet = {
|
|
511
|
-
test: jest.fn(() => {
|
|
512
|
-
return {
|
|
513
|
-
PathItem: {
|
|
514
|
-
Parameter: {
|
|
515
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
516
|
-
calls.push(`enter path ${parents.PathItem.id} > param ${param.name}`)
|
|
517
|
-
),
|
|
518
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
519
|
-
calls.push(`leave path ${parents.PathItem.id} > param ${param.name}`)
|
|
520
|
-
),
|
|
521
|
-
},
|
|
522
|
-
Operation(op, _ctx, parents) {
|
|
523
|
-
calls.push(`enter path ${parents.PathItem.id} > op ${op.operationId}`);
|
|
524
|
-
},
|
|
525
|
-
},
|
|
526
|
-
};
|
|
527
|
-
}),
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const document = parseYamlToDocument(
|
|
531
|
-
outdent`
|
|
532
|
-
openapi: 3.0.0
|
|
533
|
-
paths:
|
|
534
|
-
/pet:
|
|
535
|
-
id: pet
|
|
536
|
-
parameters:
|
|
537
|
-
- name: path-param
|
|
538
|
-
get:
|
|
539
|
-
operationId: get
|
|
540
|
-
parameters:
|
|
541
|
-
- $ref: '#/components/parameters/shared_a'
|
|
542
|
-
- name: get_b
|
|
543
|
-
/dog:
|
|
544
|
-
id: dog
|
|
545
|
-
post:
|
|
546
|
-
operationId: post
|
|
547
|
-
parameters:
|
|
548
|
-
- $ref: '#/components/parameters/shared_a'
|
|
549
|
-
components:
|
|
550
|
-
parameters:
|
|
551
|
-
shared_a:
|
|
552
|
-
name: shared-a
|
|
553
|
-
`,
|
|
554
|
-
''
|
|
555
|
-
);
|
|
556
|
-
|
|
557
|
-
await lintDocument({
|
|
558
|
-
externalRefResolver: new BaseResolver(),
|
|
559
|
-
document,
|
|
560
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
561
|
-
});
|
|
562
|
-
|
|
563
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
564
|
-
[
|
|
565
|
-
"enter path pet > param path-param",
|
|
566
|
-
"leave path pet > param path-param",
|
|
567
|
-
"enter path pet > op get",
|
|
568
|
-
"enter path pet > param shared-a",
|
|
569
|
-
"leave path pet > param shared-a",
|
|
570
|
-
"enter path pet > param get_b",
|
|
571
|
-
"leave path pet > param get_b",
|
|
572
|
-
"enter path dog > op post",
|
|
573
|
-
"enter path dog > param shared-a",
|
|
574
|
-
"leave path dog > param shared-a",
|
|
575
|
-
]
|
|
576
|
-
`);
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
it('should visit and do not recurse for circular refs top-level', async () => {
|
|
580
|
-
const calls: string[] = [];
|
|
581
|
-
|
|
582
|
-
const testRuleSet: Oas3RuleSet = {
|
|
583
|
-
test: jest.fn(() => {
|
|
584
|
-
return {
|
|
585
|
-
Schema: jest.fn((schema: any) => calls.push(`enter schema ${schema.id}`)),
|
|
586
|
-
};
|
|
587
|
-
}),
|
|
588
|
-
};
|
|
589
|
-
|
|
590
|
-
const document = parseYamlToDocument(
|
|
591
|
-
outdent`
|
|
592
|
-
openapi: 3.0.0
|
|
593
|
-
paths:
|
|
594
|
-
/pet:
|
|
595
|
-
id: pet
|
|
596
|
-
parameters:
|
|
597
|
-
- name: path-param
|
|
598
|
-
schema:
|
|
599
|
-
$ref: "#/components/parameters/shared_a"
|
|
600
|
-
components:
|
|
601
|
-
parameters:
|
|
602
|
-
shared_a:
|
|
603
|
-
id: 'shared_a'
|
|
604
|
-
allOf:
|
|
605
|
-
- $ref: "#/components/parameters/shared_a"
|
|
606
|
-
- id: 'nested'
|
|
607
|
-
`,
|
|
608
|
-
''
|
|
609
|
-
);
|
|
610
|
-
|
|
611
|
-
await lintDocument({
|
|
612
|
-
externalRefResolver: new BaseResolver(),
|
|
613
|
-
document,
|
|
614
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
618
|
-
[
|
|
619
|
-
"enter schema shared_a",
|
|
620
|
-
"enter schema nested",
|
|
621
|
-
]
|
|
622
|
-
`);
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
it('should visit and do not recurse for circular refs with context', async () => {
|
|
626
|
-
const calls: string[] = [];
|
|
627
|
-
|
|
628
|
-
const testRuleSet: Oas3RuleSet = {
|
|
629
|
-
test: jest.fn(() => {
|
|
630
|
-
return {
|
|
631
|
-
Parameter: {
|
|
632
|
-
Schema: jest.fn((schema: any, _ctx, parents) =>
|
|
633
|
-
calls.push(`enter param ${parents.Parameter.name} > schema ${schema.id}`)
|
|
634
|
-
),
|
|
635
|
-
},
|
|
636
|
-
};
|
|
637
|
-
}),
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
const document = parseYamlToDocument(
|
|
641
|
-
outdent`
|
|
642
|
-
openapi: 3.0.0
|
|
643
|
-
paths:
|
|
644
|
-
/pet:
|
|
645
|
-
id: pet
|
|
646
|
-
parameters:
|
|
647
|
-
- name: a
|
|
648
|
-
schema:
|
|
649
|
-
$ref: "#/components/parameters/shared_a"
|
|
650
|
-
- name: b
|
|
651
|
-
schema:
|
|
652
|
-
$ref: "#/components/parameters/shared_a"
|
|
653
|
-
components:
|
|
654
|
-
parameters:
|
|
655
|
-
shared_a:
|
|
656
|
-
id: 'shared_a'
|
|
657
|
-
properties:
|
|
658
|
-
a:
|
|
659
|
-
id: a
|
|
660
|
-
allOf:
|
|
661
|
-
- $ref: "#/components/parameters/shared_a"
|
|
662
|
-
- id: 'nested'
|
|
663
|
-
`,
|
|
664
|
-
''
|
|
665
|
-
);
|
|
666
|
-
|
|
667
|
-
await lintDocument({
|
|
668
|
-
externalRefResolver: new BaseResolver(),
|
|
669
|
-
document,
|
|
670
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
674
|
-
[
|
|
675
|
-
"enter param a > schema shared_a",
|
|
676
|
-
"enter param b > schema shared_a",
|
|
677
|
-
]
|
|
678
|
-
`);
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
it('should correctly skip top level', async () => {
|
|
682
|
-
const calls: string[] = [];
|
|
683
|
-
|
|
684
|
-
const testRuleSet: Oas3RuleSet = {
|
|
685
|
-
test: jest.fn(() => {
|
|
686
|
-
return {
|
|
687
|
-
Operation: {
|
|
688
|
-
skip: (op) => op.operationId === 'put',
|
|
689
|
-
enter: jest.fn((op) => calls.push(`enter operation ${op.operationId}`)),
|
|
690
|
-
leave: jest.fn((op) => calls.push(`leave operation ${op.operationId}`)),
|
|
691
|
-
},
|
|
692
|
-
};
|
|
693
|
-
}),
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
const document = parseYamlToDocument(
|
|
697
|
-
outdent`
|
|
698
|
-
openapi: 3.0.0
|
|
699
|
-
paths:
|
|
700
|
-
/pet:
|
|
701
|
-
get:
|
|
702
|
-
operationId: get
|
|
703
|
-
put:
|
|
704
|
-
operationId: put
|
|
705
|
-
`,
|
|
706
|
-
''
|
|
707
|
-
);
|
|
708
|
-
|
|
709
|
-
await lintDocument({
|
|
710
|
-
externalRefResolver: new BaseResolver(),
|
|
711
|
-
document,
|
|
712
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
716
|
-
[
|
|
717
|
-
"enter operation get",
|
|
718
|
-
"leave operation get",
|
|
719
|
-
]
|
|
720
|
-
`);
|
|
721
|
-
});
|
|
722
|
-
|
|
723
|
-
it('should correctly skip nested levels', async () => {
|
|
724
|
-
const calls: string[] = [];
|
|
725
|
-
|
|
726
|
-
const testRuleSet: Oas3RuleSet = {
|
|
727
|
-
test: jest.fn(() => {
|
|
728
|
-
return {
|
|
729
|
-
Operation: {
|
|
730
|
-
skip: (op) => op.operationId === 'put',
|
|
731
|
-
Parameter: jest.fn((param, _ctx, parents) =>
|
|
732
|
-
calls.push(`enter operation ${parents.Operation.operationId} > param ${param.name}`)
|
|
733
|
-
),
|
|
734
|
-
},
|
|
735
|
-
};
|
|
736
|
-
}),
|
|
737
|
-
};
|
|
738
|
-
|
|
739
|
-
const document = parseYamlToDocument(
|
|
740
|
-
outdent`
|
|
741
|
-
openapi: 3.0.0
|
|
742
|
-
paths:
|
|
743
|
-
/pet:
|
|
744
|
-
get:
|
|
745
|
-
operationId: get
|
|
746
|
-
parameters:
|
|
747
|
-
- $ref: '#/components/parameters/shared_a'
|
|
748
|
-
- name: get_b
|
|
749
|
-
- name: get_c
|
|
750
|
-
put:
|
|
751
|
-
operationId: put
|
|
752
|
-
parameters:
|
|
753
|
-
- $ref: '#/components/parameters/shared_a'
|
|
754
|
-
- name: get_b
|
|
755
|
-
- name: get_c
|
|
756
|
-
components:
|
|
757
|
-
parameters:
|
|
758
|
-
shared_a:
|
|
759
|
-
name: shared-a
|
|
760
|
-
`,
|
|
761
|
-
''
|
|
762
|
-
);
|
|
763
|
-
|
|
764
|
-
await lintDocument({
|
|
765
|
-
externalRefResolver: new BaseResolver(),
|
|
766
|
-
document,
|
|
767
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
771
|
-
[
|
|
772
|
-
"enter operation get > param shared-a",
|
|
773
|
-
"enter operation get > param get_b",
|
|
774
|
-
"enter operation get > param get_c",
|
|
775
|
-
]
|
|
776
|
-
`);
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
it('should correctly visit more specific visitor with skips', async () => {
|
|
780
|
-
const calls: string[] = [];
|
|
781
|
-
|
|
782
|
-
const testRuleSet: Oas3RuleSet = {
|
|
783
|
-
test: jest.fn(() => {
|
|
784
|
-
return {
|
|
785
|
-
PathItem: {
|
|
786
|
-
Parameter: {
|
|
787
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
788
|
-
calls.push(`enter path ${parents.PathItem.id} > param ${param.name}`)
|
|
789
|
-
),
|
|
790
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
791
|
-
calls.push(`leave path ${parents.PathItem.id} > param ${param.name}`)
|
|
792
|
-
),
|
|
793
|
-
},
|
|
794
|
-
Operation: {
|
|
795
|
-
skip: (op) => op.operationId === 'put',
|
|
796
|
-
Parameter: {
|
|
797
|
-
enter: jest.fn((param, _ctx, parents) =>
|
|
798
|
-
calls.push(
|
|
799
|
-
`enter operation ${parents.Operation.operationId} > param ${param.name}`
|
|
800
|
-
)
|
|
801
|
-
),
|
|
802
|
-
leave: jest.fn((param, _ctx, parents) =>
|
|
803
|
-
calls.push(
|
|
804
|
-
`leave operation ${parents.Operation.operationId} > param ${param.name}`
|
|
805
|
-
)
|
|
806
|
-
),
|
|
807
|
-
},
|
|
808
|
-
},
|
|
809
|
-
},
|
|
810
|
-
};
|
|
811
|
-
}),
|
|
812
|
-
};
|
|
813
|
-
|
|
814
|
-
const document = parseYamlToDocument(
|
|
815
|
-
outdent`
|
|
816
|
-
openapi: 3.0.0
|
|
817
|
-
paths:
|
|
818
|
-
/pet:
|
|
819
|
-
id: pet
|
|
820
|
-
parameters:
|
|
821
|
-
- name: path-param
|
|
822
|
-
get:
|
|
823
|
-
operationId: get
|
|
824
|
-
parameters:
|
|
825
|
-
- $ref: '#/components/parameters/shared_a'
|
|
826
|
-
- name: get_b
|
|
827
|
-
- name: get_c
|
|
828
|
-
put:
|
|
829
|
-
operationId: put
|
|
830
|
-
parameters:
|
|
831
|
-
- $ref: '#/components/parameters/shared_a'
|
|
832
|
-
- name: get_b
|
|
833
|
-
- name: get_c
|
|
834
|
-
/dog:
|
|
835
|
-
id: dog
|
|
836
|
-
post:
|
|
837
|
-
operationId: post
|
|
838
|
-
parameters:
|
|
839
|
-
- $ref: '#/components/parameters/shared_b'
|
|
840
|
-
components:
|
|
841
|
-
parameters:
|
|
842
|
-
shared_a:
|
|
843
|
-
name: shared-a
|
|
844
|
-
shared_b:
|
|
845
|
-
name: shared-b
|
|
846
|
-
`,
|
|
847
|
-
''
|
|
848
|
-
);
|
|
849
|
-
|
|
850
|
-
await lintDocument({
|
|
851
|
-
externalRefResolver: new BaseResolver(),
|
|
852
|
-
document,
|
|
853
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
854
|
-
});
|
|
855
|
-
|
|
856
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
857
|
-
[
|
|
858
|
-
"enter path pet > param path-param",
|
|
859
|
-
"leave path pet > param path-param",
|
|
860
|
-
"enter operation get > param shared-a",
|
|
861
|
-
"leave operation get > param shared-a",
|
|
862
|
-
"enter operation get > param get_b",
|
|
863
|
-
"leave operation get > param get_b",
|
|
864
|
-
"enter operation get > param get_c",
|
|
865
|
-
"leave operation get > param get_c",
|
|
866
|
-
"enter operation post > param shared-b",
|
|
867
|
-
"leave operation post > param shared-b",
|
|
868
|
-
]
|
|
869
|
-
`);
|
|
870
|
-
});
|
|
871
|
-
|
|
872
|
-
it('should correctly visit with nested rules', async () => {
|
|
873
|
-
const calls: string[] = [];
|
|
874
|
-
|
|
875
|
-
const testRuleSet: Oas3RuleSet = {
|
|
876
|
-
test: jest.fn(() => {
|
|
877
|
-
return {
|
|
878
|
-
Schema: {
|
|
879
|
-
Schema: {
|
|
880
|
-
enter: jest.fn((schema: any, _ctx, parents) =>
|
|
881
|
-
calls.push(`enter nested schema ${parents.Schema.id} > ${schema.id}`)
|
|
882
|
-
),
|
|
883
|
-
leave: jest.fn((schema: any, _ctx, parents) =>
|
|
884
|
-
calls.push(`leave nested schema ${parents.Schema.id} > ${schema.id}`)
|
|
885
|
-
),
|
|
886
|
-
},
|
|
887
|
-
},
|
|
888
|
-
};
|
|
889
|
-
}),
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
const document = parseYamlToDocument(
|
|
893
|
-
outdent`
|
|
894
|
-
openapi: 3.0.0
|
|
895
|
-
paths:
|
|
896
|
-
/pet:
|
|
897
|
-
get:
|
|
898
|
-
requestBody:
|
|
899
|
-
content:
|
|
900
|
-
application/json:
|
|
901
|
-
schema:
|
|
902
|
-
id: inline-top
|
|
903
|
-
type: object
|
|
904
|
-
properties:
|
|
905
|
-
b:
|
|
906
|
-
$ref: "#/components/schemas/b"
|
|
907
|
-
a:
|
|
908
|
-
type: object
|
|
909
|
-
id: inline-nested-2
|
|
910
|
-
properties:
|
|
911
|
-
a:
|
|
912
|
-
id: inline-nested-nested-2
|
|
913
|
-
components:
|
|
914
|
-
schemas:
|
|
915
|
-
b:
|
|
916
|
-
id: inline-top
|
|
917
|
-
type: object
|
|
918
|
-
properties:
|
|
919
|
-
a:
|
|
920
|
-
type: object
|
|
921
|
-
id: inline-nested
|
|
922
|
-
properties:
|
|
923
|
-
a:
|
|
924
|
-
id: inline-nested-nested
|
|
925
|
-
`,
|
|
926
|
-
'foobar.yaml'
|
|
927
|
-
);
|
|
928
|
-
|
|
929
|
-
await lintDocument({
|
|
930
|
-
externalRefResolver: new BaseResolver(),
|
|
931
|
-
document,
|
|
932
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
936
|
-
[
|
|
937
|
-
"enter nested schema inline-top > inline-top",
|
|
938
|
-
"enter nested schema inline-top > inline-nested",
|
|
939
|
-
"enter nested schema inline-nested > inline-nested-nested",
|
|
940
|
-
"leave nested schema inline-nested > inline-nested-nested",
|
|
941
|
-
"leave nested schema inline-top > inline-nested",
|
|
942
|
-
"leave nested schema inline-top > inline-top",
|
|
943
|
-
"enter nested schema inline-top > inline-nested-2",
|
|
944
|
-
"enter nested schema inline-nested-2 > inline-nested-nested-2",
|
|
945
|
-
"leave nested schema inline-nested-2 > inline-nested-nested-2",
|
|
946
|
-
"leave nested schema inline-top > inline-nested-2",
|
|
947
|
-
]
|
|
948
|
-
`);
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
it('should correctly visit refs', async () => {
|
|
952
|
-
const calls: string[] = [];
|
|
953
|
-
|
|
954
|
-
const testRuleSet: Oas3RuleSet = {
|
|
955
|
-
test: jest.fn(() => {
|
|
956
|
-
return {
|
|
957
|
-
ref(node, _, { node: target }) {
|
|
958
|
-
calls.push(`enter $ref ${node.$ref} with target ${target?.name}`);
|
|
959
|
-
},
|
|
960
|
-
};
|
|
961
|
-
}),
|
|
962
|
-
};
|
|
963
|
-
|
|
964
|
-
const document = parseYamlToDocument(
|
|
965
|
-
outdent`
|
|
966
|
-
openapi: 3.0.0
|
|
967
|
-
paths:
|
|
968
|
-
/pet:
|
|
969
|
-
id: pet
|
|
970
|
-
parameters:
|
|
971
|
-
- name: path-param
|
|
972
|
-
get:
|
|
973
|
-
operationId: get
|
|
974
|
-
parameters:
|
|
975
|
-
- $ref: '#/components/parameters/shared_b'
|
|
976
|
-
put:
|
|
977
|
-
operationId: put
|
|
978
|
-
parameters:
|
|
979
|
-
- $ref: '#/components/parameters/shared_a'
|
|
980
|
-
/dog:
|
|
981
|
-
id: dog
|
|
982
|
-
post:
|
|
983
|
-
operationId: post
|
|
984
|
-
schema:
|
|
985
|
-
example:
|
|
986
|
-
$ref: 123
|
|
987
|
-
parameters:
|
|
988
|
-
- $ref: '#/components/parameters/shared_a'
|
|
989
|
-
components:
|
|
990
|
-
parameters:
|
|
991
|
-
shared_a:
|
|
992
|
-
name: shared-a
|
|
993
|
-
shared_b:
|
|
994
|
-
name: shared-b
|
|
995
|
-
schema:
|
|
996
|
-
$ref: '#/components/parameters/shared_b'
|
|
997
|
-
`,
|
|
998
|
-
'foobar.yaml'
|
|
999
|
-
);
|
|
1000
|
-
|
|
1001
|
-
await lintDocument({
|
|
1002
|
-
externalRefResolver: new BaseResolver(),
|
|
1003
|
-
document,
|
|
1004
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1005
|
-
});
|
|
1006
|
-
|
|
1007
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
1008
|
-
[
|
|
1009
|
-
"enter $ref #/components/parameters/shared_b with target shared-b",
|
|
1010
|
-
"enter $ref #/components/parameters/shared_b with target shared-b",
|
|
1011
|
-
"enter $ref #/components/parameters/shared_a with target shared-a",
|
|
1012
|
-
"enter $ref #/components/parameters/shared_a with target shared-a",
|
|
1013
|
-
]
|
|
1014
|
-
`);
|
|
1015
|
-
});
|
|
1016
|
-
|
|
1017
|
-
it('should correctly visit refs', async () => {
|
|
1018
|
-
const calls: string[] = [];
|
|
1019
|
-
|
|
1020
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1021
|
-
test: jest.fn(() => {
|
|
1022
|
-
return {
|
|
1023
|
-
NamedSchemas: {
|
|
1024
|
-
Schema(node, { key }) {
|
|
1025
|
-
calls.push(`enter schema ${key}: ${node.type}`);
|
|
1026
|
-
},
|
|
1027
|
-
},
|
|
1028
|
-
};
|
|
1029
|
-
}),
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
const document = parseYamlToDocument(
|
|
1033
|
-
outdent`
|
|
1034
|
-
openapi: 3.0.0
|
|
1035
|
-
components:
|
|
1036
|
-
schemas:
|
|
1037
|
-
a:
|
|
1038
|
-
type: string
|
|
1039
|
-
b:
|
|
1040
|
-
type: number
|
|
1041
|
-
`,
|
|
1042
|
-
'foobar.yaml'
|
|
1043
|
-
);
|
|
1044
|
-
|
|
1045
|
-
await lintDocument({
|
|
1046
|
-
externalRefResolver: new BaseResolver(),
|
|
1047
|
-
document,
|
|
1048
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1049
|
-
});
|
|
1050
|
-
|
|
1051
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
1052
|
-
[
|
|
1053
|
-
"enter schema a: string",
|
|
1054
|
-
"enter schema b: number",
|
|
1055
|
-
]
|
|
1056
|
-
`);
|
|
1057
|
-
});
|
|
1058
|
-
|
|
1059
|
-
it('should correctly visit any visitor', async () => {
|
|
1060
|
-
const calls: string[] = [];
|
|
1061
|
-
|
|
1062
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1063
|
-
test: jest.fn(() => {
|
|
1064
|
-
return {
|
|
1065
|
-
ref: {
|
|
1066
|
-
enter(ref: any) {
|
|
1067
|
-
calls.push(`enter ref ${ref.$ref}`);
|
|
1068
|
-
},
|
|
1069
|
-
leave(ref) {
|
|
1070
|
-
calls.push(`leave ref ${ref.$ref}`);
|
|
1071
|
-
},
|
|
1072
|
-
},
|
|
1073
|
-
any: {
|
|
1074
|
-
enter(_node: any, { type }) {
|
|
1075
|
-
calls.push(`enter ${type.name}`);
|
|
1076
|
-
},
|
|
1077
|
-
leave(_node, { type }) {
|
|
1078
|
-
calls.push(`leave ${type.name}`);
|
|
1079
|
-
},
|
|
1080
|
-
},
|
|
1081
|
-
};
|
|
1082
|
-
}),
|
|
1083
|
-
};
|
|
1084
|
-
|
|
1085
|
-
const document = parseYamlToDocument(
|
|
1086
|
-
outdent`
|
|
1087
|
-
openapi: 3.0.0
|
|
1088
|
-
paths:
|
|
1089
|
-
/pet:
|
|
1090
|
-
id: pet
|
|
1091
|
-
parameters:
|
|
1092
|
-
- name: path-param
|
|
1093
|
-
get:
|
|
1094
|
-
operationId: get
|
|
1095
|
-
parameters:
|
|
1096
|
-
- $ref: '#/components/parameters/shared_a'
|
|
1097
|
-
- name: get_b
|
|
1098
|
-
- name: get_c
|
|
1099
|
-
components:
|
|
1100
|
-
parameters:
|
|
1101
|
-
shared_a:
|
|
1102
|
-
name: shared-a
|
|
1103
|
-
schemas:
|
|
1104
|
-
a:
|
|
1105
|
-
type: object
|
|
1106
|
-
`,
|
|
1107
|
-
''
|
|
1108
|
-
);
|
|
1109
|
-
|
|
1110
|
-
await lintDocument({
|
|
1111
|
-
externalRefResolver: new BaseResolver(),
|
|
1112
|
-
document,
|
|
1113
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
1117
|
-
[
|
|
1118
|
-
"enter Root",
|
|
1119
|
-
"enter Paths",
|
|
1120
|
-
"enter PathItem",
|
|
1121
|
-
"enter ParameterList",
|
|
1122
|
-
"enter Parameter",
|
|
1123
|
-
"leave Parameter",
|
|
1124
|
-
"leave ParameterList",
|
|
1125
|
-
"enter Operation",
|
|
1126
|
-
"enter ParameterList",
|
|
1127
|
-
"enter ref #/components/parameters/shared_a",
|
|
1128
|
-
"enter Parameter",
|
|
1129
|
-
"leave Parameter",
|
|
1130
|
-
"leave ref #/components/parameters/shared_a",
|
|
1131
|
-
"enter Parameter",
|
|
1132
|
-
"leave Parameter",
|
|
1133
|
-
"enter Parameter",
|
|
1134
|
-
"leave Parameter",
|
|
1135
|
-
"leave ParameterList",
|
|
1136
|
-
"leave Operation",
|
|
1137
|
-
"leave PathItem",
|
|
1138
|
-
"leave Paths",
|
|
1139
|
-
"enter Components",
|
|
1140
|
-
"enter NamedParameters",
|
|
1141
|
-
"leave NamedParameters",
|
|
1142
|
-
"enter NamedSchemas",
|
|
1143
|
-
"enter Schema",
|
|
1144
|
-
"leave Schema",
|
|
1145
|
-
"leave NamedSchemas",
|
|
1146
|
-
"leave Components",
|
|
1147
|
-
"leave Root",
|
|
1148
|
-
]
|
|
1149
|
-
`);
|
|
1150
|
-
});
|
|
1151
|
-
});
|
|
1152
|
-
|
|
1153
|
-
describe('context.report', () => {
|
|
1154
|
-
it('should report errors correctly', async () => {
|
|
1155
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1156
|
-
test: jest.fn(() => {
|
|
1157
|
-
return {
|
|
1158
|
-
Parameter: {
|
|
1159
|
-
enter: jest.fn((param, ctx) => {
|
|
1160
|
-
if (param.name.indexOf('_') > -1) {
|
|
1161
|
-
ctx.report({
|
|
1162
|
-
message: `Parameter name shouldn't contain '_: ${param.name}`,
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
}),
|
|
1166
|
-
},
|
|
1167
|
-
};
|
|
1168
|
-
}),
|
|
1169
|
-
};
|
|
1170
|
-
|
|
1171
|
-
const document = parseYamlToDocument(
|
|
1172
|
-
outdent`
|
|
1173
|
-
openapi: 3.0.0
|
|
1174
|
-
info:
|
|
1175
|
-
contact: {}
|
|
1176
|
-
license: {}
|
|
1177
|
-
paths:
|
|
1178
|
-
/pet:
|
|
1179
|
-
parameters:
|
|
1180
|
-
- name: path-param
|
|
1181
|
-
get:
|
|
1182
|
-
operationId: get
|
|
1183
|
-
parameters:
|
|
1184
|
-
- name: get_a
|
|
1185
|
-
- name: get_b
|
|
1186
|
-
post:
|
|
1187
|
-
operationId: post
|
|
1188
|
-
parameters:
|
|
1189
|
-
- $ref: '#/components/parameters/shared_a'
|
|
1190
|
-
components:
|
|
1191
|
-
parameters:
|
|
1192
|
-
shared_a:
|
|
1193
|
-
name: shared_a
|
|
1194
|
-
`,
|
|
1195
|
-
'foobar.yaml'
|
|
1196
|
-
);
|
|
1197
|
-
|
|
1198
|
-
const results = await lintDocument({
|
|
1199
|
-
externalRefResolver: new BaseResolver(),
|
|
1200
|
-
document,
|
|
1201
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1202
|
-
});
|
|
1203
|
-
|
|
1204
|
-
expect(results).toHaveLength(3);
|
|
1205
|
-
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
1206
|
-
[
|
|
1207
|
-
{
|
|
1208
|
-
"location": [
|
|
1209
|
-
{
|
|
1210
|
-
"pointer": "#/paths/~1pet/get/parameters/0",
|
|
1211
|
-
"reportOnKey": false,
|
|
1212
|
-
"source": "foobar.yaml",
|
|
1213
|
-
},
|
|
1214
|
-
],
|
|
1215
|
-
"message": "Parameter name shouldn't contain '_: get_a",
|
|
1216
|
-
"ruleId": "test/test",
|
|
1217
|
-
"severity": "error",
|
|
1218
|
-
"suggest": [],
|
|
1219
|
-
},
|
|
1220
|
-
{
|
|
1221
|
-
"location": [
|
|
1222
|
-
{
|
|
1223
|
-
"pointer": "#/paths/~1pet/get/parameters/1",
|
|
1224
|
-
"reportOnKey": false,
|
|
1225
|
-
"source": "foobar.yaml",
|
|
1226
|
-
},
|
|
1227
|
-
],
|
|
1228
|
-
"message": "Parameter name shouldn't contain '_: get_b",
|
|
1229
|
-
"ruleId": "test/test",
|
|
1230
|
-
"severity": "error",
|
|
1231
|
-
"suggest": [],
|
|
1232
|
-
},
|
|
1233
|
-
{
|
|
1234
|
-
"location": [
|
|
1235
|
-
{
|
|
1236
|
-
"pointer": "#/components/parameters/shared_a",
|
|
1237
|
-
"reportOnKey": false,
|
|
1238
|
-
"source": "foobar.yaml",
|
|
1239
|
-
},
|
|
1240
|
-
],
|
|
1241
|
-
"message": "Parameter name shouldn't contain '_: shared_a",
|
|
1242
|
-
"ruleId": "test/test",
|
|
1243
|
-
"severity": "error",
|
|
1244
|
-
"suggest": [],
|
|
1245
|
-
},
|
|
1246
|
-
]
|
|
1247
|
-
`);
|
|
1248
|
-
});
|
|
1249
|
-
|
|
1250
|
-
it('should report errors correctly', async () => {
|
|
1251
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1252
|
-
test: jest.fn(() => {
|
|
1253
|
-
return {
|
|
1254
|
-
Parameter: {
|
|
1255
|
-
enter: jest.fn((param, ctx) => {
|
|
1256
|
-
if (param.name.indexOf('_') > -1) {
|
|
1257
|
-
ctx.report({
|
|
1258
|
-
message: `Parameter name shouldn't contain '_: ${param.name}`,
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
}),
|
|
1262
|
-
},
|
|
1263
|
-
};
|
|
1264
|
-
}),
|
|
1265
|
-
};
|
|
1266
|
-
|
|
1267
|
-
const cwd = path.join(__dirname, 'fixtures/refs');
|
|
1268
|
-
const externalRefResolver = new BaseResolver();
|
|
1269
|
-
const document = (await externalRefResolver.resolveDocument(
|
|
1270
|
-
null,
|
|
1271
|
-
`${cwd}/openapi-with-external-refs.yaml`
|
|
1272
|
-
)) as Document;
|
|
1273
|
-
|
|
1274
|
-
if (document === null) {
|
|
1275
|
-
throw 'Should never happen';
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
const results = await lintDocument({
|
|
1279
|
-
externalRefResolver: new BaseResolver(),
|
|
1280
|
-
document,
|
|
1281
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1282
|
-
});
|
|
1283
|
-
|
|
1284
|
-
expect(results).toHaveLength(4);
|
|
1285
|
-
expect(replaceSourceWithRef(results, cwd)).toMatchInlineSnapshot(`
|
|
1286
|
-
[
|
|
1287
|
-
{
|
|
1288
|
-
"location": [
|
|
1289
|
-
{
|
|
1290
|
-
"pointer": "#/components/parameters/path-param",
|
|
1291
|
-
"reportOnKey": false,
|
|
1292
|
-
"source": "openapi-with-external-refs.yaml",
|
|
1293
|
-
},
|
|
1294
|
-
],
|
|
1295
|
-
"message": "Parameter name shouldn't contain '_: path_param",
|
|
1296
|
-
"ruleId": "test/test",
|
|
1297
|
-
"severity": "error",
|
|
1298
|
-
"suggest": [],
|
|
1299
|
-
},
|
|
1300
|
-
{
|
|
1301
|
-
"location": [
|
|
1302
|
-
{
|
|
1303
|
-
"pointer": "#/components/parameters/param-a",
|
|
1304
|
-
"reportOnKey": false,
|
|
1305
|
-
"source": "openapi-with-external-refs.yaml",
|
|
1306
|
-
},
|
|
1307
|
-
],
|
|
1308
|
-
"message": "Parameter name shouldn't contain '_: param_a",
|
|
1309
|
-
"ruleId": "test/test",
|
|
1310
|
-
"severity": "error",
|
|
1311
|
-
"suggest": [],
|
|
1312
|
-
},
|
|
1313
|
-
{
|
|
1314
|
-
"location": [
|
|
1315
|
-
{
|
|
1316
|
-
"pointer": "#/",
|
|
1317
|
-
"reportOnKey": false,
|
|
1318
|
-
"source": "param-c.yaml",
|
|
1319
|
-
},
|
|
1320
|
-
],
|
|
1321
|
-
"message": "Parameter name shouldn't contain '_: param_c",
|
|
1322
|
-
"ruleId": "test/test",
|
|
1323
|
-
"severity": "error",
|
|
1324
|
-
"suggest": [],
|
|
1325
|
-
},
|
|
1326
|
-
{
|
|
1327
|
-
"location": [
|
|
1328
|
-
{
|
|
1329
|
-
"pointer": "#/",
|
|
1330
|
-
"reportOnKey": false,
|
|
1331
|
-
"source": "param-b.yaml",
|
|
1332
|
-
},
|
|
1333
|
-
],
|
|
1334
|
-
"message": "Parameter name shouldn't contain '_: param_b",
|
|
1335
|
-
"ruleId": "test/test",
|
|
1336
|
-
"severity": "error",
|
|
1337
|
-
"suggest": [],
|
|
1338
|
-
},
|
|
1339
|
-
]
|
|
1340
|
-
`);
|
|
1341
|
-
});
|
|
1342
|
-
|
|
1343
|
-
it('should report errors with custom messages', async () => {
|
|
1344
|
-
const document = parseYamlToDocument(
|
|
1345
|
-
outdent`
|
|
1346
|
-
openapi: 3.0.0
|
|
1347
|
-
info:
|
|
1348
|
-
license: {}
|
|
1349
|
-
paths: {}
|
|
1350
|
-
`,
|
|
1351
|
-
'foobar.yaml'
|
|
1352
|
-
);
|
|
1353
|
-
|
|
1354
|
-
const config = await createConfig(`
|
|
1355
|
-
rules:
|
|
1356
|
-
info-contact:
|
|
1357
|
-
message: "MY ERR DESCRIPTION: {{message}}"
|
|
1358
|
-
severity: "error"
|
|
1359
|
-
`);
|
|
1360
|
-
|
|
1361
|
-
const results = await lintDocument({
|
|
1362
|
-
externalRefResolver: new BaseResolver(),
|
|
1363
|
-
document,
|
|
1364
|
-
config: config.styleguide,
|
|
1365
|
-
});
|
|
1366
|
-
|
|
1367
|
-
expect(results).toMatchInlineSnapshot(`
|
|
1368
|
-
[
|
|
1369
|
-
{
|
|
1370
|
-
"location": [
|
|
1371
|
-
{
|
|
1372
|
-
"pointer": "#/info/contact",
|
|
1373
|
-
"reportOnKey": true,
|
|
1374
|
-
"source": Source {
|
|
1375
|
-
"absoluteRef": "foobar.yaml",
|
|
1376
|
-
"body": "openapi: 3.0.0
|
|
1377
|
-
info:
|
|
1378
|
-
license: {}
|
|
1379
|
-
paths: {}",
|
|
1380
|
-
"mimeType": undefined,
|
|
1381
|
-
},
|
|
1382
|
-
},
|
|
1383
|
-
],
|
|
1384
|
-
"message": "MY ERR DESCRIPTION: Info object should contain \`contact\` field.",
|
|
1385
|
-
"ruleId": "info-contact",
|
|
1386
|
-
"severity": "error",
|
|
1387
|
-
"suggest": [],
|
|
1388
|
-
},
|
|
1389
|
-
]
|
|
1390
|
-
`);
|
|
1391
|
-
});
|
|
1392
|
-
});
|
|
1393
|
-
|
|
1394
|
-
describe('context.resolve', () => {
|
|
1395
|
-
it('should resolve refs correctly', async () => {
|
|
1396
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1397
|
-
test: jest.fn(() => {
|
|
1398
|
-
return {
|
|
1399
|
-
Schema: jest.fn((schema, { resolve }) => {
|
|
1400
|
-
if (schema.properties) {
|
|
1401
|
-
expect(schema.properties.a.$ref).toBeDefined();
|
|
1402
|
-
const { location, node } = resolve(schema.properties.a);
|
|
1403
|
-
expect(node).toMatchInlineSnapshot(`
|
|
1404
|
-
{
|
|
1405
|
-
"type": "string",
|
|
1406
|
-
}
|
|
1407
|
-
`);
|
|
1408
|
-
expect(location?.pointer).toEqual('#/components/schemas/b');
|
|
1409
|
-
expect(location?.source).toStrictEqual(document.source);
|
|
1410
|
-
}
|
|
1411
|
-
}),
|
|
1412
|
-
};
|
|
1413
|
-
}),
|
|
1414
|
-
};
|
|
1415
|
-
|
|
1416
|
-
const document = parseYamlToDocument(
|
|
1417
|
-
outdent`
|
|
1418
|
-
openapi: 3.0.0
|
|
1419
|
-
info:
|
|
1420
|
-
contact: {}
|
|
1421
|
-
license: {}
|
|
1422
|
-
paths: {}
|
|
1423
|
-
components:
|
|
1424
|
-
schemas:
|
|
1425
|
-
b:
|
|
1426
|
-
type: string
|
|
1427
|
-
a:
|
|
1428
|
-
type: object
|
|
1429
|
-
properties:
|
|
1430
|
-
a:
|
|
1431
|
-
$ref: '#/components/schemas/b'
|
|
1432
|
-
`,
|
|
1433
|
-
'foobar.yaml'
|
|
1434
|
-
);
|
|
1435
|
-
|
|
1436
|
-
await lintDocument({
|
|
1437
|
-
externalRefResolver: new BaseResolver(),
|
|
1438
|
-
document,
|
|
1439
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1440
|
-
});
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
describe('type extensions', () => {
|
|
1445
|
-
each([
|
|
1446
|
-
['3.0.0', 'oas3_0'],
|
|
1447
|
-
['3.1.0', 'oas3_1'],
|
|
1448
|
-
]).it('should correctly visit OpenAPI %s extended types', async (openapi, oas) => {
|
|
1449
|
-
const calls: string[] = [];
|
|
1450
|
-
|
|
1451
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1452
|
-
test: jest.fn(() => {
|
|
1453
|
-
return {
|
|
1454
|
-
any: {
|
|
1455
|
-
enter(_node: any, { type }) {
|
|
1456
|
-
calls.push(`enter ${type.name}`);
|
|
1457
|
-
},
|
|
1458
|
-
leave(_node, { type }) {
|
|
1459
|
-
calls.push(`leave ${type.name}`);
|
|
1460
|
-
},
|
|
1461
|
-
},
|
|
1462
|
-
XWebHooks: {
|
|
1463
|
-
enter(hook: any) {
|
|
1464
|
-
calls.push(`enter hook ${hook.name}`);
|
|
1465
|
-
},
|
|
1466
|
-
leave(hook) {
|
|
1467
|
-
calls.push(`leave hook ${hook.name}`);
|
|
1468
|
-
},
|
|
1469
|
-
},
|
|
1470
|
-
};
|
|
1471
|
-
}),
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
|
-
const document = parseYamlToDocument(
|
|
1475
|
-
outdent`
|
|
1476
|
-
openapi: ${openapi}
|
|
1477
|
-
x-webhooks:
|
|
1478
|
-
name: test
|
|
1479
|
-
parameters:
|
|
1480
|
-
- name: a
|
|
1481
|
-
`,
|
|
1482
|
-
'foobar.yaml'
|
|
1483
|
-
);
|
|
1484
|
-
|
|
1485
|
-
await lintDocument({
|
|
1486
|
-
externalRefResolver: new BaseResolver(),
|
|
1487
|
-
document,
|
|
1488
|
-
config: await makeConfigForRuleset(testRuleSet, {
|
|
1489
|
-
typeExtension: {
|
|
1490
|
-
oas3(types, version) {
|
|
1491
|
-
expect(version).toEqual(oas);
|
|
1492
|
-
|
|
1493
|
-
return {
|
|
1494
|
-
...types,
|
|
1495
|
-
XWebHooks: {
|
|
1496
|
-
properties: {
|
|
1497
|
-
parameters: listOf('Parameter'),
|
|
1498
|
-
},
|
|
1499
|
-
},
|
|
1500
|
-
Root: {
|
|
1501
|
-
...types.Root,
|
|
1502
|
-
properties: {
|
|
1503
|
-
...types.Root.properties,
|
|
1504
|
-
'x-webhooks': 'XWebHooks',
|
|
1505
|
-
},
|
|
1506
|
-
},
|
|
1507
|
-
};
|
|
1508
|
-
},
|
|
1509
|
-
},
|
|
1510
|
-
}),
|
|
1511
|
-
});
|
|
1512
|
-
|
|
1513
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
1514
|
-
[
|
|
1515
|
-
"enter Root",
|
|
1516
|
-
"enter XWebHooks",
|
|
1517
|
-
"enter hook test",
|
|
1518
|
-
"enter ParameterList",
|
|
1519
|
-
"enter Parameter",
|
|
1520
|
-
"leave Parameter",
|
|
1521
|
-
"leave ParameterList",
|
|
1522
|
-
"leave hook test",
|
|
1523
|
-
"leave XWebHooks",
|
|
1524
|
-
"leave Root",
|
|
1525
|
-
]
|
|
1526
|
-
`);
|
|
1527
|
-
});
|
|
1528
|
-
});
|
|
1529
|
-
|
|
1530
|
-
describe('ignoreNextRules', () => {
|
|
1531
|
-
it('should correctly skip top level', async () => {
|
|
1532
|
-
const calls: string[] = [];
|
|
1533
|
-
|
|
1534
|
-
const testRuleSet: Oas3RuleSet = {
|
|
1535
|
-
skip: jest.fn(() => {
|
|
1536
|
-
return {
|
|
1537
|
-
Operation: {
|
|
1538
|
-
enter: jest.fn((op, ctx) => {
|
|
1539
|
-
if (op.operationId === 'get') {
|
|
1540
|
-
ctx.ignoreNextVisitorsOnNode();
|
|
1541
|
-
calls.push(`enter and skip operation ${op.operationId}`);
|
|
1542
|
-
} else {
|
|
1543
|
-
calls.push(`enter and not skip operation ${op.operationId}`);
|
|
1544
|
-
}
|
|
1545
|
-
}),
|
|
1546
|
-
leave: jest.fn((op) => {
|
|
1547
|
-
if (op.operationId === 'get') {
|
|
1548
|
-
calls.push(`leave skipped operation ${op.operationId}`);
|
|
1549
|
-
} else {
|
|
1550
|
-
calls.push(`leave not skipped operation ${op.operationId}`);
|
|
1551
|
-
}
|
|
1552
|
-
}),
|
|
1553
|
-
},
|
|
1554
|
-
};
|
|
1555
|
-
}),
|
|
1556
|
-
test: jest.fn(() => {
|
|
1557
|
-
return {
|
|
1558
|
-
Operation: {
|
|
1559
|
-
enter: jest.fn((op) => calls.push(`enter operation ${op.operationId}`)),
|
|
1560
|
-
leave: jest.fn((op) => calls.push(`leave operation ${op.operationId}`)),
|
|
1561
|
-
},
|
|
1562
|
-
};
|
|
1563
|
-
}),
|
|
1564
|
-
};
|
|
1565
|
-
|
|
1566
|
-
const document = parseYamlToDocument(
|
|
1567
|
-
outdent`
|
|
1568
|
-
openapi: 3.0.0
|
|
1569
|
-
paths:
|
|
1570
|
-
/pet:
|
|
1571
|
-
get:
|
|
1572
|
-
operationId: get
|
|
1573
|
-
put:
|
|
1574
|
-
operationId: put
|
|
1575
|
-
`,
|
|
1576
|
-
''
|
|
1577
|
-
);
|
|
1578
|
-
|
|
1579
|
-
await lintDocument({
|
|
1580
|
-
externalRefResolver: new BaseResolver(),
|
|
1581
|
-
document,
|
|
1582
|
-
config: await makeConfigForRuleset(testRuleSet),
|
|
1583
|
-
});
|
|
1584
|
-
|
|
1585
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
1586
|
-
[
|
|
1587
|
-
"enter and skip operation get",
|
|
1588
|
-
"leave skipped operation get",
|
|
1589
|
-
"enter and not skip operation put",
|
|
1590
|
-
"enter operation put",
|
|
1591
|
-
"leave not skipped operation put",
|
|
1592
|
-
"leave operation put",
|
|
1593
|
-
]
|
|
1594
|
-
`);
|
|
1595
|
-
});
|
|
1596
|
-
});
|