Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 39c19cd

Browse files
authored
chore: dependency maintenance + removing dead code (#287)
## 🧰 Changes * [x] Drops `@apidevtools/swagger-mehtods` in favor of a hardcoded list of HTTP methods. This list never changes so there's really no need to pull in a separate library for it. * [x] Removing a `node:util.format` export that was never being used.
1 parent 8a5f1f0 commit 39c19cd

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

Diff for: lib/util.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const util = require('util');
33

44
const url = require('@readme/json-schema-ref-parser/lib/util/url');
55

6-
exports.format = util.format;
76
exports.inherits = util.inherits;
87

98
/**

Diff for: lib/validators/spec/openapi.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
const swaggerMethods = require('@apidevtools/swagger-methods');
21
const { ono } = require('@jsdevtools/ono');
32

43
const util = require('../../util');
54

5+
/**
6+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object}
7+
*/
8+
const supportedHTTPMethods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'];
9+
610
module.exports = validateSpec;
711

812
/**
@@ -58,8 +62,7 @@ function validateSpec(api) {
5862
* @param {string} operationIds - An array of collected operationIds found in other paths
5963
*/
6064
function validatePath(api, path, pathId, operationIds) {
61-
// `@apidevtools/swagger-methods` doesn't ship a `trace` method so we need to improvise.
62-
[...swaggerMethods, 'trace'].forEach(operationName => {
65+
supportedHTTPMethods.forEach(operationName => {
6366
const operation = path[operationName];
6467
const operationId = `${pathId}/${operationName}`;
6568

Diff for: lib/validators/spec/swagger.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
const swaggerMethods = require('@apidevtools/swagger-methods');
21
const { ono } = require('@jsdevtools/ono');
32

43
const util = require('../../util');
54

5+
/**
6+
* @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#path-item-object}
7+
*/
8+
const supportedHTTPMethods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch'];
9+
610
const primitiveTypes = ['array', 'boolean', 'integer', 'number', 'string'];
711
const schemaTypes = ['array', 'boolean', 'integer', 'number', 'string', 'object', 'null', undefined];
812

@@ -47,7 +51,7 @@ function validateSpec(api) {
4751
* @param {string} operationIds - An array of collected operationIds found in other paths
4852
*/
4953
function validatePath(api, path, pathId, operationIds) {
50-
swaggerMethods.forEach(operationName => {
54+
supportedHTTPMethods.forEach(operationName => {
5155
const operation = path[operationName];
5256
const operationId = `${pathId}/${operationName}`;
5357

Diff for: package-lock.json

+4-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
"test": "vitest run --coverage"
4747
},
4848
"dependencies": {
49-
"@apidevtools/swagger-methods": "^3.0.2",
5049
"@jsdevtools/ono": "^7.1.3",
5150
"@readme/better-ajv-errors": "^2.1.2",
5251
"@readme/json-schema-ref-parser": "^1.2.0",
@@ -60,7 +59,7 @@
6059
},
6160
"devDependencies": {
6261
"@readme/eslint-config": "^14.1.2",
63-
"@types/node": "^22.10.10",
62+
"@types/node": "^22.12.0",
6463
"@vitest/coverage-v8": "^3.0.4",
6564
"eslint": "^8.56.0",
6665
"openapi-types": "^12.1.3",

0 commit comments

Comments
 (0)