@@ -60,7 +60,7 @@ function error() {
|
||||
cd ${PYGEOAPI_HOME}
|
||||
|
||||
echo "Trying to generate openapi.yml"
|
||||
pygeoapi openapi generate ${PYGEOAPI_CONFIG} > ${PYGEOAPI_OPENAPI}
|
||||
pygeoapi openapi generate ${PYGEOAPI_CONFIG} --output-file ${PYGEOAPI_OPENAPI}
|
||||
|
||||
[[ $? -ne 0 ]] && error "openapi.yml could not be generated ERROR"
|
||||
|
||||
|
||||
@@ -28,6 +28,12 @@ This will dump the OpenAPI document as YAML to your system's ``stdout``. To sav
|
||||
|
||||
pygeoapi openapi generate /path/to/my-pygeoapi-config.yml > /path/to/my-pygeoapi-openapi.yml
|
||||
|
||||
You can also write to a file explicitly via the ``--output-file`` option::
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pygeoapi openapi generate /path/to/my-pygeoapi-config.yml --output-file /path/to/my-pygeoapi-openapi.yml
|
||||
|
||||
To generate the OpenAPI document as JSON, run:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
+11
-3
@@ -1076,7 +1076,9 @@ def openapi():
|
||||
@click.argument('config_file', type=click.File())
|
||||
@click.option('--format', '-f', 'format_', type=click.Choice(['json', 'yaml']),
|
||||
default='yaml', help='output format (json|yaml)')
|
||||
def generate(ctx, config_file, format_='yaml'):
|
||||
@click.option('--output-file', '-of', type=click.File('w', encoding='utf-8'),
|
||||
help='Name of output file')
|
||||
def generate(ctx, config_file, output_file, format_='yaml'):
|
||||
"""Generate OpenAPI Document"""
|
||||
|
||||
if config_file is None:
|
||||
@@ -1084,10 +1086,16 @@ def generate(ctx, config_file, format_='yaml'):
|
||||
|
||||
s = yaml_load(config_file)
|
||||
pretty_print = s['server'].get('pretty_print', False)
|
||||
|
||||
if format_ == 'yaml':
|
||||
click.echo(yaml.safe_dump(get_oas(s), default_flow_style=False))
|
||||
content = yaml.safe_dump(get_oas(s), default_flow_style=False)
|
||||
else:
|
||||
click.echo(to_json(get_oas(s), pretty=pretty_print))
|
||||
content = to_json(get_oas(s), pretty=pretty_print)
|
||||
|
||||
if output_file is None:
|
||||
click.echo(content)
|
||||
else:
|
||||
output_file.write(content)
|
||||
|
||||
|
||||
@click.command()
|
||||
|
||||
@@ -14,6 +14,6 @@ pip install gunicorn
|
||||
cd tests/cite/ogcapi-features
|
||||
. cite.env
|
||||
python ../../load_es_data.py ./canada-hydat-daily-mean-02hc003.geojson IDENTIFIER
|
||||
pygeoapi openapi generate $PYGEOAPI_CONFIG > $PYGEOAPI_OPENAPI
|
||||
pygeoapi openapi generate $PYGEOAPI_CONFIG --output-file $PYGEOAPI_OPENAPI
|
||||
gunicorn pygeoapi.flask_app:APP -b 0.0.0.0:5001 --access-logfile '-'
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user