Skip to content

Commit 37cf4f1

Browse files
authored
Tune OpenAPI linters (#3704) (#3740)
(cherry picked from commit d1b88af)
1 parent 859b8e8 commit 37cf4f1

File tree

5 files changed

+62
-7
lines changed

5 files changed

+62
-7
lines changed

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ setup: ## Install dependencies for contrib target
3939
@make clean-dep
4040
@npm install --prefix compiler
4141
@npm install --prefix typescript-generator
42-
@npm install @stoplight/spectral-cli
42+
@npm install @redocly/cli
4343

4444
clean-dep: ## Clean npm dependencies
4545
@rm -rf compiler/node_modules
@@ -64,12 +64,12 @@ overlay-docs: ## Apply overlays to OpenAPI documents
6464
rm output/openapi/elasticsearch-openapi.tmp*.json
6565

6666
lint-docs: ## Lint the OpenAPI documents after overlays
67-
@npx @stoplight/spectral-cli lint output/openapi/elasticsearch-*.examples.json --ruleset .spectral.yaml
67+
@npx @redocly/cli lint "output/openapi/elasticsearch-*.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
6868

69-
lint-docs-errs: ## Lint the OpenAPI documents after overlays and return only errors
70-
@npx @stoplight/spectral-cli lint output/openapi/elasticsearch-*.examples.json --ruleset .spectral.yaml -D
69+
lint-docs-stateful: ## Lint only the elasticsearch-openapi.examples.json file
70+
@npx @redocly/cli lint "output/openapi/elasticsearch-openapi.examples.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
7171

72-
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs-errs ## Pre contribution target
72+
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs ## Pre contribution target
7373

7474
help: ## Display help
7575
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
File renamed without changes.

docs/linters/redocly.yaml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
extends:
2+
- recommended
3+
rules:
4+
# Built-in rules
5+
# Descriptions
6+
parameter-description: warn
7+
tag-description: warn
8+
operation-description: off
9+
# Document info
10+
info-contact: warn
11+
info-license: warn
12+
no-empty-servers: warn
13+
# Examples
14+
no-invalid-media-type-examples:
15+
severity: off
16+
allowAdditionalProperties: false
17+
no-invalid-schema-examples:
18+
severity: warn
19+
allowAdditionalProperties: false
20+
# Operations
21+
operation-operationId: error
22+
operation-operationId-unique: error
23+
operation-operationId-url-safe: warn
24+
operation-summary: warn
25+
# Parameters
26+
path-parameters-defined: warn
27+
# Paths
28+
no-ambiguous-paths: off
29+
no-identical-paths: warn
30+
path-excludes-patterns:
31+
severity: error
32+
patterns:
33+
- ^\/internal
34+
# Responses
35+
operation-4xx-response: off
36+
operation-2xx-response: off
37+
# Schema
38+
struct: error
39+
spec-components-invalid-map-name: off
40+
spec-strict-refs: off
41+
security-defined: off
42+
# Tags
43+
operation-tag-defined: off
44+
tags-alphabetical: off
45+
operation-singular-tag: off
46+
# Custom rules
47+
rule/operation-summary-length:
48+
subject:
49+
type: Operation
50+
property: summary
51+
message: Operation summary must have a minimum of 5 and maximum of 45 characters
52+
severity: warn
53+
assertions:
54+
maxLength: 45
55+
minLength: 5

specification/ccr/forget_follower/examples/response/ForgetFollowerIndexResponseExample1.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
summary:
1+
# summary:
22
description: >
33
A successful response for removing the follower retention leases from the leader index.
44
# type: "response"

specification/ml/delete_model_snapshot/examples/response/MlDeleteModelSnapshotResponseExample1.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
summary:
1+
# summary:
22
description: A successful response when deleting an existing model snapshot.
33
# type: response
44
# response_code: 200

0 commit comments

Comments
 (0)