ADR 0007: OpenAPI 3.1 Canonical Schema Mapping Model
Author: Emir Boyacı • Scope: schema-mappings
1. Context and Problem Statement
Section titled “1. Context and Problem Statement”AirCommerce bridges external distribution protocols (such as IATA NDC 19.2 and 24.x) with downstream Passenger Service Systems (such as IBS iFlyRes) through a canonical internal ONE Order domain model (OrderRetrieveRequest, Order, Passenger, etc.).
Previously, cross-system schema mappings in the architecture portal (src/content/mappings/) were authored in a bespoke YAML format validated by a custom mapping.schema.json. While effective for rendering documentation tables and Mermaid lineage diagrams, the custom YAML format had critical limitations:
- No Type System for Code Generation: The custom
fields:array listed property paths (internal,ndc,external) without JSON Schema types (string,integer,number,boolean,array,format: date). Consequently, standard code generators (openapi-generator,openapi-typescript, Orval) could not generate Java DTOs or TypeScript interfaces from the portal’s definitions. - Flat Dot-Notation Instead of Object Hierarchies: Nested internal properties (such as
userInformation.travelAgency.nameandbookingChannel.channelType) were written as flat dot-delimited strings rather than structured JSON Schema object trees, preventing generators from emitting clean nested classes. - Non-Standard Composition (
uses:): Shared types were linked through a proprietaryuses:array rather than standard JSON Schema$refpointers. - Duplicate Internal Type Projections: Because shared types were previously split by NDC element (
journey.yamlforPaxJourneyandorigin-dest.yamlforOriginDest) rather than by the canonical internal class (Trip), the sametripsproperty was mounted twice onorder-view-rs.yaml, which is invalid in a typed object schema.
2. Decision Drivers
Section titled “2. Decision Drivers”- Multi-Language Code Generation: Enable out-of-the-box generation of strongly-typed Java POJOs/records, TypeScript interfaces, and validation schemas across internal services (
service-converter-ndc192,service-converter-ndc24,business-orchestrator-service,iflyres-connector) using standard OpenAPI 3.1 tooling. - Single Source of Truth: Keep architectural lineage (NDC paths, iFlyRes paths, transformation semantics, ignore reasons, and ubiquitous language glossary terms) co-located with the canonical schema definitions rather than maintaining parallel files.
- Modular Authoring Ergonomics: Preserve small, human-readable per-operation (
operations/*.yaml) and per-shared-type (types/*.yaml) files with concise vendor extensions. - 1-to-Many Projection Support: Allow a single canonical internal class (such as
Trip) or property to project onto multiple NDC or external schema targets without duplicating the internal property definition.
3. Considered Options
Section titled “3. Considered Options”- Option 1: Keep the custom mapping YAML format and maintain a separate OpenAPI repository for code generation.
- Option 2: Keep the custom mapping YAML format (adding a
typeattribute) and transpile it into OpenAPI YAML during build. - Option 3 (Chosen): Author directly in modular OpenAPI 3.1 / JSON Schema YAML files enriched with
x-*vendor extensions, and auto-generate a rootopenapi.yamlbundle for code generators.
4. Decision Outcome
Section titled “4. Decision Outcome”We chose Option 3: authoring directly in modular OpenAPI 3.1 Schema Objects under src/content/mappings/operations/ and src/content/mappings/types/, enriched with structured vendor extensions (x-id, x-internal-type, x-ndc24, x-ndc192, x-external, x-mapping, x-overrides, x-term), and automatically generating src/content/mappings/openapi.yaml during the portal build.
4.1. Visual Architecture Slice
Section titled “4.1. Visual Architecture Slice”4.2. Implementation Mechanics
Section titled “4.2. Implementation Mechanics”1. Modular Schema Layout & Root Bundle (openapi.yaml)
Section titled “1. Modular Schema Layout & Root Bundle (openapi.yaml)”Each file in src/content/mappings/types/*.yaml and src/content/mappings/operations/*.yaml is a valid OpenAPI 3.1 / JSON Schema object definition. During astro:config:setup (npm run build / npm run validate), astro-mappings.ts validates all schemas and writes src/content/mappings/openapi.yaml registering every non-template schema under components.schemas keyed by its canonical internal class name (x-internal-type):
openapi: 3.1.0info: title: AirCommerce Internal Canonical Schema Model version: 1.0.0paths: {}components: schemas: Order: $ref: './operations/order-view-rs.yaml' OrderItem: $ref: './types/order-item.yaml' OrderRetrieveRequest: $ref: './operations/order-retrieve-rq.yaml' Passenger: $ref: './types/passenger.yaml' PaxJourney: $ref: './types/trip.yaml'Template files (template-passenger.yaml, template-mapping.yaml) are excluded from openapi.yaml so downstream code generators only emit production domain models.
2. Root Schema Metadata & 1-to-Many Target Projections
Section titled “2. Root Schema Metadata & 1-to-Many Target Projections”Each schema file declares its canonical class name via x-internal-type and its target protocol bindings via x-ndc24, x-ndc192, and x-external. When a single internal class projects onto multiple target structures (such as PaxJourney mapping to both PaxJourney and OriginDest in NDC), x-ndc24, x-ndc192, or x-external accepts either a single object or an array of target descriptors:
type: objecttitle: PaxJourneyx-id: tripx-internal-type: PaxJourneyx-ndc24: - version: '24.1' type: PaxJourney - version: '24.1' type: OriginDestx-ndc192: - version: '19.2' type: PaxJourney - version: '19.2' type: OriginDestx-external: system: iFlyRes version: N/A type: flightSegmentGroupIDproperties: paxJourneyID: type: string x-ndc24: PaxJourney/PaxJourneyID x-ndc192: PaxJourney/PaxJourneyID x-mapping: transform: constant note: '`FL` plus a counter' origin: type: string x-ndc24: OriginDest/OriginCode x-ndc192: OriginDest/OriginCode x-external: flightSegmentGroupID/firstLeg/boardPoint x-mapping: transform: identity3. Nested Object Properties & Standard $ref Composition
Section titled “3. Nested Object Properties & Standard $ref Composition”Dot-delimited internal paths (userInformation.travelAgency.name) are represented as standard nested JSON Schema object hierarchies so code generators emit clean inner/sub-models, while the portal’s mapping-cache.ts recursively walks properties: to flatten leaf nodes back into userInformation.travelAgency.name for the UI table and Mermaid diagrams:
properties: userInformation: type: object properties: travelAgency: type: object properties: name: type: string x-ndc24: path: Party/Sender/TravelAgency/Name transform: lookup note: 'copied when travel agency values in use' x-ndc192: path: Party/Sender/TravelAgency/Name transform: lookup note: 'copied when travel agency values in use' x-external: path: bookingChannel/channel transform: identityShared types are composed via standard $ref (inside items: for collections or directly on a property for 1:1 references), with prefix paths declared on the mounting property and operation-specific child overrides declared via x-overrides:
travelers: type: array items: $ref: '../types/passenger.yaml' x-ndc24: Response/DataLists/PaxList/Pax x-ndc192: Response/DataLists/PaxList/Pax x-external: guestDetails x-overrides: extra: x-external: path: guestId ignore: '`inventoryId`, `age`, `nameRemark` not written onto `Pax`'5. Pros and Cons of the Options
Section titled “5. Pros and Cons of the Options”Option 1: Separate Custom Mapping YAML and OpenAPI Repository
Section titled “Option 1: Separate Custom Mapping YAML and OpenAPI Repository”- Good: Zero changes required to the existing portal parser.
- Bad: Immediate schema drift between documentation mappings and production Java/TypeScript models; violates single source of truth.
Option 2: Custom Mapping YAML Transpiled to OpenAPI
Section titled “Option 2: Custom Mapping YAML Transpiled to OpenAPI”- Good: Keeps the flat YAML authoring syntax.
- Bad: Requires maintaining a bespoke schema language and custom transpiler; authors lose standard OpenAPI IDE autocompletion, JSON Schema
$refnavigation, and standard linting tools (Spectral, Redocly).
Option 3 (Chosen): Native OpenAPI 3.1 YAML with Vendor Extensions
Section titled “Option 3 (Chosen): Native OpenAPI 3.1 YAML with Vendor Extensions”- Good: 100% compliant with OpenAPI 3.1 and JSON Schema tooling out of the box. Directly consumable by
openapi-generator(Java Spring/POJOs) andopenapi-typescript. Enforces explicit property types and clean object hierarchies while retaining all portal mapping visualization features. - Bad: Slightly deeper YAML indentation when modeling multi-level nested objects (
type: object->properties:).
6. Validation and Verification Strategy
Section titled “6. Validation and Verification Strategy”- Build-Time Schema & Semantic Validation:
astro-mappings.tsandmapping-cache.tsvalidate every OpenAPI mapping file duringnpm run validateandnpm run build, checking JSON Schema types,$refresolution, cycle detection, NDC version consistency across$refclosures, and ontology term existence (x-term). - Generated Meta-Schema (
mapping.schema.json):astro-mappings.tsgenerates an updated JSON Schema for IDE YAML language-server validation of OpenAPI properties andx-*vendor extensions. - Automated Unit Tests: Vitest suites (
tests/mappings.test.ts) verify$refexpansion, nested property flattening,x-overridesprecedence, coverage calculation, and rootopenapi.yamlgeneration.
7. Migration and Rollout Consequences
Section titled “7. Migration and Rollout Consequences”- Portal Migration: All shared types in
src/content/mappings/types/*.yamland operations insrc/content/mappings/operations/*.yamlare migrated to OpenAPI 3.1 Schema Objects, andjourney.yaml+origin-dest.yamlare consolidated intotypes/trip.yaml(Trip). - Downstream Code Generation: Internal services can point
openapi-generator-maven-pluginoropenapi-typescriptdirectly atsrc/content/mappings/openapi.yamlto generate canonical DTOs.
8. Links and Traceability
Section titled “8. Links and Traceability”- Related Portal Section: Schema Mappings
- Affected Service: NDC 19.2 Converter Service
- Affected Service: NDC 24 Converter Service
- Affected Service: Business Orchestrator Service
- Affected Service: iFlyRes Connector