Skip to content
ADP
API Design PrincipleBETA

[ADP-766] OpenAPI: Country Code Format

Guidance

  • MUST use the ISO 3166-1 alpha-2 standard for country codes.
  • SHOULD use the iso-country-code format for string fields representing country codes.
  • MUST include a clear description for country code fields.
  • SHOULD provide an example value for country code fields.

OpenAPI Schema

Use the following schema for country code fields:

yaml
openapi: 3.1.0
info:
  title: Country Code API
  version: 1.0.0
paths:
  /example:
    get:
      summary: Example endpoint
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CountryCodeResponse'
components:
  schemas:
    CountryCodeResponse:
      type: object
      properties:
        countryCode:
          type: string
          format: iso-country-code
          description: ISO 3166-1 alpha-2 country code
          example: "US"

Reference

Design Reference