Loading…
Loading…
Describes how the platform stores, retrieves, and updates OpenAPI specification artifacts for service versions, detailing the underlying data models and
The OpenAPI Repository is a data access component responsible for the persistence and retrieval of OpenAPI specification artifacts. It serves as the interface between the platform's administrative services and the underlying database tables that store service configuration and generated OpenAPI documents.
This component solves the problem of centralizing data access for the OpenAPI generation process. When the platform generates an OpenAPI specification for a service version, it requires a comprehensive snapshot of all enabled operations and their extensive configuration overrides. The repository provides methods to query this data efficiently. It also handles the transactional insertion and updating (upsert) of the final generated OpenAPI JSON artifact, linking it to the corresponding service version.
The primary consumer of this repository is the platform's OpenAPI generator. The generator calls methods like findEnabledOperations, findOperationFaults, and findOperationHeaders to gather all necessary inputs. After generating the specification, it calls upsertArtifact to store the result in the s2r_openapi_artifact table.
The repository's main function is to aggregate all configuration data related to a service version and its operations, and to persist the generated OpenAPI artifact.
To generate an OpenAPI specification, the generator requires a complete picture of the service. The repository provides several methods to build this picture by querying multiple database tables. The data is intentionally fetched in separate, targeted queries to keep data structures manageable and to ensure backward compatibility with older database schemas.
The process follows these steps:
findServiceVersion to retrieve basic information about the service version, such as its name, key, and environment.findEnabledOperations. This method executes a complex query that joins the s2r_operation and s2r_operation_mapping tables. It gathers all enabled operations for a version and includes a wide array of operation-level and field-level configuration overrides. These overrides control behaviors like data type transformations, null handling, error shaping, and more. The result is a list of OperationSnapshot records.findOperationFaults to load WSDL-defined SOAP fault structures from the s2r_wsdl_operation_catalog table. This data is keyed by the SOAP operation name and allows the generator to create specific error response schemas for each operation, rather than a single generic one. This query is separate from findEnabledOperations to avoid complicating the OperationSnapshot record.findOperationHeaders is called to load WSDL-defined SOAP header declarations from the s2r_operation table. This allows the generator to document any required SOAP headers for each operation.The generator service is responsible for merging the data from these separate calls to build the final OpenAPI specification.
flowchart TD
subgraph OpenAPI Generation Service
A[Start Generation for Service Version]
J[Merge Configuration Data]
K[Generate OpenAPI JSON]
end
subgraph OpenAPI Repository
B[findServiceVersion]
C[findEnabledOperations]
D[findOperationFaults]
E[findOperationHeaders]
L[upsertArtifact]
end
subgraph Platform Database
F[Service & Version Tables]
G[Operation & Mapping Tables]
H[WSDL Catalog Table]
M[OpenAPI Artifact Table]
end
A --> B
A --> C
A --> D
A --> E
B --> F
C --> G
D --> H
E --> G
F --> B
G --> C
H --> D
G --> E
B --> J
C --> J
D --> J
E --> J
J --> K
K --> L
L --> MOnce the OpenAPI JSON is generated, it is persisted using the upsertArtifact method. This method performs two main actions within a single database transaction:
s2r_openapi_artifact table. It uses an INSERT ... ON CONFLICT statement, keyed on service_version_id, to ensure that each service version has at most one associated OpenAPI artifact.s2r_service_version table, setting the openapi_sha256 and openapi_generated_at columns to link the service version to the newly stored artifact.This transactional approach guarantees that the artifact and the service version's link to it are always consistent.
The OpenApiRepository class exposes the following public methods.
findServiceVersionRetrieves a snapshot of metadata for a specific service version.
serviceId (UUID): The ID of the service.versionId (UUID): The ID of the service version.Optional<ServiceVersionSnapshot> containing the service version details, or Optional.empty() if not found.findEnabledOperationsRetrieves a list of all enabled operations for a given service version, including all configuration overrides for the OpenAPI generator.
versionId (UUID): The ID of the service version.List<OperationSnapshot> containing the detailed configuration for each enabled operation. Returns an empty list if no enabled operations are found.findOperationFaultsRetrieves WSDL-defined wsdl:fault contracts for all operations in a service version. This data is used to generate specific error response schemas.
versionId (UUID): The ID of the service version.Map<String, List<WsdlOperationFaultRecord>> where the key is the soap_operation_name and the value is a list of its declared fault records. Returns an empty map if no faults are defined or if the underlying database schema does not support this feature.findOperationHeadersRetrieves WSDL-defined soap:header declarations for all enabled operations in a service version.
versionId (UUID): The ID of the service version.Map<String, List<WsdlOperationHeaderRecord>> where the key is the soap_operation_name and the value is a list of its declared header records. Returns an empty map if no headers are declared or if the underlying database schema does not support this feature.upsertArtifactInserts a new OpenAPI artifact or updates an existing one for a given service version. This operation is transactional.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
serviceId | UUID | Yes | — | The ID of the service. |
versionId | UUID | Yes | — | The ID of the service version. |
openapiJson | String | Yes | — | The full content of the generated OpenAPI specification in JSON format. |
sha256 | String | Yes | — | The SHA-256 hash of the openapiJson content. |
actor | String | No | "system" | The identifier of the user or process that triggered the generation. If null or blank, defaults to "system". |
generatedAt | OffsetDateTime | Yes | — | The timestamp when the artifact was generated. |
OpenApiArtifactRecord representing the newly created or updated artifact record from the database.listAllArtifactKeysLists the unique key pairs (serviceId, serviceVersionId) for all existing OpenAPI artifacts.
List<ArtifactKey> containing all artifact keys, ordered by their generation timestamp in ascending order.findArtifactRetrieves a single, complete OpenAPI artifact record, including its JSON content.
serviceId (UUID): The ID of the service.versionId (UUID): The ID of the service version.Optional<OpenApiArtifactRecord> containing the full artifact record, or Optional.empty() if not found.The repository methods return records that encapsulate data from the database.
ServiceVersionSnapshotBasic metadata about a service version.
| Field | Type | Description |
|---|---|---|
serviceId | UUID | The unique identifier of the service. |
serviceVersionId | UUID | The unique identifier of the service version. |
versionNo | int | The version number. |
serviceKey | String | A short, unique key for the service. |
serviceName | String | The human-readable name of the service. |
environment | String | The deployment environment (e.g., "production"). |
description | String | A description of the service. |
direction | String | The service direction, normalized. |
OpenApiArtifactRecordRepresents a stored OpenAPI artifact.
| Field | Type | Description |
|---|---|---|
id | UUID | The unique identifier of the artifact record. |
serviceId | UUID | The ID of the associated service. |
serviceVersionId | UUID | The ID of the associated service version. |
sha256 | String | The SHA-256 hash of the openapiJson content. |
generatedAt | OffsetDateTime | The timestamp when the artifact was generated. |
generatedBy | String | The actor who generated the artifact. |
openapiJson | String | The full JSON content of the OpenAPI specification. |
OperationSnapshotA comprehensive record of an operation's configuration, used as input for the OpenAPI generator. A null value for any ...Override field typically means the operation inherits the system-level default setting.
| Field | Type | Description |
|---|---|---|
operationKey | String | A short, unique key for the operation. |
soapOperationName | String | The name of the operation as defined in the WSDL. |
soapAction | String | The SOAPAction value for the operation. |
restMethod | String | The HTTP method (e.g., POST) for the generated REST endpoint. |
restPath | String | The path for the generated REST endpoint. |
requestSchema | String | The JSON representation of the request body schema. |
responseSchema | String | The JSON representation of the response body schema. |
timeoutMs | int | The operation-specific timeout in milliseconds. |
retryCount | int | The operation-specific retry count. |
nullHandlingRequestOverride | String | Operation-level override for null handling in requests. |
requestFieldNullHandling | Map<String, String> | Per-field overrides for null handling in requests, mapping a SOAP XPath to a handling mode. |
nullHandlingResponseOverride | String | Operation-level override for null handling in responses. |
responseFieldNullHandling | Map<String, String> | Per-field overrides for null handling in responses, mapping a SOAP XPath to a handling mode. |
booleanHandlingOverride | String | Operation-level override for boolean value representation (e.g., as-bool, as-int). |
requestFieldBooleanHandling | Map<String, String> | Per-field overrides for boolean handling in requests. |
responseFieldBooleanHandling | Map<String, String> | Per-field overrides for boolean handling in responses. |
numericHandlingOverride | String | Operation-level override for numeric value representation (e.g., as-number, as-string). |
responseFieldNumericHandling | Map<String, String> | Per-field overrides for numeric handling in responses. |
integerRangeBoundsOverride | String | Operation-level override for emitting integer range bounds (min/max) in the schema (e.g., emit, omit). |
responseFieldIntegerRangeBounds | Map<String, String> | Per-field overrides for emitting integer range bounds in responses. |
datetimeFormatOverride | String | Operation-level override for date-time formatting (e.g., epoch-millis, custom). |
datetimeCustomPatternOverride | String | The custom pattern to use when datetimeFormatOverride is custom. |
datetimeTimezoneOverride | String | Operation-level override for the date-time timezone. |
datetimeLocalTimezoneOverride | String | Operation-level override for the local date-time timezone. |
datetimeNullModeOverride | String | Operation-level override for representing null date-times (e.g., omit, null). |
responseFieldDatetimeHandling | Map<String, Object> | Per-field overrides for date-time handling in responses. Values can be a format string or a structured object with format details. |
durationHandlingOverride | String | Operation-level override for duration formatting. |
responseFieldDurationHandling | Map<String, String> | Per-field overrides for duration handling in responses. |
binaryHandlingOverride | String | Operation-level override for binary data encoding. |
responseFieldBinaryHandling | Map<String, String> | Per-field overrides for binary data handling in responses. |
arrayCollapseOverride | String | Operation-level override for array handling (e.g., always-array, collapse-when-single). |
responseFieldArrayCollapse | Map<String, String> | Per-field overrides for array collapsing in responses. |
fieldCasingOverride | String | Operation-level override for JSON field name casing. |
responseFieldCasing | Map<String, String> | Per-field explicit name overrides, mapping a SOAP XPath to a specific JSON field name. |
fieldOrderingOverride | String | Operation-level override for ordering of fields in JSON objects. |
envelopeWrapOverride | String | Operation-level override for SOAP envelope wrapping behavior. |
errorShapeOverride | String | Operation-level override for the shape of error responses. |
xsiTypeHandlingOverride | String | Operation-level override for handling xsi:type attributes (e.g., strip, discriminator-field). |
xsiTypeDiscriminatorFieldOverride | String | The name of the discriminator field to use when xsiTypeHandlingOverride is discriminator-field. |
responseFieldXsiType | Map<String, String> | Per-field overrides for xsi:type handling in responses. |
headerPropagationOverride | String | Operation-level override for HTTP header propagation behavior. |
requiredHandlingOverride | String | Operation-level override for handling required-but-empty fields (e.g., permissive, fail-with-502). |
responseFieldRequiredHandling | Map<String, String> | Per-field overrides for required field handling in responses. |
whitespaceHandlingOverride | String | Operation-level override for whitespace handling in string values (e.g., preserve, trim). |
responseFieldWhitespaceHandling | Map<String, String> | Per-field overrides for whitespace handling in responses. |
upstreamFailureStatusOverride | String | Operation-level override for propagating upstream failure HTTP status codes (e.g., propagate, mask-as-200). |
requestFieldValidationRegexes | Map<String, String> | Per-field validation regex patterns for request fields, mapping a SOAP XPath to a regex string. |
responseFieldValidationRegexes | Map<String, String> | Per-field validation regex patterns for response fields. |
The repository is designed to be resilient to missing data or older database schemas to prevent failures during OpenAPI generation.
NOTE
Schema-Defensive Behavior
The methods findOperationFaults and findOperationHeaders are designed to be "schema-defensive." If they are executed against a database schema that predates the columns they query (operation_faults or operation_headers), they will catch the resulting RuntimeException, log it, and return an empty Map. This ensures that OpenAPI generation can proceed successfully on older environments, falling back to generic error shapes and omitting SOAP header documentation.
parseStringMap, parseObjectMap, etc.) that deserialize JSONB columns are robust. If a column contains null, a blank string, or malformed JSON, the method returns an empty Map or List. This prevents parsing errors and causes the generator to use the operation-level or system-level default for the affected fields.findServiceVersion and findArtifact methods return an Optional. If no record matches the provided serviceId and versionId, the Optional will be empty. Callers must check for this condition to avoid NoSuchElementException.parseStringMap method can handle both legacy (plain string values) and modern (structured object values) formats within the same JSONB map. It extracts the relevant mode string from objects, ensuring backward compatibility.OpenApiArtifactRecordWsdlOperationFaultRecordWsdlOperationHeaderRecords2r_openapi_artifacts2r_service_versions2r_services2r_operations2r_operation_mappings2r_wsdl_operation_catalog