Skip to content

Commit

Permalink
Fixes for issue 160 (#161)
Browse files Browse the repository at this point in the history
* various version updates to fix issue 160

* add servers.zip

* add xml libraries to Alpine linux docker

* Update python-flask templates

* Increment version

* Revert "Increment version"

This reverts commit 2fe39d7.

* Revert "Update python-flask templates"

This reverts commit 647bae7.

* Update with fixes to moustache templates because of openapi version increment

* Update Open API generator version
Add curl to docker instance to help with health check

* Add comment about servers folder

* Put back the docs file
  • Loading branch information
rhyslewisakl authored Jun 13, 2022
1 parent 98d57ec commit d29fec3
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>jar</packaging>
<groupId>edu.isi.oba</groupId>
<artifactId>oba</artifactId>
<version>3.6.0</version>
<version>3.6.0.04</version>
<name>core</name>
<url>https://github.com/KnowledgeCaptureAndDiscovery/OBA</url>

Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/README.md
Original file line number Diff line number Diff line change
@@ -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.
Empty file removed src/main/resources/README.txt
Empty file.
Binary file modified src/main/resources/servers.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -29,4 +29,4 @@ ENTRYPOINT ["python"]
ENTRYPOINT ["python3"]
{{/supportPython2}}

CMD ["-m", "{{packageName}}"]
CMD ["-m", "{{packageName}}"]
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/main/resources/servers/python/generate-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit d29fec3

Please sign in to comment.