Skip to content

AEP-0143 Linter Rules

This document covers the linting rules for AEP-143, which provides guidance on using standardized codes for common concepts like languages, regions, currencies, and time zones.

aep-143-standardized-codes

Rule: Field names for standardized codes must follow AEP-143 conventions.

This rule enforces that field names use the correct standardized terminology for common concepts like languages, currencies, regions, and media types.

This rule checks schema property names and flags incorrect variants, suggesting the correct standardized field name according to AEP-143.

This rule uses a map-based detection approach that only catches explicitly listed field name variants. While it covers the most common incorrect naming patterns, it cannot detect all possible variations developers might use.

What this means:

  • ✅ Catches common mistakes like lang, country, mime_type, etc.
  • ❌ Won’t catch creative variations like user_locale, iso_country, or document_mime
  • ✅ Low false positive rate - only flags known incorrect patterns
  • ❌ May miss some non-standard field names that should use standardized codes

Why this approach:

Pattern-based detection (e.g., flagging any field containing “language” or “country”) would produce too many false positives. The map-based approach is intentionally conservative to maintain high precision.

Recommendation: Use this rule as a first-pass check, but rely on human code review to catch edge cases and uncommon field name variations. If you encounter a common variant that should be flagged, consider contributing it to the linter.

ConceptCorrect Field NameIncorrect VariantsStandard
Languagelanguage_codelang, language, localeIETF BCP-47
Country/Regionregion_codecountry, country_code, regionUnicode CLDR
Currencycurrency_codecurrencyISO-4217
Content/Media Typecontent_typemime, mimetype, mime_type, media_type, mediatypeIANA media types
Time Zonetime_zonetz, timezoneIANA TZ

Incorrect code for this rule:

components:
schemas:
book:
type: object
properties:
title:
type: string
lang: # Should be language_code
type: string
country: # Should be region_code
type: string

Correct code for this rule:

components:
schemas:
book:
type: object
properties:
title:
type: string
language_code:
type: string
description: IETF BCP-47 language code (e.g., en-US, de-CH)
region_code:
type: string
description: Unicode CLDR region code (e.g., US, CH)

If you need to violate this rule, add an override to your Spectral configuration:

overrides:
- files:
- 'openapi.json#/components/schemas/book'
rules:
aep-143-standardized-codes: 'off'
aep-143-standardized-codes-string-type

Rule: Standardized code fields must be of type string.

This rule enforces that all standardized code fields (language_code, region_code, currency_code, content_type, time_zone, utc_offset) use type string.

According to AEP-143, standardized code fields must use the appropriate data type for standard codes (usually string), and should not use enums even if they only allow a small subset of possible values.

This rule checks the following fields:

  • language_code
  • region_code
  • currency_code
  • content_type
  • time_zone
  • utc_offset

Incorrect code for this rule:

components:
schemas:
book:
type: object
properties:
language_code:
type: integer # Wrong type
description: Language code

Correct code for this rule:

components:
schemas:
book:
type: object
properties:
language_code:
type: string
description: IETF BCP-47 language code (e.g., en-US, de-CH)

If you need to violate this rule, add an override to your Spectral configuration:

overrides:
- files:
- 'openapi.json#/components/schemas/book/properties/language_code'
rules:
aep-143-standardized-codes-string-type: 'off'
References