Skip to content
Draft
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
65 changes: 0 additions & 65 deletions .github/workflows/megalinter.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/spectral-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Spectral Lint

on:
# Pull Requests to main
pull_request:
branches: [master,main]
push:
branches:
- draft/add-java-script-based-testing-by-spectral # You can specify the branch you want to trigger this on

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install Spectral
run: npm install -g @stoplight/spectral-cli

- name: Install 'nspell' Module
run: npm install nspell && npm install dictionary-en
working-directory: ${{ github.workspace }}

- name: Run Custom Spectral Linting
run: spectral lint code/API_definitions/qod-api.yaml --verbose --ruleset .spectral.yml
# Replace 'openapi.yaml' with the path to your OpenAPI specification file

- name: Run spectral:oas Spectral Linting
run: spectral lint code/API_definitions/qod-api.yaml --verbose --ruleset .spectral-oas.yml
# Replace 'openapi.yaml' with the path to your OpenAPI specification file

- name: Upload Spectral Results
if: always() # Always upload the results, even if linting fails
uses: actions/upload-artifact@v2
with:
name: spectral-results
path: spectral-report.json
2 changes: 2 additions & 0 deletions .spectral-oas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- "spectral:oas"
33 changes: 33 additions & 0 deletions .spectral.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
functions:
- check-spelling-code
functionsDir: "./lint_functions"
rules:
language-spelling-names:
message: "{{error}}"
severity: warn
given:
- "$.paths.*~"
- "$.paths.*.*.parameters[?(@.in==='query' || @.in==='path' || @.in==='cookie')].name"
- "$..properties.*~"
then:
function: check-spelling-code

language-spelling-texts:
message: "{{error}}"
severity: warn
given:
- "$.info.title"
- "$.info.summary"
- "$.info.description"
- "$.paths.*.*.parameters[?(@.in==='query' || @.in==='path' || @.in==='cookie')].description"
- "$..properties.*.description"
then:
function: check-spelling-code

language-spelling-schema-names:
message: "{{error}}"
severity: warn
given:
- "$.components.schemas.*~"
then:
function: check-spelling-code
4 changes: 2 additions & 2 deletions code/API_definitions/qod-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ paths:
- Session notifications callback
summary: "Session notifications callback"
description: |
Important: this endpoint is to be implemented by the API consumer.
Impt: this endpoint is to be implemented by the API consumer.
The QoD server will call this endpoint whenever any network related event occurs.
Currently only QOS_STATUS_CHANGED event is defined.
operationId: postNotification
Expand Down Expand Up @@ -661,7 +661,7 @@ components:
QosProfileName:
description: |
A unique name for identifying a specific QoS profile.
This may follow different formats depending on the service providers implementation.
This may follow difrent formats depending on the service providers implementation.
Some options addresses:
- A UUID style string
- Support for predefined profiles QOS_S, QOS_M, QOS_L, and QOS_E
Expand Down
36 changes: 36 additions & 0 deletions lint_functions/check-spelling-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var dictionary = require('dictionary-en')
var nspell = require('nspell')
var exceptions = ['eventId', 'eventType', 'eventTime', 'eventSubscriptionId', 'publicAddress', 'subnet', 'privateAddress', 'publicPort', 'sessionId', 'UUID', 'devicePorts', 'QoS', 'qosProfile', 'TCP', 'UDP', 'QOS_S', 'QOS_M', 'QOS_L', 'QOS_E', 'webhook', 'notificationUrl', 'notificationAuthToken', 'startedAt', 'expiresAt', 'qosprofiles', 'minDuration', 'maxDuration', 'packetDelayBudget', 'oneway', 'endtoend', 'jitter', 'roundtrip', 'ITU', 'eg', 'realtime', 'packetErrorLossRate', 'QCI', 'maxDownstreamRate', 'QOS_STATUS_CHANGED', 'qosStatus', 'statusInfo', 'DURATION_EXPIRED', 'Enduser', 'IoT', 'sensorsactuators', 'phoneNumber', 'networkAccessIdentifier', 'MNO', 'invoker', 'MNOs', 'MSISDN', 'GPSI', 'IdentifierDomain', 'DNS', 'ie', 'applicationServerPorts', 'maxDownstreamBurstRate', 'maxUpstreamRate', 'QoD', 'cmunication', 'QualityOnDemand', 'Telco', 'indepth', 'Telecom', 'VRGaming', 'backend', 'OverviewhttpsrawgithubusercontentcomcamaraprojectQualityOnDemandmaindocumentationAPI_documentationresourcesQoD_latency_overviewPNG', 'QOD', 'OAuth', 'andor', 'AppFlow', 'portranges', 'AppFlows', 'portportranges', 'Appflow', 'br', 'APIhttpsrawgithubusercontentcomcamaraprojectQualityOnDemandmaindocumentationAPI_documentationresourcesQoD_detailsPNG', 'CAMARA', 'DRAFThttpsgithubcomcamaraprojectQualityOnDemandblobmaindocumentationAPI_documentationQoSProfile_Mapping_Tablemd', 'IETF', 'addressmask', 'applicationServer', 'dottedquad', 'sessionssessionId', 'createSession', 'targetMinUpstreamRate', 'SessionId', 'SessionInfo', 'EventNotification', 'PhoneNumber', 'QosStatus', 'EventQosStatus', 'ErrorInfo', 'GBR', 'latencysensitive', 'DOCSIS', 'maxUpstreamBurstRate', 'targetMinDownstreamRate', 'qosprofilesname', 'RateUnitEnum', 'CreateSession', 'PortsSpec', 'QosProfile', 'QosProfileName', 'TimeUnitEnum', 'QosProfileStatusEnum', 'EventId', 'EventType', 'EventTime', 'QosStatusChangedEvent', 'eventDetail', 'NETWORK_TERMINATED', 'StatusInfo', 'ApplicationServer', 'NetworkAccessIdentifier'];
var separatorsRegex = /\s/;
var mistakes= [];

function includesNumber(value) {
return /\d/.test(value);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default async function (input) {
dictionary ((err, dict) => {
if (err) {
throw err;
}
var spell = nspell(dict)
var no_special_characters= input.replace(/[^\w\s]/gi, '')
const words = no_special_characters.split(separatorsRegex);
var errors= words
.filter((word) => !exceptions.includes(word))
.filter((word) => !spell.correct(word))
.filter((word) => !word == '')
.filter((word) => !includesNumber(word));

if ((errors.length > 0) && (mistakes[mistakes.length-1] != errors[errors.length-1])) {
mistakes.push(errors);
errors = [];
console.log("There was a spelling mistake: " + mistakes);
}
})
sleep(150000).then(() => {return [{
message: `Spelling mistakes found: ${mistakes.join(', ')}`,
}];});
};
30 changes: 30 additions & 0 deletions spell-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const spellChecker = require('spellchecker');

function findSpellingMistakesInYamlFile(filePath) {
// Read the content of the YAML file
const yamlContent = fs.readFileSync(filePath, 'utf8');

// Split the content into words (split by spaces, newlines, etc.)
const words = yamlContent.split(/\s+/);

// Filter out any words that should be excluded from spell checking
const exceptions = ["bic", "datetime", "gt", "gte", "icontains", "iban", "idempotency", "isnull", "lt", "lte", "md5", "mimetype", "oid", "userpic"];
const filteredWords = words.filter((word) => !exceptions.includes(word.toLowerCase()));

// Find spelling mistakes
const mistakes = filteredWords.filter((word) => spellChecker.isMisspelled(word));

return mistakes;
}

// Example usage:
const filePath = 'code/API_definitions/qod-api2.yaml';
const spellingMistakes = findSpellingMistakesInYamlFile(filePath);

if (spellingMistakes.length > 0) {
console.log('Spelling mistakes found:');
console.log(spellingMistakes);
} else {
console.log('No spelling mistakes found.');
}