From a4fa0bd8010d26e0e149323b30a87a5f238db64e Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Sun, 7 Jun 2020 16:16:16 +0000 Subject: [PATCH] feat(generate): add makefile to generate code --- .gitignore | 1 + Makefile | 36 ++++++++++++++++++++++++++++++++++++ config/python-flask.yaml | 1 + 3 files changed, 38 insertions(+) create mode 100644 Makefile create mode 100644 config/python-flask.yaml diff --git a/.gitignore b/.gitignore index 8df74ac..4b89ebe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ # Node modules directory node_modules +build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..74e4b23 --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +INSTALL_DIR=build +CONFIG_DIR=config +YAML_FILE=https://raw.githubusercontent.com/MieuxVoter/mv-api-spec/master/mv-openapi.yaml + +.DEFAULT_GOAL := all + +.PHONY: all +all: clients server + +.PHONY: server +server: ${INSTALL_DIR}/python-flask + +.PHONY: clients +clients: ${INSTALL_DIR}/typescript-fetch ${INSTALL_DIR}/python + +${INSTALL_DIR}/%: + mkdir -p ${INSTALL_DIR} + CONFIG_FILE=${CONFIG_DIR}/$*.yaml + if [ -f ${CONFIG_DIR}/$*.yaml ]; then\ + docker run --rm -v "${PWD}:/local" \ + openapitools/openapi-generator-cli generate \ + -i ${YAML_FILE} \ + -g $* \ + -o /local/${INSTALL_DIR}/$* \ + -c /local/${CONFIG_DIR}/$*.yaml;\ + else\ + docker run --rm -v "${PWD}:/local" \ + openapitools/openapi-generator-cli generate \ + -i ${YAML_FILE} \ + -g $* \ + -o /local/${INSTALL_DIR}/$*; \ + fi + +.PHONY: clean +clean: + rm -rf ${INSTALL_DIR} diff --git a/config/python-flask.yaml b/config/python-flask.yaml new file mode 100644 index 0000000..2f74dec --- /dev/null +++ b/config/python-flask.yaml @@ -0,0 +1 @@ +packageName: mvapi