11extends :
2- - " spectral:oas"
3- - " @stoplight/spectral-owasp-ruleset"
2+ - " spectral:oas" # Base OpenAPI validation
3+ - " @stoplight/spectral-owasp-ruleset" # OWASP API security ruleset
44
55rules :
6+ # Custom rules specific to Xero APIs
67 xero-info-required-fields :
78 description : " Ensure required info fields are present"
89 given : " $.info"
1617 function : truthy
1718 - field : " contact"
1819 function : truthy
20+
1921 xero-contact-required-fields :
2022 description : " Ensure contact has required fields"
2123 given : " $.info.contact"
@@ -27,62 +29,71 @@ rules:
2729 function : truthy
2830 - field : " url"
2931 function : truthy
32+
3033 xero-servers-required :
3134 description : " Ensure servers are defined"
3235 given : " $"
3336 severity : error
3437 then :
3538 field : " servers"
3639 function : truthy
40+
3741 xero-server-description :
3842 description : " Each server should have a description"
3943 given : " $.servers[*]"
4044 severity : warn
4145 then :
4246 field : " description"
4347 function : truthy
48+
4449 xero-operation-summary :
4550 description : " Operations should have summaries"
4651 given : " $.paths[*][get,post,put,patch,delete,head,options,trace]"
4752 severity : warn
4853 then :
4954 field : " summary"
5055 function : truthy
56+
5157 xero-operation-id :
5258 description : " Operations must have operationId"
5359 given : " $.paths[*][get,post,put,patch,delete,head,options,trace]"
5460 severity : error
5561 then :
5662 field : " operationId"
5763 function : truthy
64+
5865 xero-operation-tags :
5966 description : " Operations should have tags"
6067 given : " $.paths[*][get,post,put,patch,delete,head,options,trace]"
6168 severity : warn
6269 then :
6370 field : " tags"
6471 function : truthy
72+
6573 xero-operation-security :
6674 description : " Operations should have security defined"
6775 given : " $.paths[*][get,post,put,patch,delete,head,options,trace]"
6876 severity : info
6977 then :
7078 field : " security"
7179 function : truthy
80+
7281 xero-response-200-description :
7382 description : " 200 responses should have descriptions"
7483 given : " $.paths[*][get,post,put,patch,delete,head,options,trace].responses.200"
7584 severity : warn
7685 then :
7786 field : " description"
7887 function : truthy
88+
7989 xero-schema-properties-description :
8090 description : " Schema properties should have descriptions for better documentation"
8191 given : " $.components.schemas[*].properties[*]"
8292 severity : off
8393 then :
8494 field : " description"
8595 function : truthy
96+
8697 xero-openapi-version :
8798 description : " Should use OpenAPI 3.0.0 or higher"
8899 given : " $.openapi"
@@ -91,6 +102,7 @@ rules:
91102 function : pattern
92103 functionOptions :
93104 match : " ^3\\ .[0-9]+\\ .[0-9]+$"
105+
94106 xero-path-parameters :
95107 description : " Path parameters should be properly defined"
96108 given : " $.paths[*][get,post,put,patch,delete,head,options,trace].parameters[?(@.in === 'path')]"
@@ -102,44 +114,48 @@ rules:
102114 function : truthy
103115 - field : " schema"
104116 function : truthy
117+
105118 xero-consistent-error-responses :
106119 description : " Should have consistent error response structure"
107120 given : " $.paths[*][get,post,put,patch,delete,head,options,trace].responses[?(@property >= '400')]"
108121 severity : info
109122 then :
110123 field : " description"
111124 function : truthy
112- operation-description : off
113- operation-tags : off
114- oas3-schema : warn
125+ operation-description : off # Disable operation description rule for now
126+ operation-tags : off # Disable operation tags rule for now
127+ oas3-schema : warn # Re-enable schema validation with reduced severity
115128 info-contact :
116- severity : warn
117- given : $.info.contact
129+ severity : warn # Re-enabled with reduced severity
130+ given : $.info.contact # Scope: info.contact field
118131 then :
119- function : truthy
132+ function : truthy # Ensure the field is truthy
120133 info-license :
121- severity : warn
122- given : $.info.license
134+ severity : warn # Re-enabled with reduced severity
135+ given : $.info.license # Scope: info.license field
123136 then :
124- function : truthy
125- owasp:api2:2023-no-http-basic : off
126- owasp:api4:2023-string-limit : off
127- owasp:api4:2023-array-limit : off
128- owasp:api4:2023-integer-limit-legacy : off
129- owasp:api4:2023-rate-limit : off
130- owasp:api2:2023-jwt-best-practices : off
131- owasp:api8:2023-define-error-responses-401 : off
132- owasp:api8:2023-define-error-responses-500 : off
133- owasp:api4:2023-rate-limit-responses-429 : off
134- oas3-valid-media-example : off
135- owasp:api4:2023-integer-format : off
136- no-$ref-siblings : off
137- oas3-valid-schema-example : off
138- owasp:api9:2023-inventory-access : off
139- owasp:api9:2023-inventory-environment : off
140- owasp:api2:2023-short-lived-access-tokens : off
141- owasp:api8:2023-define-error-validation : off
142- operation-tag-defined : off
143- owasp:api4:2023-string-restricted : off
144- path-params : off
145- owasp:api8:2023-define-cors-origin : off
137+ function : truthy # Ensure the field is truthy
138+
139+
140+ # OWASP Rules
141+ owasp:api2:2023-no-http-basic : off # Disable HTTP Basic authentication rule
142+ owasp:api4:2023-string-limit : off # Disable string length limit checks
143+ owasp:api4:2023-array-limit : off # Disable array size limit checks
144+ owasp:api4:2023-integer-limit-legacy : off # Disable integer limit checks
145+ owasp:api4:2023-rate-limit : off # Disable rate limiting headers check
146+ owasp:api2:2023-jwt-best-practices : off # Disable JWT best practices check
147+ owasp:api8:2023-define-error-responses-401 : off # Disable missing 401 response rule
148+ owasp:api8:2023-define-error-responses-500 : off # Disable missing 500 response rule
149+ owasp:api4:2023-rate-limit-responses-429 : off # Disable missing 429 rate limit response rule
150+ oas3-valid-media-example : off # Disable media example validation
151+ owasp:api4:2023-integer-format : off # Disable integer format validation
152+ no-$ref-siblings : off # Disable $ref sibling validation
153+ oas3-valid-schema-example : off # Disable schema example validation
154+ owasp:api9:2023-inventory-access : off # Disable server audience declaration rule
155+ owasp:api9:2023-inventory-environment : off # Disable server environment declaration rule
156+ owasp:api2:2023-short-lived-access-tokens : off # Disable short-lived access tokens rule
157+ owasp:api8:2023-define-error-validation : off # Disable missing error response validation rule
158+ operation-tag-defined : off # Disable operation tags defined in global tags rule
159+ owasp:api4:2023-string-restricted : off # Disable string restricted rule to address warnings
160+ path-params : off # Disable path parameter validation to address mapping key issues
161+ owasp:api8:2023-define-cors-origin : off # Disable CORS origin header requirement
0 commit comments