Ignore:
Timestamp:
Apr 22, 2019, 5:39:46 PM (8 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
041e464
Parents:
5e4cb73
Message:

Improved adding Water UI in mapservice-webclient

Location:
src/mapservice/codegen
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice/codegen/code_generator

    r5e4cb73 rbe25db1  
    99fi
    1010
    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/
    2121
     22echo "Generating backend and client API code"
    2223cd ../../
     24# backend
    2325codegen/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
    2430
    2531cd src-gen/
     32tox > /tmp/openapi_tox.log
    2633python3 -m openapi_server
  • src/mapservice/codegen/templates/__init__test.mustache

    r5e4cb73 rbe25db1  
    22
    33import connexion
     4from flask_cors import CORS
    45from flask_testing import TestCase
    56
    67from {{packageName}}.encoder import JSONEncoder
    78
     9from {{packageName}}.server_impl.database.Model import db, db_test_setup
    810
    911class 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')
    1019
    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  
    2828        {{/bodyParam}}
    2929        {{#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}}
    3131        {{/queryParams}}
    3232        headers = { {{#vendorExtensions.x-prefered-produce}}
    3333            'Accept': '{{mediaType}}',{{/vendorExtensions.x-prefered-produce}}{{#vendorExtensions.x-prefered-consume}}
    3434            '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}}
    3737        }
    3838        {{#formParams}}
    … …  
    4040        {{/formParams}}
    4141        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}},
    4343            method='{{httpMethod}}',
    4444            headers=headers{{#bodyParam}},
  • src/mapservice/codegen/templates/requirements.mustache

    r5e4cb73 rbe25db1  
    66{{/supportPython2}}
    77setuptools >= 21.0.0
     8flask-sqlalchemy
     9flask-cors
Note: See TracChangeset for help on using the changeset viewer.