Changeset be25db1 for src/mapservice/codegen
- Timestamp:
- Apr 22, 2019, 5:39:46 PM (8 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 041e464
- Parents:
- 5e4cb73
- Location:
- src/mapservice/codegen
- Files:
-
- 4 edited
-
code_generator (modified) (1 diff)
-
templates/__init__test.mustache (modified) (1 diff)
-
templates/controller_test.mustache (modified) (2 diffs)
-
templates/requirements.mustache (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice/codegen/code_generator
r5e4cb73 rbe25db1 9 9 fi 10 10 11 echo "Copying static files"12 cp -a ../../src/templates ./13 cp -a ../../src/static ./14 mkdir -p static/css/15 mkdir -p static/js/16 mkdir -p static/resources/17 cp -a ../../../common/css/* static/css/18 cp -a ../../../common/js/* static/js/19 cp -a ../../../common/resources/* static/resources/20 cp -a ../../../../icon/gnuboat-256-256-transparent.png static/resources/11 #echo "Copying static files" 12 #cp -a ../../src/templates ./ 13 #cp -a ../../src/static ./ 14 #mkdir -p static/css/ 15 #mkdir -p static/js/ 16 #mkdir -p static/resources/ 17 #cp -a ../../common/css/* static/css/ 18 #cp -a ../../common/js/* static/js/ 19 #cp -a ../../common/resources/* static/resources/ 20 #cp -a ../../common/icon/gnuboat-256-256-transparent.png static/resources/ 21 21 22 echo "Generating backend and client API code" 22 23 cd ../../ 24 # backend 23 25 codegen/openapi-generator-cli generate -i openapi.yaml -g python-flask -t codegen/templates/ -o src-gen 26 # client 27 #codegen/openapi-generator-cli generate -i openapi.yaml -g javascript -o src-gen/openapi_server/static/ 28 #rm -R src-gen/openapi_server/static/.openapi* 29 24 30 25 31 cd src-gen/ 32 tox > /tmp/openapi_tox.log 26 33 python3 -m openapi_server -
src/mapservice/codegen/templates/__init__test.mustache
r5e4cb73 rbe25db1 2 2 3 3 import connexion 4 from flask_cors import CORS 4 5 from flask_testing import TestCase 5 6 6 7 from {{packageName}}.encoder import JSONEncoder 7 8 9 from {{packageName}}.server_impl.database.Model import db, db_test_setup 8 10 9 11 class BaseTestCase(TestCase): 12 def create_app(self): 13 logging.getLogger('connexion.operation').setLevel('ERROR') 14 app = connexion.App(__name__, specification_dir='../openapi/') 15 application = app.app 16 CORS(application) 17 application.json_encoder = JSONEncoder 18 app.add_api('openapi.yaml') 10 19 11 def create_app(self): 12 logging.getLogger('connexion.operation').setLevel('ERROR') 13 app = connexion.App(__name__, specification_dir='../openapi/') 14 app.app.json_encoder = JSONEncoder 15 app.add_api('openapi.yaml') 16 return app.app 20 application.config.from_object('{{packageName}}.server_impl.Config.TestingConfig') 21 db.init_app(application) 22 application.app_context().push() 23 24 return application 25 26 def setUp(self): 27 db.drop_all() 28 db_test_setup() 29 30 def tearDown(self): 31 db.session.remove() 32 db.drop_all() -
src/mapservice/codegen/templates/controller_test.mustache
r5e4cb73 rbe25db1 28 28 {{/bodyParam}} 29 29 {{#queryParams}} 30 {{#-first}}query_string = [{{/-first}}{{^-first}} {{/-first}}('{{paramName}}', {{{example}}}){{#hasMore}},{{/hasMore}}{{#-last}}]{{/-last}}30 {{#-first}}query_string = [{{/-first}}{{^-first}} {{/-first}}('{{paramName}}', '{{{example}}}'){{#hasMore}},{{/hasMore}}{{#-last}}]{{/-last}} 31 31 {{/queryParams}} 32 32 headers = { {{#vendorExtensions.x-prefered-produce}} 33 33 'Accept': '{{mediaType}}',{{/vendorExtensions.x-prefered-produce}}{{#vendorExtensions.x-prefered-consume}} 34 34 'Content-Type': '{{mediaType}}',{{/vendorExtensions.x-prefered-consume}}{{#headerParams}} 35 '{{paramName}}': {{{example}}},{{/headerParams}}{{#authMethods}}36 {{#isOAuth}}'Authorization': 'Bearer special-key',{{/isOAuth}}{{#isApiKey}}' {{name}}': 'special-key',{{/isApiKey}}{{#isBasicBasic}}'Authorization': 'BasicZm9vOmJhcg==',{{/isBasicBasic}}{{#isBasicBearer}}'Authorization': 'Bearer special-key',{{/isBasicBearer}}{{/authMethods}}35 '{{paramName}}': '{{{example}}}',{{/headerParams}}{{#authMethods}} 36 {{#isOAuth}}'Authorization': 'Bearer special-key',{{/isOAuth}}{{#isApiKey}}'X-API-KEY': 'test_key',{{/isApiKey}}{{#isBasicBasic}}'Authorization': 'BasicZm9vOmJhcg==',{{/isBasicBasic}}{{#isBasicBearer}}'Authorization': 'Bearer special-key',{{/isBasicBearer}}{{/authMethods}} 37 37 } 38 38 {{#formParams}} … … 40 40 {{/formParams}} 41 41 response = self.client.open( 42 '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}= {{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},42 '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}='{{{example}}}'{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}}, 43 43 method='{{httpMethod}}', 44 44 headers=headers{{#bodyParam}}, -
src/mapservice/codegen/templates/requirements.mustache
r5e4cb73 rbe25db1 6 6 {{/supportPython2}} 7 7 setuptools >= 21.0.0 8 flask-sqlalchemy 9 flask-cors
Note:
See TracChangeset
for help on using the changeset viewer.
