Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
//
// SPDX-License-Identifier: EUPL-1.2

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = async () => {
return {
preset: 'ts-jest',
testPathIgnorePatterns: ['util'],
testEnvironment: 'node',
"extensionsToTreatAsEsm": [".ts"],
transform: {
'.*': ['ts-jest', {useIsolatedModules: true }]
}
};
/** @type {import('jest').Config} */
module.exports = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.ts$': ['ts-jest', {
useESM: true,
tsconfig: 'tsconfig.jest.json'
}],
},
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transformIgnorePatterns: ['/node_modules/'],
testMatch: ['**/tests/unit/**/*.test.ts'],

};
10 changes: 10 additions & 0 deletions jest.integration.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2025 diggsweden/rest-api-profil-lint-processor
//
// SPDX-License-Identifier: EUPL-1.2
const base = require('./jest.config.cjs');

/** @type {import('jest').Config} */
module.exports = {
...base,
testMatch: ['**/tests/integration/**/*.test.ts']
};
39 changes: 25 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
{
"name": "@diggsweden/rest-api-profil-lint-processor",
"version": "v1.0.3-alpha.1",
"main": ".src/app.ts",
"version": "v1.0.0",
"main": "./dist/app.js",
"bin": {
"raplp": "dist/cli.js"
},
"type": "module",
"engines": {
"node": "<=22.15.1"
},
"files": [
"dist",
"README.md",
"GUIDELINES.md",
"document/**"
],
"repository": {
"type": "git",
"url": "git@github.com:diggsweden/rest-api-profil-lint-processor"
},
"description": "A command-line tool to lint OpenAPI v3 definitions using Spectral",
"scripts": {
"clean": "rm -rf dist",
"build": "tsc -p tsconfig.json",
"test": "jest",
"test:integration": "node --experimental-vm-modules ./node_modules/.bin/jest --config jest.integration.config.cjs ",
"prepare": "npm run clean && npm run build",
"prepack": "npm run clean && npm run build",
"start": "node --import=./register.js src/app.ts"
},
"directories": {
Expand All @@ -28,7 +41,8 @@
"jest": "^30.0.4",
"standard-version": "^9.5.0",
"ts-jest": "^29.4.1",
"typescript": "^5.9.2"
"typescript": "^5.9.2",
"ts-node": "^10.9.2"
},
"dependencies": {
"@stoplight/spectral-core": "^1.19.5",
Expand All @@ -42,7 +56,6 @@
"fast-xml-parser": "^4.5.0",
"js-yaml": "^4.1.0",
"path": "^0.12.7",
"ts-node": "^10.9.2",
"yargs": "^17.7.2"
},
"//": [
Expand Down
8 changes: 5 additions & 3 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ description:
- Missing attributes check
- Detect missing or misconfigured attributes in specifications
longDescription: |
REST API-profil - Lint Processor is a command-line tool to lint OpenAPI v3 definitions of the swedish rest api-profile specification using Spectral.
RAP-LP (REST API Profile Lint Processor) is a tool that reviews an OpenAPI specification against the national REST API Profile. The tool identifies syntax errors and deviations from the guidelines, making it easier to quickly find and correct issues.
The tool analyzes the OpenAPI specification and checks that the API follows specific design rules associated with the REST API Profile. Each rule points to a specific part of the OpenAPI specification using a JSON Path Plus expression and verifies whether the values comply with the established rules. If deviations are found, one or more error messages are returned.
In addition to the rules from the REST API Profile, RAP-LP also includes a rule area called Prerequisites. This area encompasses additional rules not included in the profile but based on established best practices for API design. The rules in Prerequisites can help further improve the quality of the API specification by identifying areas for improvement not covered by the national profile.
The first version of RAP-LP is compatible with REST API Profile version 1.2.0, and each new version of the tool will specify which version of the profile it is intended to support.
shortDescription: A linting tool for the swedish rest api-profile specification
developmentStatus: beta
legal:
Expand All @@ -31,8 +34,7 @@ localisation:
localisationReady: false
maintenance:
contacts:
- name: Digg OSPO
- email: 'raplp-maintenance@digg.se'
- name: raplp-maintenance@digg.se
type: internal
name: 'REST API-profil - Lint Processor (RAP-LP)'
platforms:
Expand Down
10 changes: 5 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import * as path from 'node:path';
import { join } from 'path';
import Parsers from '@stoplight/spectral-parsers';
import spectralCore from '@stoplight/spectral-core';
import { importAndCreateRuleInstances, getRuleModules } from './util/ruleUtil.ts'; // Import the helper function
import { importAndCreateRuleInstances, getRuleModules } from './util/ruleUtil.js'; // Import the helper function
import util from 'util';
import { RapLPCustomSpectral } from './util/RapLPCustomSpectral.ts';
import { DiagnosticReport, RapLPDiagnostic } from './util/RapLPDiagnostic.ts';
import { AggregateError } from './util/RapLPCustomErrorInfo.ts';
import { RapLPCustomSpectral } from './util/RapLPCustomSpectral.js';
import { DiagnosticReport, RapLPDiagnostic } from './util/RapLPDiagnostic.js';
import { AggregateError } from './util/RapLPCustomErrorInfo.js';
import chalk from 'chalk';
import { ExcelReportProcessor } from './util/excelReportProcessor.ts';
import { ExcelReportProcessor } from './util/excelReportProcessor.js';

declare var AggregateError: {
prototype: AggregateError;
Expand Down
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node
// SPDX-FileCopyrightText: 2025 diggsweden/rest-api-profil-lint-processor
//
// SPDX-License-Identifier: EUPL-1.2
import "./app.js";
File renamed without changes.
Loading
Loading