From e056a9849bfc4b38f2c815a559821e9d0d250833 Mon Sep 17 00:00:00 2001 From: Matt Dean Date: Wed, 8 Oct 2025 09:15:50 +0100 Subject: [PATCH] [NRL-1658] Move /metadata endpoint into swagger OAS --- api/consumer/swagger.yaml | 23 ++++++++ api/producer/swagger.yaml | 23 ++++++++ terraform/infrastructure/consumer.tftpl | 2 +- .../modules/api_gateway/api_gateway.tf | 55 ++----------------- terraform/infrastructure/producer.tftpl | 5 +- .../api_capability_statement_lookup.py | 11 ---- 6 files changed, 56 insertions(+), 63 deletions(-) diff --git a/api/consumer/swagger.yaml b/api/consumer/swagger.yaml index 47c668533..3fff692f9 100644 --- a/api/consumer/swagger.yaml +++ b/api/consumer/swagger.yaml @@ -382,6 +382,29 @@ paths: description: | Read a single document pointer by specifying the `DocumentReference.id`. Note that you will only be able to retrieve document pointers that have the `type` that was agreed during the [onboarding](#api-description__onboarding) process. + + /metadata: + get: + summary: Retrieve FHIR Capability Statement + operationId: getCapabilityStatement + responses: + "200": + description: Capability statement response + content: + application/json: + schema: + type: object + x-amazon-apigateway-integration: + type: MOCK + requestTemplates: + application/json: '{ "statusCode": 200 }' + responses: + default: + statusCode: "200" + responseTemplates: + # prettier-ignore + application/json: '${capability_statement_json}' + /_status: get: tags: diff --git a/api/producer/swagger.yaml b/api/producer/swagger.yaml index 6a53f7cb9..027d6c375 100644 --- a/api/producer/swagger.yaml +++ b/api/producer/swagger.yaml @@ -915,6 +915,29 @@ paths: contentHandling: CONVERT_TO_TEXT description: | Delete a single document pointer that your created. + + /metadata: + get: + summary: Retrieve FHIR Capability Statement + operationId: getCapabilityStatement + responses: + "200": + description: Capability statement response + content: + application/json: + schema: + type: object + x-amazon-apigateway-integration: + type: MOCK + requestTemplates: + application/json: '{ "statusCode": 200 }' + responses: + default: + statusCode: "200" + responseTemplates: + # prettier-ignore + application/json: '${capability_statement_json}' + /_status: get: summary: _status endpoint for APIGEE integration diff --git a/terraform/infrastructure/consumer.tftpl b/terraform/infrastructure/consumer.tftpl index 60b8a2d88..41dfef084 100644 --- a/terraform/infrastructure/consumer.tftpl +++ b/terraform/infrastructure/consumer.tftpl @@ -58,7 +58,7 @@ } ], "versioning": "version", - "readHistory": false, + "readHistory": false }, { "type": "DocumentReference", diff --git a/terraform/infrastructure/modules/api_gateway/api_gateway.tf b/terraform/infrastructure/modules/api_gateway/api_gateway.tf index f40307b01..d82313a7f 100644 --- a/terraform/infrastructure/modules/api_gateway/api_gateway.tf +++ b/terraform/infrastructure/modules/api_gateway/api_gateway.tf @@ -2,50 +2,12 @@ resource "aws_api_gateway_rest_api" "api_gateway_rest_api" { name = "${var.prefix}--${var.apitype}" description = "Manages an API Gateway Rest API." disable_execute_api_endpoint = true - body = templatefile("${path.module}/../../../../api/${var.apitype}/swagger.yaml", var.lambdas) -} - -resource "aws_api_gateway_resource" "capability" { - rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id - parent_id = aws_api_gateway_rest_api.api_gateway_rest_api.root_resource_id - path_part = "metadata" -} - -resource "aws_api_gateway_method" "capability" { - rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id - resource_id = aws_api_gateway_resource.capability.id - http_method = "GET" - authorization = "NONE" - - depends_on = [aws_api_gateway_resource.capability] -} - -resource "aws_api_gateway_integration" "capability" { - rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id - resource_id = aws_api_gateway_resource.capability.id - http_method = aws_api_gateway_method.capability.http_method - type = "MOCK" - request_templates = { - "application/json" = jsonencode({ "statusCode" = 200 }) - } -} - -resource "aws_api_gateway_method_response" "capability_200" { - rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id - resource_id = aws_api_gateway_resource.capability.id - http_method = aws_api_gateway_method.capability.http_method - status_code = "200" -} - -resource "aws_api_gateway_integration_response" "capability" { - rest_api_id = aws_api_gateway_rest_api.api_gateway_rest_api.id - resource_id = aws_api_gateway_resource.capability.id - http_method = aws_api_gateway_method.capability.http_method - status_code = aws_api_gateway_method_response.capability_200.status_code - - response_templates = { - "application/json" = var.capability_statement_content - } + body = templatefile( + "${path.module}/../../../../api/${var.apitype}/swagger.yaml", + merge(var.lambdas, { + capability_statement_json = var.capability_statement_content + }) + ) } resource "aws_api_gateway_deployment" "api_gateway_deployment" { @@ -65,11 +27,6 @@ resource "aws_api_gateway_deployment" "api_gateway_deployment" { depends_on = [ aws_api_gateway_rest_api.api_gateway_rest_api, - aws_api_gateway_resource.capability, - aws_api_gateway_method.capability, - aws_api_gateway_integration.capability, - aws_api_gateway_method_response.capability_200, - aws_api_gateway_integration_response.capability, aws_api_gateway_integration_response.head_integration_response ] } diff --git a/terraform/infrastructure/producer.tftpl b/terraform/infrastructure/producer.tftpl index e57375e1d..5a649c5ce 100644 --- a/terraform/infrastructure/producer.tftpl +++ b/terraform/infrastructure/producer.tftpl @@ -23,7 +23,8 @@ "description": "Capability Statement for the National Record Locator FHIR R4 Producer API", "kind": "instance", "software": { - "name": "National Record Locator FHIR R4 API - Producer" + "name": "National Record Locator FHIR R4 API - Producer", + "version": "v3.0" }, "implementation": { "description": "NRL v3.0 Producer API FHIR Server", @@ -57,7 +58,7 @@ } ], "versioning": "version", - "readHistory": false, + "readHistory": false }, { "type": "DocumentReference", diff --git a/tests/smoke/scenarios/api_capability_statement_lookup.py b/tests/smoke/scenarios/api_capability_statement_lookup.py index ab1eeb720..71959df30 100644 --- a/tests/smoke/scenarios/api_capability_statement_lookup.py +++ b/tests/smoke/scenarios/api_capability_statement_lookup.py @@ -1,17 +1,6 @@ -import os - -import pytest - from tests.utilities.api_clients import ConsumerTestClient, ProducerTestClient -def is_public_url(): - return os.environ.get("TEST_CONNECT_MODE") == "public" - - -@pytest.mark.skip( - reason="Capability statements only work via APIGEE in persistent environments", -) def test_read_api_capability_statements( consumer_client: ConsumerTestClient, producer_client: ProducerTestClient ):