From c2c0c828042c0bd81e9ff68ffe18be6f2623d26c Mon Sep 17 00:00:00 2001 From: Nicolo' Padovani <69471887+nicopado@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:57:07 +0200 Subject: [PATCH] feat: Implement openapi client code generator | NPG-6475 (#580) # Description Implement openapi client generator to automatically generate cat-data-service client code ## Type of change - [X] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [X] This change requires a documentation update ## How Has This Been Tested? - [X] Navigate to the test folder and run `earthly +generate-client` ## Checklist - [X] My code follows the style guidelines of this project - [X] I have performed a self-review of my code - [X] I have commented my code, particularly in hard-to-understand areas - [X] I have made corresponding changes to the documentation - [X] My changes generate no new warnings - [X] I have added tests that prove my fix is effective or that my feature works - [X] New and existing unit tests pass locally with my changes - [X] Any dependent changes have been merged and published in downstream modules --- .gitignore | 1 + tests/Earthfile | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/Earthfile diff --git a/.gitignore b/.gitignore index b3eb4c17b7..6a888d4651 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ result* .vscode **/.idea/ .temp/ +tests/tmp/ # std .std diff --git a/tests/Earthfile b/tests/Earthfile new file mode 100644 index 0000000000..6648477e76 --- /dev/null +++ b/tests/Earthfile @@ -0,0 +1,27 @@ +VERSION 0.7 + +FROM debian:stable-slim + +# BASH, CURL, GPG, NODEJS, NPM, JRE +dependencies: + RUN apt-get update + RUN apt-get install bash + RUN apt-get install curl -y + RUN apt-get install gpg -y + RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg + RUN apt-get install nodejs -y + RUN apt-get install npm -y + RUN apt-get install default-jre -y + +generate-client: + FROM +dependencies + + # TODO(@nicopado): Get the correct file from openapi doc generation target - https://github.com/input-output-hk/catalyst-core/issues/589 + ARG openapispec_file="./petstore.yaml" + COPY $openapispec_file . + + RUN npm install @openapitools/openapi-generator-cli -g + + RUN openapi-generator-cli validate -i $openapispec_file + + RUN openapi-generator-cli generate -i $openapispec_file -g rust -o ./tmp/client/ --package-name cat-data-service-client \ No newline at end of file