-
Notifications
You must be signed in to change notification settings - Fork 51
feat: enable semantic versioning for openAPI specs #677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| include ../../Makefile.shared | ||
|
|
||
| RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest_api | ||
|
|
||
| .PHONY: build | ||
|
|
||
| # Replaces all ${TAG} placeholders with the current build version | ||
| build: | ||
| @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" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,13 +7,23 @@ | |
| 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=api_context schemas /home/app/interactive_ai/services/api/schemas/ | ||
|
|
||
| # Install envsubst | ||
| RUN apt-get update && apt-get install -y gettext-base && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # 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 | ||
|
Comment on lines
+22
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could simplify this a bit using |
||
|
|
||
| RUN npm run build:rest-openapi-spec | ||
|
|
||
|
|
||
|
|
@@ -43,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/ | ||
|
Comment on lines
-46
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we can remove these since we don't need this at build time (only when calling |
||
|
|
||
| RUN npm run build | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BDD tests depend on

openapi_internal.yamlto generate the JSON spec (source). I checked this branch and the API client auto-generation still succeeds even if the ${TAG} is not resolved in the JSON file:I don't know if this has side effects on the BDD tests, though. Could you please run them on this PR?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Leo, I've implemented an additional target that compiles the OpenAPI spec before generating a client, but given that the compiled code is generated in a subfolder, the hardcoded references to the object schemas break. So the idea of version generation will not work for this OpenAPI spec. I'm closing the PR.
