50 lines
2.3 KiB
Bash
50 lines
2.3 KiB
Bash
#!/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
|
|
|