@luxass/spectral-ruleset 0.0.3 → 0.0.4

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 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,18 @@ var ruleset_default = {
189
251
  },
190
252
  severity: DiagnosticSeverity.Error
191
253
  },
192
- "luxass/oas2-protocol-https-only": {
193
- description: "ALL requests MUST go through `https` protocol only.",
194
- formats: [__stoplight_spectral_formats.oas2],
195
- message: "Schemes MUST be https and no other value is allowed.",
196
- severity: DiagnosticSeverity.Error,
197
- recommended: true,
198
- type: "style",
199
- given: "$",
200
- then: {
201
- field: "schemes",
202
- function: __stoplight_spectral_functions.schema,
203
- functionOptions: { schema: {
204
- type: "array",
205
- items: {
206
- type: "string",
207
- enum: ["https"]
208
- }
209
- } }
210
- }
211
- },
212
- "luxass/oas3-protocol-https-only": {
213
- description: "ALL requests MUST go through `https` protocol only.",
214
- formats: [__stoplight_spectral_formats.oas3],
215
- message: "Schemes MUST be https and no other value is allowed.",
216
- severity: DiagnosticSeverity.Error,
217
- recommended: true,
218
- type: "style",
219
- given: "$.servers..url",
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[*]~",
220
258
  then: {
221
259
  function: __stoplight_spectral_functions.pattern,
222
- functionOptions: { match: "/^https:/" }
223
- }
224
- }
260
+ functionOptions: { notMatch: ".(json|xml|html|txt)$" }
261
+ },
262
+ severity: DiagnosticSeverity.Error
263
+ },
264
+ ...oas2_default,
265
+ ...oas3_default
225
266
  }
226
267
  };
227
268
 
package/dist/ruleset.js CHANGED
@@ -1,6 +1,6 @@
1
- import { oas2, oas3 } from "@stoplight/spectral-formats";
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,18 @@ var ruleset_default = {
165
227
  },
166
228
  severity: DiagnosticSeverity.Error
167
229
  },
168
- "luxass/oas2-protocol-https-only": {
169
- description: "ALL requests MUST go through `https` protocol only.",
170
- 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: schema,
179
- functionOptions: { schema: {
180
- type: "array",
181
- items: {
182
- type: "string",
183
- enum: ["https"]
184
- }
185
- } }
186
- }
187
- },
188
- "luxass/oas3-protocol-https-only": {
189
- description: "ALL requests MUST go through `https` protocol only.",
190
- formats: [oas3],
191
- message: "Schemes MUST be https and no other value is allowed.",
192
- severity: DiagnosticSeverity.Error,
193
- recommended: true,
194
- type: "style",
195
- given: "$.servers..url",
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[*]~",
196
234
  then: {
197
235
  function: pattern,
198
- functionOptions: { match: "/^https:/" }
199
- }
200
- }
236
+ functionOptions: { notMatch: ".(json|xml|html|txt)$" }
237
+ },
238
+ severity: DiagnosticSeverity.Error
239
+ },
240
+ ...oas2_default,
241
+ ...oas3_default
201
242
  }
202
243
  };
203
244
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/spectral-ruleset",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Opinonated ruleset for Spectral",
5
5
  "type": "module",
6
6
  "repository": {