Skip to content

Conversation

@shakrav2
Copy link
Contributor

Summary

Implements linting rules for AEP-126 (Enumerations) to validate enum field usage in OpenAPI specifications.

Closes #58

Rules Added

This PR adds 6 new linting rules:

  1. aep-126-enum-type-string (error) - Enums must use type: string, not integer or number
  2. aep-126-enum-case-consistent (warn) - All enum values must use consistent case formatting
  3. aep-126-enum-null-first (warn) - Nullable enums must have null as the first value
  4. aep-126-enum-nullable-declaration (error) - Enums containing null must declare nullable: true
  5. aep-126-no-standard-value-enums (warn) - Warns against enumerating standard codes (ISO 639, ISO 3166, ISO 4217, IANA)
  6. aep-126-enum-has-description (info) - Enum fields should include a description

Implementation Details

  • Custom Functions: 4 new Spectral functions in functions/aep-126-*.js
  • Tests: 38 test cases across 6 test files in test/0126/
  • Documentation: Complete rule documentation in docs/0126.md
  • JSONPath Pattern: Uses parent selector $..[?(@property === 'enum')]^ to safely handle enums containing null values

Test Results

38/38 tests passing (100%)
Code coverage: 80-85% for all custom functions
Linter: All checks passing

Testing

```bash
npm test -- --testPathPattern=0126
```

Checklist

  • All 6 rules implemented in `aep/0126.yaml`
  • Custom functions created with proper error handling
  • Comprehensive tests written (38 tests)
  • Documentation added in `docs/0126.md`
  • `spectral.yaml` and `docs/rules.md` updated
  • All tests passing
  • Code coverage >80%
  • Linter passing

- Replace pattern match with schema function to handle both scalar and array types
- Add support for OAS 3.1 type: ['string', 'null'] syntax
- Add test cases for OAS 3.1 nullable enums
- Fixes critical bug where OAS 3.1 specs would fail with runtime error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement rules for AEP-126: Enumerations

1 participant