|
| 1 | +rules: |
| 2 | + # Custom rules specific to Xero APIs |
| 3 | + xero-info-required-fields: |
| 4 | + description: "Ensure required info fields are present" |
| 5 | + given: "$.info" |
| 6 | + severity: error |
| 7 | + then: |
| 8 | + - field: "title" |
| 9 | + function: truthy |
| 10 | + - field: "version" |
| 11 | + function: truthy |
| 12 | + - field: "termsOfService" |
| 13 | + function: truthy |
| 14 | + - field: "contact" |
| 15 | + function: truthy |
| 16 | + |
| 17 | + xero-contact-required-fields: |
| 18 | + description: "Ensure contact has required fields" |
| 19 | + given: "$.info.contact" |
| 20 | + severity: error |
| 21 | + then: |
| 22 | + - field: "name" |
| 23 | + function: truthy |
| 24 | + - field: "email" |
| 25 | + function: truthy |
| 26 | + - field: "url" |
| 27 | + function: truthy |
| 28 | + |
| 29 | + xero-servers-required: |
| 30 | + description: "Ensure servers are defined" |
| 31 | + given: "$" |
| 32 | + severity: error |
| 33 | + then: |
| 34 | + field: "servers" |
| 35 | + function: truthy |
| 36 | + |
| 37 | + xero-server-description: |
| 38 | + description: "Each server should have a description" |
| 39 | + given: "$.servers[*]" |
| 40 | + severity: warn |
| 41 | + then: |
| 42 | + field: "description" |
| 43 | + function: truthy |
| 44 | + |
| 45 | + xero-operation-summary: |
| 46 | + description: "Operations should have summaries" |
| 47 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace]" |
| 48 | + severity: warn |
| 49 | + then: |
| 50 | + field: "summary" |
| 51 | + function: truthy |
| 52 | + |
| 53 | + xero-operation-id: |
| 54 | + description: "Operations must have operationId" |
| 55 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace]" |
| 56 | + severity: error |
| 57 | + then: |
| 58 | + field: "operationId" |
| 59 | + function: truthy |
| 60 | + |
| 61 | + xero-operation-tags: |
| 62 | + description: "Operations should have tags" |
| 63 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace]" |
| 64 | + severity: warn |
| 65 | + then: |
| 66 | + field: "tags" |
| 67 | + function: truthy |
| 68 | + |
| 69 | + xero-operation-security: |
| 70 | + description: "Operations should have security defined" |
| 71 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace]" |
| 72 | + severity: info |
| 73 | + then: |
| 74 | + field: "security" |
| 75 | + function: truthy |
| 76 | + |
| 77 | + xero-response-200-description: |
| 78 | + description: "200 responses should have descriptions" |
| 79 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace].responses.200" |
| 80 | + severity: warn |
| 81 | + then: |
| 82 | + field: "description" |
| 83 | + function: truthy |
| 84 | + |
| 85 | + xero-schema-properties-description: |
| 86 | + description: "Schema properties should have descriptions for better documentation" |
| 87 | + given: "$.components.schemas[*].properties[*]" |
| 88 | + severity: info |
| 89 | + then: |
| 90 | + field: "description" |
| 91 | + function: truthy |
| 92 | + |
| 93 | + xero-openapi-version: |
| 94 | + description: "Should use OpenAPI 3.0.0 or higher" |
| 95 | + given: "$.openapi" |
| 96 | + severity: error |
| 97 | + then: |
| 98 | + function: pattern |
| 99 | + functionOptions: |
| 100 | + match: "^3\\.[0-9]+\\.[0-9]+$" |
| 101 | + |
| 102 | + xero-path-parameters: |
| 103 | + description: "Path parameters should be properly defined" |
| 104 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace].parameters[?(@.in === 'path')]" |
| 105 | + severity: error |
| 106 | + then: |
| 107 | + - field: "name" |
| 108 | + function: truthy |
| 109 | + - field: "required" |
| 110 | + function: truthy |
| 111 | + - field: "schema" |
| 112 | + function: truthy |
| 113 | + |
| 114 | + xero-consistent-error-responses: |
| 115 | + description: "Should have consistent error response structure" |
| 116 | + given: "$.paths[*][get,post,put,patch,delete,head,options,trace].responses[?(@property >= '400')]" |
| 117 | + severity: info |
| 118 | + then: |
| 119 | + field: "description" |
| 120 | + function: truthy |
0 commit comments