diff --git a/pom.xml b/pom.xml index 43d8dd0..ca528e0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ jar edu.isi.oba oba - 3.6.0 + 3.6.0.04 core https://github.com/KnowledgeCaptureAndDiscovery/OBA diff --git a/src/main/resources/README.md b/src/main/resources/README.md new file mode 100644 index 0000000..2ca16b5 --- /dev/null +++ b/src/main/resources/README.md @@ -0,0 +1,10 @@ +# Servers directory + +Note servers.zip file is used to generate the python flask server, so any changes to files in the folder need to be replicated into a new servers.zip file. eg. + +``` +rm servers.zip +zip -r servers.zip servers +``` + +Also note the moustache template files in the hidden folder: OBA/src/main/resources/servers/python/.openapi-generator were copied from https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python-flask on 17 Jul 2020, and have not followed changes to that project so that a full refactor would be required to get back in sync. \ No newline at end of file diff --git a/src/main/resources/README.txt b/src/main/resources/README.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/resources/servers.zip b/src/main/resources/servers.zip index f77ace7..49164d2 100644 Binary files a/src/main/resources/servers.zip and b/src/main/resources/servers.zip differ diff --git a/src/main/resources/servers/python/.openapi-generator/template/Dockerfile.mustache b/src/main/resources/servers/python/.openapi-generator/template/Dockerfile.mustache index 3aea2fc..35fee13 100644 --- a/src/main/resources/servers/python/.openapi-generator/template/Dockerfile.mustache +++ b/src/main/resources/servers/python/.openapi-generator/template/Dockerfile.mustache @@ -5,7 +5,7 @@ FROM python:2-alpine FROM python:3-alpine {{/supportPython2}} -RUN apk add build-base libffi-dev openssl-dev git +RUN apk add build-base libffi-dev openssl-dev git libxml2-dev libxslt-dev curl RUN mkdir -p /usr/src/app WORKDIR /usr/src/app @@ -29,4 +29,4 @@ ENTRYPOINT ["python"] ENTRYPOINT ["python3"] {{/supportPython2}} -CMD ["-m", "{{packageName}}"] \ No newline at end of file +CMD ["-m", "{{packageName}}"] diff --git a/src/main/resources/servers/python/.openapi-generator/template/__init__.mustache b/src/main/resources/servers/python/.openapi-generator/template/__init__.mustache index f854ece..df5c8d3 100644 --- a/src/main/resources/servers/python/.openapi-generator/template/__init__.mustache +++ b/src/main/resources/servers/python/.openapi-generator/template/__init__.mustache @@ -11,13 +11,10 @@ except: logger = logging.getLogger(__name__) query_manager = QueryManager(queries_dir=QUERY_DIRECTORY, - context_dir=CONTEXT_DIRECTORY, - queries_types=QUERIES_TYPES, - endpoint=ENDPOINT, - endpoint_username=ENDPOINT_USERNAME, - endpoint_password=ENDPOINT_PASSWORD, - graph_base=ENDPOINT_GRAPH_BASE, - prefix=ENDPOINT_RESOURCE_PREFIX) - - + context_dir=CONTEXT_DIRECTORY, + endpoint=ENDPOINT, + endpoint_username=ENDPOINT_USERNAME, + endpoint_password=ENDPOINT_PASSWORD, + named_graph_base=ENDPOINT_GRAPH_BASE, + uri_prefix=ENDPOINT_RESOURCE_PREFIX) diff --git a/src/main/resources/servers/python/.openapi-generator/template/controller.mustache b/src/main/resources/servers/python/.openapi-generator/template/controller.mustache index fe450ad..5a74e64 100644 --- a/src/main/resources/servers/python/.openapi-generator/template/controller.mustache +++ b/src/main/resources/servers/python/.openapi-generator/template/controller.mustache @@ -9,7 +9,7 @@ from {{packageName}} import util {{#operations}} {{#operation}} -def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): # noqa: E501 +def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{^-last}}, {{/-last}}{{/allParams}}): # noqa: E501 """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} {{#notes}}{{.}}{{/notes}} # noqa: E501 @@ -110,9 +110,9 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{ {{/isMapContainer}} {{/allParams}} - return query_manager.{{#lambda.lowercase}}{{httpMethod}}_resource{{/lambda.lowercase}}({{#pathParams}}{{paramName}}={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/pathParams}}{{#queryParams}} - {{paramName}}={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/queryParams}}{{#bodyParams}} - body={{paramName}}{{#hasMore}},{{/hasMore}}{{#-last}},{{/-last}}{{/bodyParams}} + return query_manager.{{#lambda.lowercase}}{{httpMethod}}_resource{{/lambda.lowercase}}({{#pathParams}}{{paramName}}={{paramName}},{{/pathParams}}{{#queryParams}} + {{paramName}}={{paramName}},{{/queryParams}}{{#bodyParams}} + body={{paramName}},{{/bodyParams}} rdf_type_uri={{#lambda.uppercase}}{{baseName}}_type_uri{{/lambda.uppercase}}, rdf_type_name={{#lambda.uppercase}}{{baseName}}_type_name{{/lambda.uppercase}}, kls={{baseName}}) diff --git a/src/main/resources/servers/python/.openapi-generator/template/model.mustache b/src/main/resources/servers/python/.openapi-generator/template/model.mustache index afc0bc7..bbd001e 100644 --- a/src/main/resources/servers/python/.openapi-generator/template/model.mustache +++ b/src/main/resources/servers/python/.openapi-generator/template/model.mustache @@ -47,13 +47,13 @@ class {{classname}}(Model): self.openapi_types = { {{#vars}} - '{{name}}': {{{dataType}}}{{#hasMore}},{{/hasMore}} + '{{name}}': {{{dataType}}}{{^-last}},{{/-last}} {{/vars}} } self.attribute_map = { {{#vars}} - '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} + '{{name}}': '{{baseName}}'{{^-last}},{{/-last}} {{/vars}} } {{#vars}}{{#-first}} diff --git a/src/main/resources/servers/python/.openapi-generator/template/requirements.mustache b/src/main/resources/servers/python/.openapi-generator/template/requirements.mustache index 158b8b4..d7cd4f7 100644 --- a/src/main/resources/servers/python/.openapi-generator/template/requirements.mustache +++ b/src/main/resources/servers/python/.openapi-generator/template/requirements.mustache @@ -1,9 +1,10 @@ pythonql3==0.9.61 connexion >= 2.6.0 obasparql >= 3.4.2 -werkzeug==0.16.1 +werkzeug>=2.0 swagger-ui-bundle >= 0.0.2 python_dateutil >= 2.6.0 setuptools >= 21.0.0 validators >= 0.14.2 python-jose >= 3.0.1 +markupsafe==2.0.1 diff --git a/src/main/resources/servers/python/generate-server.sh b/src/main/resources/servers/python/generate-server.sh index de381f9..0bafd0a 100644 --- a/src/main/resources/servers/python/generate-server.sh +++ b/src/main/resources/servers/python/generate-server.sh @@ -20,9 +20,9 @@ cp ../openapi.yaml ${PWD} SERVER_DIR=server -docker run -ti --rm -v ${PWD}:/local \ +docker run --rm -v ${PWD}:/local \ -u "$(id -u):$(id -u)" \ - openapitools/openapi-generator-cli:v4.1.2 \ + openapitools/openapi-generator-cli:v6.0.0 \ generate \ -i /local/openapi.yaml\ -g python-flask \