File tree Expand file tree Collapse file tree 5 files changed +40
-3
lines changed Expand file tree Collapse file tree 5 files changed +40
-3
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,14 @@ List:
210
210
211
211
**Severity**: warning
212
212
213
+ # ## rhoas-external-$ref
214
+
215
+ ` $ref` values cannot be a relative path to an external file. Please use the absolute URL or convert it to an internal `$ref`.
216
+
217
+ **Recommended**: Yes
218
+
219
+ **Severity**: error
220
+
213
221
# # Development
214
222
215
223
> NOTE: This project uses [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) for easier development.
Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ paths:
23
23
application/json :
24
24
schema :
25
25
$ref : ' #/components/schemas/Error'
26
+ " 400 " :
27
+ description : br
28
+ content :
29
+ application/json :
30
+ schema :
31
+ $ref : ' openapi-invalid.yaml#/components/schemas/Error'
26
32
/api/foo_mgmt/v1beta/foos/{id} :
27
33
get :
28
34
operationId : getFooById
@@ -90,4 +96,4 @@ components:
90
96
Bearer :
91
97
scheme : ' bearer'
92
98
bearerFormat : ' JWT'
93
- type : ' http'
99
+ type : ' http'
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @rhoas/spectral-ruleset" ,
3
- "version" : " 0.1.1 " ,
3
+ "version" : " 0.1.2 " ,
4
4
"description" : " Spectral ruleset" ,
5
5
"private" : false ,
6
6
"main" : " ruleset.yaml" ,
Original file line number Diff line number Diff line change @@ -5,10 +5,18 @@ functions:
5
5
- securitySchemes
6
6
- infoLicenseApache2
7
7
- schemaDefinition
8
+ - externalRefs
8
9
rules :
9
10
openapi-tags : off
10
11
operation-tags : off
11
12
13
+ rhoas-external-$ref :
14
+ given : " $..['$ref']"
15
+ severity : error
16
+ type : ' validation'
17
+ resolved : false
18
+ then :
19
+ function : externalRefs
12
20
rhoas-oas3minimum :
13
21
given : " $"
14
22
description : OpenAPI version must be >= 3
@@ -163,4 +171,4 @@ rules:
163
171
required : true
164
172
total :
165
173
type : integer
166
- required : true
174
+ required : true
Original file line number Diff line number Diff line change
1
+ import { IFunctionResult } from "@stoplight/spectral" ;
2
+
3
+ export default ( targetVal : any ) : IFunctionResult [ ] => {
4
+ if ( ! targetVal || ! targetVal . length ) {
5
+ return
6
+ }
7
+
8
+ if ( targetVal . startsWith ( 'https' ) || targetVal . startsWith ( 'http' ) || targetVal . startsWith ( '#/' ) ) {
9
+ return ;
10
+ } else {
11
+ return [ {
12
+ message : 'Only local relative `$ref` or absolute external URL `$ref` is allowed'
13
+ } ]
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments