diff --git a/README.md b/README.md
index ea524ce..2155aae 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ curl http://localhost:5000/collections/countries/items?resulttype=hits
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui
# go to http://localhost
-# enter http://localhost:5000/api and click 'Explore'
+# enter http://localhost:5000/openapi and click 'Explore'
```
## Demo Server
diff --git a/docs/source/openapi.rst b/docs/source/openapi.rst
index 59259fb..f8af172 100644
--- a/docs/source/openapi.rst
+++ b/docs/source/openapi.rst
@@ -15,9 +15,9 @@ pygeoapi REST end points descriptions on OpenAPI standard are automatically gene
pygeoapi generate-openapi-document -c local.config.yml > openapi.yml
-The api will them be accessible at `/api` endpoint.
+The api will them be accessible at `/openapi` endpoint.
-For api demo please check: ``_
+For api demo please check: ``_
The api page has REST description but also integrated clients that can be used to send requests to the REST end points and see the response provided
diff --git a/pygeoapi/api.py b/pygeoapi/api.py
index 250e21e..93bdcea 100644
--- a/pygeoapi/api.py
+++ b/pygeoapi/api.py
@@ -146,12 +146,12 @@ class API(object):
'rel': 'service-desc',
'type': 'application/vnd.oai.openapi+json;version=3.0',
'title': 'The OpenAPI definition as JSON',
- 'href': '{}/api'.format(self.config['server']['url'])
+ 'href': '{}/openapi'.format(self.config['server']['url'])
}, {
'rel': 'service-doc',
'type': 'text/html',
'title': 'The OpenAPI definition as HTML',
- 'href': '{}/api?f=html'.format(self.config['server']['url']),
+ 'href': '{}/openapi?f=html'.format(self.config['server']['url']),
'hreflang': self.config['server']['language']
}, {
'rel': 'conformance',
@@ -178,7 +178,7 @@ class API(object):
return headers_, 200, json.dumps(fcm)
@pre_process
- def api(self, headers_, format_, openapi):
+ def openapi(self, headers_, format_, openapi):
"""
Provide OpenAPI document
@@ -199,14 +199,14 @@ class API(object):
LOGGER.error(exception)
return headers_, 400, json.dumps(exception)
- path = '/'.join([self.config['server']['url'].rstrip('/'), 'api'])
+ path = '/'.join([self.config['server']['url'].rstrip('/'), 'openapi'])
if format_ == 'html':
data = {
'openapi-document-path': path
}
headers_['Content-Type'] = 'text/html'
- content = _render_j2_template(self.config, 'api.html', data)
+ content = _render_j2_template(self.config, 'openapi.html', data)
return headers_, 200, content
headers_['Content-Type'] = \
diff --git a/pygeoapi/flask_app.py b/pygeoapi/flask_app.py
index 2053069..09e343d 100644
--- a/pygeoapi/flask_app.py
+++ b/pygeoapi/flask_app.py
@@ -77,8 +77,8 @@ def root():
return response
-@APP.route('/api')
-def api():
+@APP.route('/openapi')
+def openapi():
"""
OpenAPI access point
@@ -87,8 +87,8 @@ def api():
with open(os.environ.get('PYGEOAPI_OPENAPI')) as ff:
openapi = yaml_load(ff)
- headers, status_code, content = api_.api(request.headers, request.args,
- openapi)
+ headers, status_code, content = api_.openapi(request.headers, request.args,
+ openapi)
response = make_response(content, status_code)
if headers:
diff --git a/pygeoapi/openapi.py b/pygeoapi/openapi.py
index d95a2e2..b8fbc44 100644
--- a/pygeoapi/openapi.py
+++ b/pygeoapi/openapi.py
@@ -146,7 +146,7 @@ def get_oas_30(cfg):
}
}
- paths['/api'] = {
+ paths['/openapi'] = {
'get': {
'summary': 'This document',
'description': 'This document',
diff --git a/pygeoapi/provider/postgresql.py b/pygeoapi/provider/postgresql.py
index cfab560..db1b146 100644
--- a/pygeoapi/provider/postgresql.py
+++ b/pygeoapi/provider/postgresql.py
@@ -72,8 +72,11 @@ class DatabaseConnection(object):
(defaults to UNIX socket if not provided)
port – connection port number
(defaults to 5432 if not provided)
- schema – schema to use as search path, normally
- data is in the public schema
+ search_path – search path to be used (by order) , normally
+ data is in the public schema, [public],
+ or in a specific schema ["osm", "public"].
+ Note: First we should have the schema
+ being used and then public
:param table: table name containing the data. This variable is used to
assemble column information
@@ -87,18 +90,14 @@ class DatabaseConnection(object):
self.context = context
self.columns = None
self.conn = None
- self.schema = None
def __enter__(self):
try:
- self.schema = self.conn_dic.pop('schema', None)
- if self.schema == 'public' or self.schema is None:
- pass
- else:
- self.conn_dic["options"] = '-c search_path={}'.format(
- self.schema)
- LOGGER.debug('Using schema {} as search path'.format(
- self.schema))
+ search_path = self.conn_dic.pop('search_path', ['public'])
+ if search_path != ['public']:
+ self.conn_dic["options"] = f'-c \
+ search_path={",".join(search_path)}'
+ LOGGER.debug(f'Using search path: {search_path} ')
self.conn = psycopg2.connect(**self.conn_dic)
except psycopg2.OperationalError:
@@ -149,6 +148,7 @@ class PostgreSQLProvider(BaseProvider):
self.table = provider_def['table']
self.id_field = provider_def['id_field']
self.conn_dic = provider_def['data']
+ self.geom = provider_def.get('geom_field', 'geom')
LOGGER.debug('Setting Postgresql properties:')
LOGGER.debug('Connection String:{}'.format(
@@ -188,7 +188,6 @@ class PostgreSQLProvider(BaseProvider):
except Exception as err:
LOGGER.error('Error executing sql_query: {}: {}'.format(
sql_query.as_string(cursor)), err)
- LOGGER.error('Using public schema: {}'.format(db.schema))
raise ProviderQueryError()
hits = cursor.fetchone()["hits"]
@@ -203,9 +202,9 @@ class PostgreSQLProvider(BaseProvider):
SELECT {},ST_AsGeoJSON({}) FROM {} WHERE {} @ \
ST_MakeEnvelope({}, {}, {}, {})").\
format(db.columns,
- Identifier('geom'),
+ Identifier(self.geom),
Identifier(self.table),
- Identifier('geom'),
+ Identifier(self.geom),
Placeholder(),
Placeholder(),
Placeholder(),
@@ -214,7 +213,7 @@ class PostgreSQLProvider(BaseProvider):
if not bbox:
bbox = [-180, -90, 180, 90]
- LOGGER.debug('SQL Query: {}'.format(sql_query.as_string(cursor)))
+ LOGGER.debug('SQL Query: {}'.format(sql_query))
LOGGER.debug('Start Index: {}'.format(startindex))
LOGGER.debug('End Index: {}'.format(end_index))
try:
@@ -225,7 +224,6 @@ class PostgreSQLProvider(BaseProvider):
except Exception as err:
LOGGER.error('Error executing sql_query: {}'.format(
sql_query.as_string(cursor)))
- LOGGER.error('Using public schema: {}'.format(db.schema))
LOGGER.error(err)
raise ProviderQueryError()
@@ -258,7 +256,7 @@ class PostgreSQLProvider(BaseProvider):
sql_query = SQL("select {},ST_AsGeoJSON({}) \
from {} WHERE {}=%s").format(db.columns,
- Identifier('geom'),
+ Identifier(self.geom),
Identifier(self.table),
Identifier(self.id_field))
@@ -269,7 +267,6 @@ class PostgreSQLProvider(BaseProvider):
except Exception as err:
LOGGER.error('Error executing sql_query: {}'.format(
sql_query.as_string(cursor)))
- LOGGER.error('Using public schema: {}'.format(db.schema))
LOGGER.error(err)
raise ProviderQueryError()
diff --git a/pygeoapi/starlette_app.py b/pygeoapi/starlette_app.py
index 29f3f81..7d3a3b9 100644
--- a/pygeoapi/starlette_app.py
+++ b/pygeoapi/starlette_app.py
@@ -80,9 +80,9 @@ async def root(request: Request):
return response
-@app.route('/api')
-@app.route('/api/')
-async def api(request: Request):
+@app.route('/openapi')
+@app.route('/openapi/')
+async def openapi(request: Request):
"""
OpenAPI access point
@@ -91,7 +91,7 @@ async def api(request: Request):
with open(os.environ.get('PYGEOAPI_OPENAPI')) as ff:
openapi = yaml_load(ff)
- headers, status_code, content = api_.api(
+ headers, status_code, content = api_.openapi(
request.headers, request.query_params, openapi)
response = Response(content=content, status_code=status_code)
diff --git a/pygeoapi/templates/api.html b/pygeoapi/templates/openapi.html
similarity index 100%
rename from pygeoapi/templates/api.html
rename to pygeoapi/templates/openapi.html
diff --git a/pygeoapi/templates/root.html b/pygeoapi/templates/root.html
index 6358ac2..365dd25 100644
--- a/pygeoapi/templates/root.html
+++ b/pygeoapi/templates/root.html
@@ -56,10 +56,10 @@
View the processes in this service
-