From 645b9264d5fe95edd4d37573fe4ab3a4f82fb6c6 Mon Sep 17 00:00:00 2001 From: Mikhail Pryakhin Date: Thu, 10 Jul 2025 14:54:27 +0100 Subject: [PATCH 1/5] Parametrise openapi.yaml --- docs/rest_api/Makefile | 12 ++++++++++++ docs/rest_api/openapi.yaml | 2 +- docs/rest_api/openapi_internal.yaml | 2 +- web_ui/Dockerfile | 10 +++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 docs/rest_api/Makefile diff --git a/docs/rest_api/Makefile b/docs/rest_api/Makefile new file mode 100644 index 0000000000..b8ece05cb3 --- /dev/null +++ b/docs/rest_api/Makefile @@ -0,0 +1,12 @@ +include ../../Makefile.shared + +RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest-api + +build: + mkdir -p ${RESTAPI_BUILD_DIR} && \ + rsync -av --exclude='Makefile' --exclude=".build" . ${RESTAPI_BUILD_DIR} && \ + TAG=$(TAG) envsubst '$$TAG' < ${RESTAPI_BUILD_DIR}/openapi.yaml > ${RESTAPI_BUILD_DIR}/openapi.yaml.tmp && \ + mv ${RESTAPI_BUILD_DIR}/openapi.yaml.tmp ${RESTAPI_BUILD_DIR}/openapi.yaml && \ + TAG=$(TAG) envsubst '$$TAG' < ${RESTAPI_BUILD_DIR}/openapi_internal.yaml > ${RESTAPI_BUILD_DIR}/openapi_internal.yaml.tmp && \ + mv ${RESTAPI_BUILD_DIR}/openapi_internal.yaml.tmp ${RESTAPI_BUILD_DIR}/openapi_internal.yaml + diff --git a/docs/rest_api/openapi.yaml b/docs/rest_api/openapi.yaml index 51008cc6ab..1eaefffb55 100644 --- a/docs/rest_api/openapi.yaml +++ b/docs/rest_api/openapi.yaml @@ -1,6 +1,6 @@ openapi: "3.1.0" info: - version: 2.12.0 + version: ${TAG} title: Intel® Geti™ REST API description: REST API documentation for Intel® Geti™. diff --git a/docs/rest_api/openapi_internal.yaml b/docs/rest_api/openapi_internal.yaml index 9be49d0729..38267b485f 100644 --- a/docs/rest_api/openapi_internal.yaml +++ b/docs/rest_api/openapi_internal.yaml @@ -1,6 +1,6 @@ openapi: "3.1.0" info: - version: 2.12.0 + version: ${TAG} title: Intel® Geti™ REST API description: REST API documentation for Intel® Geti™. diff --git a/web_ui/Dockerfile b/web_ui/Dockerfile index b8ecab972b..31bcf1e59e 100644 --- a/web_ui/Dockerfile +++ b/web_ui/Dockerfile @@ -7,13 +7,21 @@ FROM node:22.12-bookworm-slim@sha256:35531c52ce27b6575d69755c73e65d4468dba93a25644eed56dc12879cae9213 AS build_rest_api_specs ARG LOCATION=/home/app/rest-api-specs/ +ARG REACT_APP_GETI_VERSION=development WORKDIR ${LOCATION} + COPY --link ./package.json . -COPY --link --from=docs_context rest_api /home/app/docs/rest_api/ +COPY --link --from=docs_context rest_api /tmp/rest_api_source/ COPY --link --from=api_context schemas /home/app/interactive_ai/services/api/schemas/ +# Install gettext-base for envsubst (needed by Makefile) +RUN apt-get update && apt-get install -y gettext-base rsync make && rm -rf /var/lib/apt/lists/* + +# Use the Makefile to generate the processed files +RUN cd /tmp/rest_api_source && TAG=${REACT_APP_GETI_VERSION} RESTAPI_BUILD_DIR=/home/app/docs/rest_api make build + RUN npm run build:rest-openapi-spec From 2a7da0d970cdfb4e4d07fd86e693fbf57715c417 Mon Sep 17 00:00:00 2001 From: Mikhail Pryakhin Date: Thu, 10 Jul 2025 15:08:42 +0100 Subject: [PATCH 2/5] Parametrise openapi.yaml --- web_ui/Dockerfile | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/web_ui/Dockerfile b/web_ui/Dockerfile index 31bcf1e59e..1c15e8f2ac 100644 --- a/web_ui/Dockerfile +++ b/web_ui/Dockerfile @@ -11,16 +11,18 @@ ARG REACT_APP_GETI_VERSION=development WORKDIR ${LOCATION} - COPY --link ./package.json . -COPY --link --from=docs_context rest_api /tmp/rest_api_source/ +COPY --link --from=docs_context rest_api /home/app/docs/rest_api/ COPY --link --from=api_context schemas /home/app/interactive_ai/services/api/schemas/ -# Install gettext-base for envsubst (needed by Makefile) -RUN apt-get update && apt-get install -y gettext-base rsync make && rm -rf /var/lib/apt/lists/* +# Install envsubst +RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/* -# Use the Makefile to generate the processed files -RUN cd /tmp/rest_api_source && TAG=${REACT_APP_GETI_VERSION} RESTAPI_BUILD_DIR=/home/app/docs/rest_api make build +# Replace ${TAG} placeholders with the current build version +RUN TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi.yaml > /home/app/docs/rest_api/openapi.yaml.tmp && \ + mv /home/app/docs/rest_api/openapi.yaml.tmp /home/app/docs/rest_api/openapi.yaml && \ + TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi_internal.yaml > /home/app/docs/rest_api/openapi_internal.yaml.tmp && \ + mv /home/app/docs/rest_api/openapi_internal.yaml.tmp /home/app/docs/rest_api/openapi_internal.yaml RUN npm run build:rest-openapi-spec @@ -51,8 +53,8 @@ COPY --link ./dev-proxy.ts ./ COPY --link src/ src/ COPY --link public/ public/ -COPY --from=docs_context rest_api /home/app/docs/rest_api/ -COPY --from=api_context schemas /home/app/interactive_ai/services/api/schemas/ +COPY --from=build_rest_api_specs /home/app/docs/rest_api/ /home/app/docs/rest_api/ +COPY --from=build_rest_api_specs /home/app/interactive_ai/services/api/schemas/ /home/app/interactive_ai/services/api/schemas/ RUN npm run build From 4af8dfc027f285b66e71586ba7436b7e7c92e724 Mon Sep 17 00:00:00 2001 From: Mikhail Pryakhin Date: Thu, 10 Jul 2025 15:16:37 +0100 Subject: [PATCH 3/5] Parametrise openapi.yaml --- docs/rest_api/Makefile | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/rest_api/Makefile b/docs/rest_api/Makefile index b8ece05cb3..b4eda3dfec 100644 --- a/docs/rest_api/Makefile +++ b/docs/rest_api/Makefile @@ -2,11 +2,24 @@ include ../../Makefile.shared RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest-api +.PHONY: build + +# Replaces all ${TAG} placeholders with the current build version build: - mkdir -p ${RESTAPI_BUILD_DIR} && \ - rsync -av --exclude='Makefile' --exclude=".build" . ${RESTAPI_BUILD_DIR} && \ - TAG=$(TAG) envsubst '$$TAG' < ${RESTAPI_BUILD_DIR}/openapi.yaml > ${RESTAPI_BUILD_DIR}/openapi.yaml.tmp && \ - mv ${RESTAPI_BUILD_DIR}/openapi.yaml.tmp ${RESTAPI_BUILD_DIR}/openapi.yaml && \ - TAG=$(TAG) envsubst '$$TAG' < ${RESTAPI_BUILD_DIR}/openapi_internal.yaml > ${RESTAPI_BUILD_DIR}/openapi_internal.yaml.tmp && \ - mv ${RESTAPI_BUILD_DIR}/openapi_internal.yaml.tmp ${RESTAPI_BUILD_DIR}/openapi_internal.yaml + @echo "Building REST API..." + @mkdir -p $(RESTAPI_BUILD_DIR) + + @echo "Copying source files..." + @rsync -av --exclude='Makefile' --exclude='.build' . $(RESTAPI_BUILD_DIR) + + @echo "Processing OpenAPI specifications..." + @for file in openapi.yaml openapi_internal.yaml; do \ + echo "Processing $$file..."; \ + TAG=$(TAG) envsubst '$$TAG' < $(RESTAPI_BUILD_DIR)/$$file > $(RESTAPI_BUILD_DIR)/$$file.tmp; \ + mv $(RESTAPI_BUILD_DIR)/$$file.tmp $(RESTAPI_BUILD_DIR)/$$file; \ + done + + @echo "Build complete" + + From 62000f5c104b557a8ae2c2962cc1d589ffc4b2b8 Mon Sep 17 00:00:00 2001 From: Mikhail Pryakhin Date: Thu, 10 Jul 2025 15:22:18 +0100 Subject: [PATCH 4/5] Parametrise openapi.yaml --- docs/rest_api/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/rest_api/Makefile b/docs/rest_api/Makefile index b4eda3dfec..392d11e60b 100644 --- a/docs/rest_api/Makefile +++ b/docs/rest_api/Makefile @@ -20,6 +20,3 @@ build: done @echo "Build complete" - - - From ebca5a12e20438086e15c1449938d5daac5418e5 Mon Sep 17 00:00:00 2001 From: Mikhail Pryakhin Date: Thu, 10 Jul 2025 17:07:03 +0100 Subject: [PATCH 5/5] add openapi spec compilation target --- docs/rest_api/Makefile | 2 +- interactive_ai/tests/e2e/Makefile | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/rest_api/Makefile b/docs/rest_api/Makefile index 392d11e60b..181b2a0d35 100644 --- a/docs/rest_api/Makefile +++ b/docs/rest_api/Makefile @@ -1,6 +1,6 @@ include ../../Makefile.shared -RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest-api +RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest_api .PHONY: build diff --git a/interactive_ai/tests/e2e/Makefile b/interactive_ai/tests/e2e/Makefile index 9580082477..c986f9da91 100644 --- a/interactive_ai/tests/e2e/Makefile +++ b/interactive_ai/tests/e2e/Makefile @@ -1,16 +1,28 @@ MAKEFILE_DIR := $(shell pwd) -OPENAPI_YAML_SPEC := ../../../docs/rest_api/openapi_internal.yaml + +OPENAPI_DIR := ../../../docs/rest_api + +OPENAPI_YAML_SPEC := $(OPENAPI_DIR)/.build/rest_api/openapi_internal.yaml OPENAPI_JSON_SPEC := /tmp/openapi_internal.json CLIENT_NAME := geti_client CLIENT_PATH := rest_client SPEC_HASH_FILE := .openapi_spec_hash -.PHONY: all check_yaml_spec generate_json_spec generate_client generate_client_if_needed test test_wip test_smoke mypy +.PHONY: all check_yaml_spec generate_json_spec generate_client generate_client_if_needed test test_wip test_smoke mypy compile_yaml_spec venv: $(MAKE) generate_client_if_needed; uv sync --frozen ${PIP_INSTALL_PARAMS} -check_yaml_spec: + +compile_yaml_spec: + @if [ ! -d $(OPENAPI_DIR) ]; then \ + echo "Error: OpenAPI directory not found at $(OPENAPI_DIR)"; \ + exit 1; \ + else \ + $(MAKE) -C $(OPENAPI_DIR) build; \ + fi + +check_yaml_spec: compile_yaml_spec @if [ ! -f $(OPENAPI_YAML_SPEC) ]; then \ echo "Error: OpenAPI YAML spec file not found at $(OPENAPI_YAML_SPEC)"; \ exit 1; \