From 97a6f5c8cd780b29ef33471eea0a0983abd8597e Mon Sep 17 00:00:00 2001 From: fterrot Date: Sun, 28 Feb 2021 21:29:24 +0100 Subject: [PATCH] Initial generation files --- config.yaml | 41 +++++++++++++++++++++++++++++++++++++++++ generate.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 config.yaml create mode 100644 generate.sh diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..8bdc8cc --- /dev/null +++ b/config.yaml @@ -0,0 +1,41 @@ +# +# MIT License Copyright (c) 2021 F.Terrot +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is furnished +# to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +generatorName: java +apiPackage: io.gitea.api +artifactDescription: Access GITEA services in Java. +artifactId: java.gitea.api +artifactUrl: https://forge.chapril.org/gitea/java.gitea.api +artifactVersion: 1.13.0 +developerEmail: fterrot<@>april.org +developerName: Gitea Contributors, OpenAPI-generator Contributors +developerOrganisation: none +developerOragnisationUrl: https://gitea.io/ +groupId: io.gitea +hideGenerationTimestamp: true +invokerPackage: io.gitea +licenseName: MIT +modelPackage: io.gitea.model +scmUrl: https://forge.chapril.org/gitea/java.gitea.api +snapshotVersion: false # true for master +java8: true +dateLibrary: java8 + diff --git a/generate.sh b/generate.sh new file mode 100644 index 0000000..b273a5b --- /dev/null +++ b/generate.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# MIT License Copyright (c) 2021 F.Terrot +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is furnished +# to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +gitea_version=1.13 +openapi_codegen_version=5.0.1 + +gitea_api_json=swagger.${gitea_version}.json +openapi_codegen_jar=openapi-generator-cli-${openapi_codegen_version}.jar +openapi_codegen_baseurl=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli +openapi_codegen="java -jar ${openapi_codegen_jar}" + +if [ ${gitea_version} = "master" ] ; then + gitea_api_json_url=https://raw.githubusercontent.com/go-gitea/gitea/master/templates/swagger/v1_json.tmpl +else + gitea_api_json_url=https://raw.githubusercontent.com/go-gitea/gitea/release/v${gitea_version}/templates/swagger/v1_json.tmpl +fi + +curl ${gitea_api_json_url} --output ${gitea_api_json} +sed -i s/{{AppSubUrl}}//g ${gitea_api_json} + +[ ! -f ${openapi_codegen_jar} ] && curl ${openapi_codegen_baseurl}/${openapi_codegen_version}/${openapi_codegen_jar} -O + +if [ -f ${openapi_codegen_jar} ] ; then + ${openapi_codegen} validate -i ${gitea_api_json} || (echo "**ERROR ** JSON Validation issue" && exit 1) + ${openapi_codegen} generate --additional-properties=java8=true -i ${gitea_api_json} -c config.yaml -o . || (echo "** ERROR ** Code Generation issue" && exit 2) + mvn -Dmaven.javadoc.skip=true package +else + echo "Missing ${openapi_codegen_jar}" +fi +