|
| 1 | +functionsDir: ../functions |
| 2 | +functions: |
| 3 | + - aep-126-enum-case-consistent |
| 4 | + - aep-126-enum-null-first |
| 5 | + - aep-126-enum-nullable-declaration |
| 6 | + - aep-126-no-standard-value-enums |
| 7 | + |
| 8 | +rules: |
| 9 | + aep-126-enum-type-string: |
| 10 | + description: Enumerated fields should use type string, not integer or other types. |
| 11 | + message: Enum field "{{property}}" should have type "string", not "{{error}}". |
| 12 | + severity: error |
| 13 | + formats: ['oas2', 'oas3'] |
| 14 | + given: $..[?(@property === 'enum')]^ |
| 15 | + then: |
| 16 | + field: type |
| 17 | + function: pattern |
| 18 | + functionOptions: |
| 19 | + match: '^string$' |
| 20 | + |
| 21 | + aep-126-enum-case-consistent: |
| 22 | + description: All enum values in a field should use consistent case format. |
| 23 | + message: '{{error}}' |
| 24 | + severity: warn |
| 25 | + formats: ['oas2', 'oas3'] |
| 26 | + given: $..[?(@property === 'enum')]^ |
| 27 | + then: |
| 28 | + function: aep-126-enum-case-consistent |
| 29 | + |
| 30 | + aep-126-enum-null-first: |
| 31 | + description: If enum is nullable, null should be the first value in the enum array. |
| 32 | + message: '{{error}}' |
| 33 | + severity: warn |
| 34 | + formats: ['oas2', 'oas3'] |
| 35 | + given: $..[?(@property === 'enum')]^ |
| 36 | + then: |
| 37 | + function: aep-126-enum-null-first |
| 38 | + |
| 39 | + aep-126-enum-nullable-declaration: |
| 40 | + description: If enum contains null, field must declare nullable true. |
| 41 | + message: '{{error}}' |
| 42 | + severity: error |
| 43 | + formats: ['oas2', 'oas3'] |
| 44 | + given: $..[?(@property === 'enum')]^ |
| 45 | + then: |
| 46 | + function: aep-126-enum-nullable-declaration |
| 47 | + |
| 48 | + aep-126-no-standard-value-enums: |
| 49 | + description: Fields should not enumerate standard codes (language, country, currency, media types). |
| 50 | + message: '{{error}}' |
| 51 | + severity: warn |
| 52 | + formats: ['oas2', 'oas3'] |
| 53 | + given: $..[?(@property === 'enum')]^ |
| 54 | + then: |
| 55 | + function: aep-126-no-standard-value-enums |
| 56 | + |
| 57 | + aep-126-enum-has-description: |
| 58 | + description: Enum fields should include a description explaining their purpose. |
| 59 | + message: Enum field "{{property}}" should have a description. |
| 60 | + severity: info |
| 61 | + formats: ['oas2', 'oas3'] |
| 62 | + given: $..[?(@property === 'enum')]^ |
| 63 | + then: |
| 64 | + field: description |
| 65 | + function: truthy |
0 commit comments