diff --git a/docs/changelog.md b/docs/changelog.md index 50de67a3f2..273327134c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1294,9 +1294,8 @@ rules: ### Features - Added five new built-in rules: - - [path-excludes-patterns](./rules/path-excludes-patterns.md) + - [path-excludes-patterns](./rules/oas/path-excludes-patterns.md) - [no-http-verbs-in-paths](./rules/no-http-verbs-in-paths.md) - - [path-excludes-patterns](./rules/path-excludes-patterns.md) - [request-mime-type](./rules/request-mime-type.md) - [response-mime-type](./rules/response-mime-type.md) diff --git a/docs/rules/built-in-rules.md b/docs/rules/built-in-rules.md index 7baaec9beb..b5bed50e0c 100644 --- a/docs/rules/built-in-rules.md +++ b/docs/rules/built-in-rules.md @@ -49,9 +49,9 @@ Details of all the rules available "out of the box" with Redocly CLI are listed - [no-invalid-parameter-examples](./no-invalid-parameter-examples.md): Parameter examples must match declared schema types - [operation-parameters-unique](./operation-parameters-unique.md): No repeated parameter names within an operation - [parameter-description](./oas/parameter-description.md): Parameters must all have descriptions -- [path-declaration-must-exist](./path-declaration-must-exist.md): Paths must define template variables where placeholders are needed -- [path-not-include-query](./path-not-include-query.md): No query parameters in path declarations (declare them as parameters with `in: query`) -- [path-parameters-defined](./path-parameters-defined.md): Path template variables must be defined as parameters +- [path-declaration-must-exist](./oas/path-declaration-must-exist.md): Paths must define template variables where placeholders are needed +- [path-not-include-query](./oas/path-not-include-query.md): No query parameters in path declarations (declare them as parameters with `in: query`) +- [path-parameters-defined](./oas/path-parameters-defined.md): Path template variables must be defined as parameters ### Paths @@ -59,9 +59,9 @@ Details of all the rules available "out of the box" with Redocly CLI are listed - [no-http-verbs-in-paths](./no-http-verbs-in-paths.md): Verbs like "get" cannot be used in paths - [no-identical-paths](./oas/no-identical-paths.md): Paths cannot be identical, including template variables - [no-path-trailing-slash](./oas/no-path-trailing-slash.md): No trailing slashes on paths -- [path-excludes-patterns](./path-excludes-patterns.md): Set a regular expression that cannot be used in paths -- [path-segment-plural](./path-segment-plural.md): All URL segments in a path must be plural (exceptions can be configured) -- [paths-kebab-case](./paths-kebab-case.md): Paths must be in `kebab-case` format +- [path-excludes-patterns](./oas/path-excludes-patterns.md): Set a regular expression that cannot be used in paths +- [path-segment-plural](./oas/path-segment-plural.md): All URL segments in a path must be plural (exceptions can be configured) +- [paths-kebab-case](./oas/paths-kebab-case.md): Paths must be in `kebab-case` format ### Requests, Responses, and Schemas diff --git a/docs/rules/minimal.md b/docs/rules/minimal.md index b08a874a9e..6225e993f7 100644 --- a/docs/rules/minimal.md +++ b/docs/rules/minimal.md @@ -32,9 +32,9 @@ Warnings: - [operation-operationId](./operation-operationId.md) - [operation-parameters-unique](./operation-parameters-unique.md) - [operation-summary](./oas/operation-summary.md) -- [path-declaration-must-exist](./path-declaration-must-exist.md) -- [path-not-include-query](./path-not-include-query.md) -- [path-parameters-defined](./path-parameters-defined.md) +- [path-declaration-must-exist](./oas/path-declaration-must-exist.md) +- [path-not-include-query](./oas/path-not-include-query.md) +- [path-parameters-defined](./oas/path-parameters-defined.md) - [security-defined](./security-defined.md) - [spec-components-invalid-map-name](./spec-components-invalid-map-name.md) - [tag-description](./oas/tag-description.md) diff --git a/docs/rules/path-declaration-must-exist.md b/docs/rules/oas/path-declaration-must-exist.md similarity index 96% rename from docs/rules/path-declaration-must-exist.md rename to docs/rules/oas/path-declaration-must-exist.md index 786a2eafb7..4f08d91204 100644 --- a/docs/rules/path-declaration-must-exist.md +++ b/docs/rules/oas/path-declaration-must-exist.md @@ -1,5 +1,5 @@ --- -slug: /docs/cli/rules/path-declaration-must-exist +slug: /docs/cli/rules/oas/path-declaration-must-exist --- # path-declaration-must-exist diff --git a/docs/rules/path-excludes-patterns.md b/docs/rules/oas/path-excludes-patterns.md similarity index 100% rename from docs/rules/path-excludes-patterns.md rename to docs/rules/oas/path-excludes-patterns.md diff --git a/docs/rules/path-not-include-query.md b/docs/rules/oas/path-not-include-query.md similarity index 97% rename from docs/rules/path-not-include-query.md rename to docs/rules/oas/path-not-include-query.md index e68ee6f116..d13b56dc66 100644 --- a/docs/rules/path-not-include-query.md +++ b/docs/rules/oas/path-not-include-query.md @@ -1,5 +1,5 @@ --- -slug: /docs/cli/rules/path-not-include-query +slug: /docs/cli/rules/oas/path-not-include-query --- # path-not-include-query diff --git a/docs/rules/path-parameters-defined.md b/docs/rules/oas/path-parameters-defined.md similarity index 97% rename from docs/rules/path-parameters-defined.md rename to docs/rules/oas/path-parameters-defined.md index 492ed5f9d8..19ae6fbabb 100644 --- a/docs/rules/path-parameters-defined.md +++ b/docs/rules/oas/path-parameters-defined.md @@ -1,5 +1,5 @@ --- -slug: /docs/cli/rules/path-parameters-defined +slug: /docs/cli/rules/oas/path-parameters-defined --- # path-parameters-defined diff --git a/docs/rules/path-segment-plural.md b/docs/rules/oas/path-segment-plural.md similarity index 98% rename from docs/rules/path-segment-plural.md rename to docs/rules/oas/path-segment-plural.md index 4adc09d7cc..3f65bb039c 100644 --- a/docs/rules/path-segment-plural.md +++ b/docs/rules/oas/path-segment-plural.md @@ -1,5 +1,5 @@ --- -slug: /docs/cli/rules/path-segment-plural +slug: /docs/cli/rules/oas/path-segment-plural --- # path-segment-plural diff --git a/docs/rules/paths-kebab-case.md b/docs/rules/oas/paths-kebab-case.md similarity index 97% rename from docs/rules/paths-kebab-case.md rename to docs/rules/oas/paths-kebab-case.md index b42efa07a3..18e61e82bc 100644 --- a/docs/rules/paths-kebab-case.md +++ b/docs/rules/oas/paths-kebab-case.md @@ -1,5 +1,5 @@ --- -slug: /docs/cli/rules/paths-kebab-case +slug: /docs/cli/rules/oas/paths-kebab-case --- # paths-kebab-case diff --git a/docs/rules/recommended.md b/docs/rules/recommended.md index 89e5e26274..c445003958 100644 --- a/docs/rules/recommended.md +++ b/docs/rules/recommended.md @@ -22,8 +22,8 @@ Errors: - [operation-parameters-unique](./operation-parameters-unique.md) - [operation-summary](./oas/operation-summary.md) - [path-declaration-must-exist](./path-declaration-must-exist.md) -- [path-not-include-query](./path-not-include-query.md) -- [path-parameters-defined](./path-parameters-defined.md) +- [path-not-include-query](./oas/path-not-include-query.md) +- [path-parameters-defined](./oas/path-parameters-defined.md) - [security-defined](./security-defined.md) - [spec-components-invalid-map-name](./spec-components-invalid-map-name.md) - [spec](./spec.md) diff --git a/docs/sidebars.yaml b/docs/sidebars.yaml index 68e2a1ee12..5337d2b902 100644 --- a/docs/sidebars.yaml +++ b/docs/sidebars.yaml @@ -110,11 +110,11 @@ - page: rules/operation-tag-defined.md - page: rules/oas/parameter-description.md - page: rules/path-declaration-must-exist.md - - page: rules/path-excludes-patterns.md - - page: rules/path-not-include-query.md - - page: rules/path-parameters-defined.md - - page: rules/path-segment-plural.md - - page: rules/paths-kebab-case.md + - page: rules/oas/path-excludes-patterns.md + - page: rules/oas/path-not-include-query.md + - page: rules/oas/path-parameters-defined.md + - page: rules/oas/path-segment-plural.md + - page: rules/oas/paths-kebab-case.md - page: rules/request-mime-type.md - page: rules/required-string-property-missing-min-length.md - page: rules/response-contains-header.md diff --git a/packages/core/src/config/all.ts b/packages/core/src/config/all.ts index ae9b4ac1d7..9b122bb07a 100644 --- a/packages/core/src/config/all.ts +++ b/packages/core/src/config/all.ts @@ -2,10 +2,6 @@ import type { PluginStyleguideConfig } from './types'; const all: PluginStyleguideConfig<'built-in'> = { rules: { - 'path-segment-plural': 'error', - 'path-declaration-must-exist': 'error', - 'path-not-include-query': 'error', - 'path-parameters-defined': 'error', 'operation-description': 'error', 'operation-2xx-response': 'error', 'operation-4xx-response': 'error', @@ -18,20 +14,13 @@ const all: PluginStyleguideConfig<'built-in'> = { 'operation-singular-tag': 'error', 'no-unresolved-refs': 'error', 'no-enum-type-mismatch': 'error', - 'paths-kebab-case': 'error', 'no-http-verbs-in-paths': 'error', - 'path-excludes-patterns': { - severity: 'error', - patterns: [], - }, spec: 'error', struct: 'off', 'no-invalid-schema-examples': 'error', 'no-invalid-parameter-examples': 'error', 'scalar-property-missing-example': 'error', 'spec-strict-refs': 'error', - 'path-http-verbs-order': 'error', - 'path-params-defined': 'error', 'required-string-property-missing-min-length': 'error', 'response-contains-header': 'error', }, @@ -43,6 +32,17 @@ const all: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'error', 'parameter-description': 'error', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'error', + 'path-excludes-patterns': { + severity: 'error', + patterns: [], + }, + 'path-http-verbs-order': 'error', + 'path-params-defined': 'error', + 'path-segment-plural': 'error', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -67,6 +67,17 @@ const all: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'error', 'parameter-description': 'error', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'error', + 'path-excludes-patterns': { + severity: 'error', + patterns: [], + }, + 'path-http-verbs-order': 'error', + 'path-params-defined': 'error', + 'path-segment-plural': 'error', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -103,6 +114,17 @@ const all: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'error', 'parameter-description': 'error', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'error', + 'path-excludes-patterns': { + severity: 'error', + patterns: [], + }, + 'path-http-verbs-order': 'error', + 'path-params-defined': 'error', + 'path-segment-plural': 'error', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', diff --git a/packages/core/src/config/minimal.ts b/packages/core/src/config/minimal.ts index 71a8e153fb..b7956675ba 100644 --- a/packages/core/src/config/minimal.ts +++ b/packages/core/src/config/minimal.ts @@ -2,9 +2,6 @@ import type { PluginStyleguideConfig } from './types'; const minimal: PluginStyleguideConfig<'built-in'> = { rules: { - 'path-declaration-must-exist': 'warn', - 'path-not-include-query': 'warn', - 'path-parameters-defined': 'warn', 'operation-description': 'off', 'operation-2xx-response': 'warn', 'operation-4xx-response': 'off', @@ -17,19 +14,14 @@ const minimal: PluginStyleguideConfig<'built-in'> = { 'operation-singular-tag': 'off', 'no-unresolved-refs': 'error', 'no-enum-type-mismatch': 'warn', - 'paths-kebab-case': 'off', spec: 'error', struct: 'off', 'spec-strict-refs': 'off', 'no-http-verbs-in-paths': 'off', 'no-invalid-parameter-examples': 'off', 'no-invalid-schema-examples': 'off', - 'path-excludes-patterns': 'off', - 'path-http-verbs-order': 'off', - 'path-params-defined': 'off', 'required-string-property-missing-min-length': 'off', 'response-contains-header': 'off', - 'path-segment-plural': 'off', 'scalar-property-missing-example': 'off', }, oas2Rules: { @@ -40,6 +32,14 @@ const minimal: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'warn', + 'path-not-include-query': 'warn', + 'path-parameters-defined': 'warn', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'warn', 'no-path-trailing-slash': 'warn', 'no-identical-paths': 'warn', @@ -58,6 +58,14 @@ const minimal: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'warn', + 'path-not-include-query': 'warn', + 'path-parameters-defined': 'warn', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'warn', 'no-ambiguous-paths': 'warn', 'no-path-trailing-slash': 'warn', @@ -91,6 +99,14 @@ const minimal: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'warn', + 'path-not-include-query': 'warn', + 'path-parameters-defined': 'warn', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'warn', 'no-path-trailing-slash': 'warn', 'no-identical-paths': 'warn', diff --git a/packages/core/src/config/recommended-strict.ts b/packages/core/src/config/recommended-strict.ts index c336d6f038..664ad09e85 100644 --- a/packages/core/src/config/recommended-strict.ts +++ b/packages/core/src/config/recommended-strict.ts @@ -2,9 +2,6 @@ import type { PluginStyleguideConfig } from './types'; const recommendedStrict: PluginStyleguideConfig<'built-in'> = { rules: { - 'path-declaration-must-exist': 'error', - 'path-not-include-query': 'error', - 'path-parameters-defined': 'error', 'operation-description': 'off', 'operation-2xx-response': 'error', 'operation-4xx-response': 'error', @@ -17,17 +14,12 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = { 'operation-singular-tag': 'off', 'no-unresolved-refs': 'error', 'no-enum-type-mismatch': 'error', - 'paths-kebab-case': 'off', spec: 'error', struct: 'off', 'spec-strict-refs': 'off', 'no-http-verbs-in-paths': 'off', 'no-invalid-parameter-examples': 'off', 'no-invalid-schema-examples': 'off', - 'path-excludes-patterns': 'off', - 'path-http-verbs-order': 'off', - 'path-params-defined': 'off', - 'path-segment-plural': 'off', 'required-string-property-missing-min-length': 'off', 'response-contains-header': 'off', 'scalar-property-missing-example': 'off', @@ -40,6 +32,14 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -58,6 +58,14 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -91,6 +99,14 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'error', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', diff --git a/packages/core/src/config/recommended.ts b/packages/core/src/config/recommended.ts index 48cf7ee055..9ce4e002be 100644 --- a/packages/core/src/config/recommended.ts +++ b/packages/core/src/config/recommended.ts @@ -2,9 +2,6 @@ import type { PluginStyleguideConfig } from './types'; const recommended: PluginStyleguideConfig<'built-in'> = { rules: { - 'path-declaration-must-exist': 'error', - 'path-not-include-query': 'error', - 'path-parameters-defined': 'error', 'operation-description': 'off', 'operation-2xx-response': 'warn', 'operation-4xx-response': 'warn', @@ -17,17 +14,12 @@ const recommended: PluginStyleguideConfig<'built-in'> = { 'operation-singular-tag': 'off', 'no-unresolved-refs': 'error', 'no-enum-type-mismatch': 'error', - 'paths-kebab-case': 'off', spec: 'error', struct: 'off', 'spec-strict-refs': 'off', 'no-http-verbs-in-paths': 'off', 'no-invalid-parameter-examples': 'off', 'no-invalid-schema-examples': 'off', - 'path-excludes-patterns': 'off', - 'path-http-verbs-order': 'off', - 'path-params-defined': 'off', - 'path-segment-plural': 'off', 'required-string-property-missing-min-length': 'off', 'response-contains-header': 'off', 'scalar-property-missing-example': 'off', @@ -40,6 +32,14 @@ const recommended: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -59,6 +59,14 @@ const recommended: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', @@ -93,6 +101,14 @@ const recommended: PluginStyleguideConfig<'built-in'> = { 'tag-description': 'warn', 'tags-alphabetical': 'off', 'parameter-description': 'off', + 'path-declaration-must-exist': 'error', + 'path-not-include-query': 'error', + 'path-parameters-defined': 'error', + 'paths-kebab-case': 'off', + 'path-excludes-patterns': 'off', + 'path-http-verbs-order': 'off', + 'path-params-defined': 'off', + 'path-segment-plural': 'off', 'operation-summary': 'error', 'no-path-trailing-slash': 'error', 'no-identical-paths': 'error', diff --git a/packages/core/src/types/redocly-yaml.ts b/packages/core/src/types/redocly-yaml.ts index 133e88f47d..aa5fee032d 100644 --- a/packages/core/src/types/redocly-yaml.ts +++ b/packages/core/src/types/redocly-yaml.ts @@ -24,14 +24,6 @@ const builtInCommonRules = [ 'operation-parameters-unique', 'operation-singular-tag', 'operation-tag-defined', - 'path-declaration-must-exist', - 'path-excludes-patterns', - 'path-http-verbs-order', - 'path-not-include-query', - 'path-params-defined', - 'path-parameters-defined', - 'path-segment-plural', - 'paths-kebab-case', 'required-string-property-missing-min-length', 'response-contains-header', 'scalar-property-missing-example', @@ -114,6 +106,14 @@ const builtInOAS2Rules = [ 'tag-description', 'tags-alphabetical', 'parameter-description', + 'path-declaration-must-exist', + 'path-not-include-query', + 'path-parameters-defined', + 'paths-kebab-case', + 'path-excludes-patterns', + 'path-http-verbs-order', + 'path-params-defined', + 'path-segment-plural', 'operation-summary', 'no-identical-paths', 'no-path-trailing-slash', @@ -135,6 +135,14 @@ const builtInOAS3Rules = [ 'tag-description', 'tags-alphabetical', 'parameter-description', + 'path-declaration-must-exist', + 'path-not-include-query', + 'path-parameters-defined', + 'paths-kebab-case', + 'path-excludes-patterns', + 'path-http-verbs-order', + 'path-params-defined', + 'path-segment-plural', 'operation-summary', 'no-identical-paths', 'no-path-trailing-slash',