@@ -5,18 +5,6 @@ const SwaggerParser = require('@apidevtools/swagger-parser');
5
5
const { execSync } = require ( 'child_process' ) ;
6
6
const spec = '/Users/ja/Documents/GitHub/docs-v2/api-docs/cloud/v2/ref.yml'
7
7
8
- async function detectCircularRefs ( ) {
9
- try {
10
- const api = await SwaggerParser . validate ( spec ) ;
11
- console . log ( 'API is valid:' , api ) ;
12
- } catch ( err ) {
13
- if ( err . message . includes ( 'Circular $ref pointer found' ) ) {
14
- console . error ( 'Circular reference detected:' , err ) ;
15
- } else {
16
- console . error ( 'API validation failed:' , err ) ;
17
- }
18
- }
19
- }
20
8
21
9
// Function to execute shell commands
22
10
const execCommand = ( command ) => {
@@ -30,15 +18,20 @@ const execCommand = (command) => {
30
18
31
19
function validate ( ) {
32
20
33
- detectCircularRefs ( ) ;
21
+ // detectCircularRefs();
22
+
23
+ // // swagger-cli validate
24
+ // execCommand(`npx swagger-cli validate ${spec}`);
25
+
26
+ // // speccy lint. Treat $ref like JSON schema and convert to OpenAPI Schema Objects.
27
+ // execCommand(`npx speccy lint -j -v ${spec}`);
34
28
35
- // swagger-cli validate
36
- execCommand ( `npx swagger-cli validate ${ spec } ` ) ;
29
+ // execCommand(`npx @redocly/cli lint ${spec}`);
37
30
38
- // speccy lint. Treat $ref like JSON schema and convert to OpenAPI Schema Objects.
39
- execCommand ( `npx speccy lint -j -v ${ spec } ` ) ;
31
+ // Create a Spectral ruleset file
32
+ // Spectral is a flexible JSON/YAML linter, formatter, and style checker for OpenAPI v2, v3.0, v3.1, and AsyncAPI v2.0.
33
+ execCommand ( `npx @stoplight/spectral-cli lint ${ spec } --ruleset ./api-docs/.spectral.yaml` ) ; // --ruleset myruleset.yaml
40
34
41
- execCommand ( `npx @redocly/cli lint ${ spec } ` ) ;
42
35
}
43
36
44
37
validate ( ) ;
0 commit comments