Skip to content

allixender/ogcapi-dggs-webdev-python

Repository files navigation

Swagger generated server for OGC DGGS API testing

Overview

This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.

This example uses the Connexion library on top of Flask.

The OpenAPI target definition is of DGGS API 0.0.6 of the DGGS SWG wip-ogc_api_dggs_zone_query_process_style

The latest iteration of that spec is actually ogc_api_dggs, unfortunately also 0.0.6. This repo is not yet implementing this. As part of the October 2021 ogcapi-code-sprint I/we are aiming to support the new API SPEC. Stay tuned or pull request.

Requirements

Python 3.5.2+

Usage

We need an env var named TABLES_CONFIG this TABLES_CONFIG var should hold the path to a file# based on the tables.template.conf wich holds the access info to the database definition.

The most useful is the demo test.sb SQlite database.

# for example
export TABLES_CONFIG=$HOME/tables.conf

To run the server, please execute the following from the root directory:

pip3 install -r requirements.txt

# configure clickhouse db access
export TABLES_CONFIG=tables.template.conf

python3 -m dggs_api_server

# or for dev and testing
# python server.py

and open your browser to here:

http://localhost:8080/dggs-api/ui/

Your Swagger definition lives here:

http://localhost:8080/dggs-api/openapi.json

To launch the integration tests, use tox:

sudo pip install tox
tox

Remark: I haven't had time to update the tests, please feel free to do so

Running with Docker

To run the server on a Docker container, please execute the following from the root directory:

# building the image
docker build -t dggs_api_server .

# starting up a container
docker run -p 8080:8080 dggs_api_server

A recent demo instance with the sqlite3 test.db is running at: https://dggs-api-bozea3cspa-ew.a.run.app/dggs-api/

About

Testing Python code generated servers for ogcapi-discrete-global-grid-systems

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published