Skip to content

Commit

Permalink
chore: migrating oas rules from common
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky committed Nov 18, 2024
1 parent dc758aa commit 498c610
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 66 deletions.
3 changes: 1 addition & 2 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions docs/rules/built-in-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ 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

- [no-ambiguous-paths](./oas/no-ambiguous-paths.md): No path can match more than one PathItem entry, including template variables
- [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

Expand Down
6 changes: 3 additions & 3 deletions docs/rules/minimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /docs/cli/rules/path-parameters-defined
slug: /docs/cli/rules/oas/path-parameters-defined
---

# path-parameters-defined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /docs/cli/rules/path-segment-plural
slug: /docs/cli/rules/oas/path-segment-plural
---

# path-segment-plural
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /docs/cli/rules/paths-kebab-case
slug: /docs/cli/rules/oas/paths-kebab-case
---

# paths-kebab-case
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/recommended.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 24 in docs/rules/recommended.md

View workflow job for this annotation

GitHub Actions / linkcheck

broken link

/github/workspace/docs/rules/path-declaration-must-exist.md. Target filename not found.
- [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)
Expand Down
10 changes: 5 additions & 5 deletions docs/sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 33 additions & 11 deletions packages/core/src/config/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
},
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
32 changes: 24 additions & 8 deletions packages/core/src/config/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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: {
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
32 changes: 24 additions & 8 deletions packages/core/src/config/recommended-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Loading

0 comments on commit 498c610

Please sign in to comment.