@luxass/spectral-ruleset 0.0.3 → 0.0.5
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/dist/ruleset.cjs +88 -25
- package/dist/ruleset.js +89 -26
- package/package.json +1 -1
package/dist/ruleset.cjs
CHANGED
|
@@ -22,9 +22,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
const __stoplight_spectral_formats = __toESM(require("@stoplight/spectral-formats"));
|
|
26
25
|
const __stoplight_spectral_functions = __toESM(require("@stoplight/spectral-functions"));
|
|
27
26
|
const __stoplight_spectral_rulesets = __toESM(require("@stoplight/spectral-rulesets"));
|
|
27
|
+
const __stoplight_spectral_formats = __toESM(require("@stoplight/spectral-formats"));
|
|
28
28
|
|
|
29
29
|
//#region node_modules/.pnpm/@stoplight+types@14.1.1/node_modules/@stoplight/types/dist/index.mjs
|
|
30
30
|
var HttpOperationSecurityDeclarationTypes;
|
|
@@ -151,6 +151,68 @@ var NodeFormat;
|
|
|
151
151
|
NodeFormat$1["Webp"] = "webp";
|
|
152
152
|
})(NodeFormat || (NodeFormat = {}));
|
|
153
153
|
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/oas2.ts
|
|
156
|
+
var oas2_default = {
|
|
157
|
+
"luxass/oas2/get-request-no-body": {
|
|
158
|
+
message: "A `GET` request MUST NOT accept a request body.",
|
|
159
|
+
description: "Defining a request body on a HTTP GET is technically possible in some implementations, but is increasingly frowned upon due to the confusion that comes from unspecified behavior in the HTTP specification.",
|
|
160
|
+
given: "$.paths..get.parameters..in",
|
|
161
|
+
then: {
|
|
162
|
+
function: __stoplight_spectral_functions.pattern,
|
|
163
|
+
functionOptions: { notMatch: "/^body$/" }
|
|
164
|
+
},
|
|
165
|
+
severity: DiagnosticSeverity.Error,
|
|
166
|
+
formats: [__stoplight_spectral_formats.oas2]
|
|
167
|
+
},
|
|
168
|
+
"luxass/oas2/protocol-https-only": {
|
|
169
|
+
description: "ALL requests MUST go through `https` protocol only.",
|
|
170
|
+
formats: [__stoplight_spectral_formats.oas2],
|
|
171
|
+
message: "Schemes MUST be https and no other value is allowed.",
|
|
172
|
+
severity: DiagnosticSeverity.Error,
|
|
173
|
+
recommended: true,
|
|
174
|
+
type: "style",
|
|
175
|
+
given: "$",
|
|
176
|
+
then: {
|
|
177
|
+
field: "schemes",
|
|
178
|
+
function: __stoplight_spectral_functions.schema,
|
|
179
|
+
functionOptions: { schema: {
|
|
180
|
+
type: "array",
|
|
181
|
+
items: {
|
|
182
|
+
type: "string",
|
|
183
|
+
enum: ["https"]
|
|
184
|
+
}
|
|
185
|
+
} }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/oas3.ts
|
|
192
|
+
var oas3_default = {
|
|
193
|
+
"luxass/oas3/protocol-https-only": {
|
|
194
|
+
description: "ALL requests MUST go through `https` protocol only.",
|
|
195
|
+
formats: [__stoplight_spectral_formats.oas3],
|
|
196
|
+
message: "Schemes MUST be https and no other value is allowed.",
|
|
197
|
+
severity: DiagnosticSeverity.Error,
|
|
198
|
+
recommended: true,
|
|
199
|
+
type: "style",
|
|
200
|
+
given: "$.servers..url",
|
|
201
|
+
then: {
|
|
202
|
+
function: __stoplight_spectral_functions.pattern,
|
|
203
|
+
functionOptions: { match: "/^https:/" }
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"luxass/oas3/get-request-no-body": {
|
|
207
|
+
message: "A `GET` request MUST NOT accept a request body.",
|
|
208
|
+
description: "Defining a request body on a HTTP GET is in some implementations, but is increasingly frowned upon due to the confusion that comes from unspecified behavior in the HTTP specification.",
|
|
209
|
+
given: "$.paths..get.requestBody",
|
|
210
|
+
then: { function: __stoplight_spectral_functions.undefined },
|
|
211
|
+
formats: [__stoplight_spectral_formats.oas3],
|
|
212
|
+
severity: DiagnosticSeverity.Error
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
154
216
|
//#endregion
|
|
155
217
|
//#region src/ruleset.ts
|
|
156
218
|
var ruleset_default = {
|
|
@@ -189,39 +251,40 @@ var ruleset_default = {
|
|
|
189
251
|
},
|
|
190
252
|
severity: DiagnosticSeverity.Error
|
|
191
253
|
},
|
|
192
|
-
"luxass/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
254
|
+
"luxass/no-file-extensions-in-paths": {
|
|
255
|
+
message: "Paths must not include file extensions such as .json, .xml, .html and .txt.",
|
|
256
|
+
description: "Paths must not include file extensions such as `.json`, `.xml`, `.html` and `.txt`. Use the OpenAPI `content` keyword to tell consumers which Media Types are available.",
|
|
257
|
+
given: "$.paths[*]~",
|
|
258
|
+
then: {
|
|
259
|
+
function: __stoplight_spectral_functions.pattern,
|
|
260
|
+
functionOptions: { notMatch: ".(json|xml|html|txt)$" }
|
|
261
|
+
},
|
|
262
|
+
severity: DiagnosticSeverity.Error
|
|
263
|
+
},
|
|
264
|
+
"luxass/paths-kebab-case": {
|
|
265
|
+
description: "All YAML/JSON paths MUST follow kebab-case",
|
|
266
|
+
severity: DiagnosticSeverity.Warning,
|
|
197
267
|
recommended: true,
|
|
198
|
-
|
|
199
|
-
given: "
|
|
268
|
+
message: "{{property}} is not kebab-case: {{error}}",
|
|
269
|
+
given: "$.paths[*]~",
|
|
200
270
|
then: {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
functionOptions: { schema: {
|
|
204
|
-
type: "array",
|
|
205
|
-
items: {
|
|
206
|
-
type: "string",
|
|
207
|
-
enum: ["https"]
|
|
208
|
-
}
|
|
209
|
-
} }
|
|
271
|
+
function: __stoplight_spectral_functions.pattern,
|
|
272
|
+
functionOptions: { match: "^/([a-z0-9]+(-[a-z0-9]+)*)?(/[a-z0-9]+(-[a-z0-9]+)*|/{.+})*$" }
|
|
210
273
|
}
|
|
211
274
|
},
|
|
212
|
-
"luxass/
|
|
213
|
-
description: "
|
|
214
|
-
formats: [__stoplight_spectral_formats.oas3],
|
|
215
|
-
message: "Schemes MUST be https and no other value is allowed.",
|
|
275
|
+
"luxass/headers-hyphenated-pascal-case": {
|
|
276
|
+
description: "All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation",
|
|
216
277
|
severity: DiagnosticSeverity.Error,
|
|
217
278
|
recommended: true,
|
|
218
|
-
|
|
219
|
-
given: "
|
|
279
|
+
message: "{{property}} is not hyphenated-pascal-case: {{error}}",
|
|
280
|
+
given: "$..parameters[?(@.in == 'header')].name",
|
|
220
281
|
then: {
|
|
221
282
|
function: __stoplight_spectral_functions.pattern,
|
|
222
|
-
functionOptions: { match: "
|
|
283
|
+
functionOptions: { match: "^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$" }
|
|
223
284
|
}
|
|
224
|
-
}
|
|
285
|
+
},
|
|
286
|
+
...oas2_default,
|
|
287
|
+
...oas3_default
|
|
225
288
|
}
|
|
226
289
|
};
|
|
227
290
|
|
package/dist/ruleset.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pattern, schema, truthy } from "@stoplight/spectral-functions";
|
|
1
|
+
import { pattern, schema, truthy, undefined as undefined$1 } from "@stoplight/spectral-functions";
|
|
3
2
|
import { asyncapi, oas } from "@stoplight/spectral-rulesets";
|
|
3
|
+
import { oas2, oas3 } from "@stoplight/spectral-formats";
|
|
4
4
|
|
|
5
5
|
//#region node_modules/.pnpm/@stoplight+types@14.1.1/node_modules/@stoplight/types/dist/index.mjs
|
|
6
6
|
var HttpOperationSecurityDeclarationTypes;
|
|
@@ -127,6 +127,68 @@ var NodeFormat;
|
|
|
127
127
|
NodeFormat$1["Webp"] = "webp";
|
|
128
128
|
})(NodeFormat || (NodeFormat = {}));
|
|
129
129
|
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/oas2.ts
|
|
132
|
+
var oas2_default = {
|
|
133
|
+
"luxass/oas2/get-request-no-body": {
|
|
134
|
+
message: "A `GET` request MUST NOT accept a request body.",
|
|
135
|
+
description: "Defining a request body on a HTTP GET is technically possible in some implementations, but is increasingly frowned upon due to the confusion that comes from unspecified behavior in the HTTP specification.",
|
|
136
|
+
given: "$.paths..get.parameters..in",
|
|
137
|
+
then: {
|
|
138
|
+
function: pattern,
|
|
139
|
+
functionOptions: { notMatch: "/^body$/" }
|
|
140
|
+
},
|
|
141
|
+
severity: DiagnosticSeverity.Error,
|
|
142
|
+
formats: [oas2]
|
|
143
|
+
},
|
|
144
|
+
"luxass/oas2/protocol-https-only": {
|
|
145
|
+
description: "ALL requests MUST go through `https` protocol only.",
|
|
146
|
+
formats: [oas2],
|
|
147
|
+
message: "Schemes MUST be https and no other value is allowed.",
|
|
148
|
+
severity: DiagnosticSeverity.Error,
|
|
149
|
+
recommended: true,
|
|
150
|
+
type: "style",
|
|
151
|
+
given: "$",
|
|
152
|
+
then: {
|
|
153
|
+
field: "schemes",
|
|
154
|
+
function: schema,
|
|
155
|
+
functionOptions: { schema: {
|
|
156
|
+
type: "array",
|
|
157
|
+
items: {
|
|
158
|
+
type: "string",
|
|
159
|
+
enum: ["https"]
|
|
160
|
+
}
|
|
161
|
+
} }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/oas3.ts
|
|
168
|
+
var oas3_default = {
|
|
169
|
+
"luxass/oas3/protocol-https-only": {
|
|
170
|
+
description: "ALL requests MUST go through `https` protocol only.",
|
|
171
|
+
formats: [oas3],
|
|
172
|
+
message: "Schemes MUST be https and no other value is allowed.",
|
|
173
|
+
severity: DiagnosticSeverity.Error,
|
|
174
|
+
recommended: true,
|
|
175
|
+
type: "style",
|
|
176
|
+
given: "$.servers..url",
|
|
177
|
+
then: {
|
|
178
|
+
function: pattern,
|
|
179
|
+
functionOptions: { match: "/^https:/" }
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"luxass/oas3/get-request-no-body": {
|
|
183
|
+
message: "A `GET` request MUST NOT accept a request body.",
|
|
184
|
+
description: "Defining a request body on a HTTP GET is in some implementations, but is increasingly frowned upon due to the confusion that comes from unspecified behavior in the HTTP specification.",
|
|
185
|
+
given: "$.paths..get.requestBody",
|
|
186
|
+
then: { function: undefined$1 },
|
|
187
|
+
formats: [oas3],
|
|
188
|
+
severity: DiagnosticSeverity.Error
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
130
192
|
//#endregion
|
|
131
193
|
//#region src/ruleset.ts
|
|
132
194
|
var ruleset_default = {
|
|
@@ -165,39 +227,40 @@ var ruleset_default = {
|
|
|
165
227
|
},
|
|
166
228
|
severity: DiagnosticSeverity.Error
|
|
167
229
|
},
|
|
168
|
-
"luxass/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
230
|
+
"luxass/no-file-extensions-in-paths": {
|
|
231
|
+
message: "Paths must not include file extensions such as .json, .xml, .html and .txt.",
|
|
232
|
+
description: "Paths must not include file extensions such as `.json`, `.xml`, `.html` and `.txt`. Use the OpenAPI `content` keyword to tell consumers which Media Types are available.",
|
|
233
|
+
given: "$.paths[*]~",
|
|
234
|
+
then: {
|
|
235
|
+
function: pattern,
|
|
236
|
+
functionOptions: { notMatch: ".(json|xml|html|txt)$" }
|
|
237
|
+
},
|
|
238
|
+
severity: DiagnosticSeverity.Error
|
|
239
|
+
},
|
|
240
|
+
"luxass/paths-kebab-case": {
|
|
241
|
+
description: "All YAML/JSON paths MUST follow kebab-case",
|
|
242
|
+
severity: DiagnosticSeverity.Warning,
|
|
173
243
|
recommended: true,
|
|
174
|
-
|
|
175
|
-
given: "
|
|
244
|
+
message: "{{property}} is not kebab-case: {{error}}",
|
|
245
|
+
given: "$.paths[*]~",
|
|
176
246
|
then: {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
functionOptions: { schema: {
|
|
180
|
-
type: "array",
|
|
181
|
-
items: {
|
|
182
|
-
type: "string",
|
|
183
|
-
enum: ["https"]
|
|
184
|
-
}
|
|
185
|
-
} }
|
|
247
|
+
function: pattern,
|
|
248
|
+
functionOptions: { match: "^/([a-z0-9]+(-[a-z0-9]+)*)?(/[a-z0-9]+(-[a-z0-9]+)*|/{.+})*$" }
|
|
186
249
|
}
|
|
187
250
|
},
|
|
188
|
-
"luxass/
|
|
189
|
-
description: "
|
|
190
|
-
formats: [oas3],
|
|
191
|
-
message: "Schemes MUST be https and no other value is allowed.",
|
|
251
|
+
"luxass/headers-hyphenated-pascal-case": {
|
|
252
|
+
description: "All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation",
|
|
192
253
|
severity: DiagnosticSeverity.Error,
|
|
193
254
|
recommended: true,
|
|
194
|
-
|
|
195
|
-
given: "
|
|
255
|
+
message: "{{property}} is not hyphenated-pascal-case: {{error}}",
|
|
256
|
+
given: "$..parameters[?(@.in == 'header')].name",
|
|
196
257
|
then: {
|
|
197
258
|
function: pattern,
|
|
198
|
-
functionOptions: { match: "
|
|
259
|
+
functionOptions: { match: "^[A-Z][a-z0-9]*(-[A-Z][a-z0-9]*)*$" }
|
|
199
260
|
}
|
|
200
|
-
}
|
|
261
|
+
},
|
|
262
|
+
...oas2_default,
|
|
263
|
+
...oas3_default
|
|
201
264
|
}
|
|
202
265
|
};
|
|
203
266
|
|