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

Commit 0ed5d7f

Browse files
authored
Merge pull request #80 from AtomLinter/arcanemagus/no-required-quotes
Don't require quotes around version
2 parents 2c3a009 + 2f02da2 commit 0ed5d7f

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let populateRangesForErrors;
99
const idleCallbacks = new Set();
1010

1111
function canValidate(text) {
12-
return text.length > 8 && /"?(swagger|openapi)"?\s*:\s*['"]\d+\.\d+(.\d+)?['"]/g.test(text);
12+
return text.length > 8 && /"?(swagger|openapi)"?\s*:\s*['"]?\d+\.\d+(.\d+)?['"]?/g.test(text);
1313
}
1414

1515
function errorsToLinterMessages(err, path, text) {

spec/fixtures/openapi.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
openapi: 3.0.0
2+
info:
3+
title: Open API Sample
4+
version: 1.0.0
5+
paths:
6+
/todos:
7+
get:
8+
description: "Returns all todo items"
9+
responses:
10+
200:
11+
description: "A list of todo items"
12+
schema:
13+
type: array
14+
items:
15+
type: object
16+
properties:
17+
id:
18+
type: strin
19+
format: uuid
20+
name:
21+
type: string

spec/yaml-files-spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@ describe('Linting YAML files', () => {
1919
await atom.packages.activatePackage('linter-swagger');
2020
});
2121

22+
it('Handles no quotes around version', async () => {
23+
const OPENAPI = join(__dirname, 'fixtures', 'openapi.yaml');
24+
const editor = await atom.workspace.open(OPENAPI);
25+
const messages = await lint(editor);
26+
27+
expect(messages.length).toEqual(2);
28+
expect(messages[0]).toEqual({
29+
severity: 'error',
30+
excerpt: 'Additional properties not allowed: schema',
31+
location: {
32+
file: OPENAPI,
33+
position: [[11, 10], [11, 16]],
34+
},
35+
});
36+
expect(messages[1]).toEqual({
37+
severity: 'error',
38+
excerpt: 'Missing required property: $ref',
39+
location: {
40+
file: OPENAPI,
41+
position: [[11, 10], [11, 16]],
42+
},
43+
});
44+
});
45+
2246
it('Handles correct input with no errors', async () => {
2347
const PETSTORE = join(__dirname, 'fixtures', 'petstore.yaml');
2448
const editor = await atom.workspace.open(PETSTORE);

0 commit comments

Comments
 (0)