Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML responses #636

Merged
merged 45 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3252b6f
[wip] implement HTML response requirement of OGC API Processes (relat…
fmigneault Mar 19, 2024
86d4aad
[wip] add OutputFormat.HTML definitions + add accept-header/format-qu…
fmigneault Mar 20, 2024
61e0fb3
update swagger-ui 3.25.1 to 5.12.0 for ui/css fixes of OpenAPI rendering
fmigneault Mar 20, 2024
5ca62c7
[wip] refactor pyramid views configuration using cornice service dire…
fmigneault Mar 21, 2024
c4b1809
fix invalid API route resolutions from cornice service definitions
fmigneault Mar 22, 2024
e0bcb79
temporarily patch cornice's prefix path resolution with pyramid route…
fmigneault Mar 22, 2024
bab932d
add config and handling of HTML views + add redict to non-prefixed co…
fmigneault Apr 6, 2024
dc4961d
workaournd fix of invalid pyramid route_prefix path (relates to https…
fmigneault Apr 6, 2024
7730c2b
working basic HTML redering for /processes endpoint
fmigneault Apr 6, 2024
4b49007
[wip] add HTML for process description
fmigneault Apr 10, 2024
f5dd70f
basic HTML process description + improvements to HTML process listing…
fmigneault Apr 10, 2024
031f3fc
fix resolution of HTML response schema name
fmigneault Apr 12, 2024
8536e1e
add html alternate link to process description (relates to https://gi…
fmigneault Apr 29, 2024
ca241ff
more process description metadata in HTML view
fmigneault Apr 30, 2024
00615d1
HTML detailed rendering for process description
fmigneault Apr 30, 2024
013a042
better unification of styles between HTML processes listing and descr…
fmigneault Apr 30, 2024
5dd5871
address some inconsistencies in HTTP Accept header / format query neg…
fmigneault May 1, 2024
b7564cc
Merge remote-tracking branch 'origin/master' into html-responses
fmigneault May 1, 2024
7a56d25
Merge remote-tracking branch 'origin/master' into html-responses
fmigneault May 1, 2024
8488f02
add basic tests for HTML process views
fmigneault May 1, 2024
b1e7791
temporary revert cornice.Service.pyramid_route for route_prefix to re…
fmigneault May 2, 2024
3a70b4f
[wip] refactor accept view decorators
fmigneault May 2, 2024
c39d548
[wip] more refector
fmigneault May 3, 2024
da6cc79
openapi JSON redirect from swagger-ui with accept/format (fixes #623)
fmigneault May 3, 2024
9e32550
fix sphinx-autoapi docs generation with cornice service + add docs co…
fmigneault May 3, 2024
55ea968
add frontpage HTML rendering
fmigneault May 4, 2024
4bc301b
add glossary details
fmigneault May 4, 2024
a9d3279
Merge branch 'master' into html-responses
fmigneault May 7, 2024
15619c5
Merge remote-tracking branch 'origin/master' into html-responses
fmigneault May 28, 2024
606a232
Merge branch 'master' into html-responses
fmigneault May 28, 2024
ceafdbc
Merge branch 'master' into html-responses
fmigneault Jun 7, 2024
8fdb293
improve HTML header/breadcrumbs + [WIP] add HTML job list rendering
fmigneault Jun 7, 2024
6653564
add HTML job listing response
fmigneault Jun 7, 2024
c702783
Merge remote-tracking branch 'origin/master' into html-responses
fmigneault Jun 11, 2024
dd9e635
Merge remote-tracking branch 'origin/master' into html-responses
fmigneault Jun 14, 2024
940f490
fix accept header / query format for job logs endpoint
fmigneault Jun 20, 2024
e180e77
Merge branch 'master' into html-responses
fmigneault Jul 9, 2024
dd0dbb4
add YAML OpenAPI response (relates to https://github.com/crim-ca/weav…
fmigneault Jul 9, 2024
7aeb463
Merge branch 'html-responses' of github-crim:crim-ca/weaver into html…
fmigneault Jul 9, 2024
59733e5
fix linting
fmigneault Jul 10, 2024
1a01246
add 'weaver.wps_restapi_html_override_user_agent' option, default HTM…
fmigneault Jul 10, 2024
4711d14
fix missing application/xml for process description endpoint
fmigneault Jul 10, 2024
dd7b71e
fix code linting
fmigneault Jul 10, 2024
cd09c13
fix imports lint
fmigneault Jul 11, 2024
cef5117
fix CSS lint
fmigneault Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,34 @@ Changes

Changes:
--------
- No change.

Fixes:
------
- No change.
- Add support of `HTML` responses for `OGC API - Processes` endpoints
(fixes `#210 <https://github.com/crim-ca/weaver/issues/210>`_).
- Add ``weaver.wps_restapi_html`` configuration setting to control support of `HTML` responses.
- Add ``weaver.wps_restapi_html_override_user_agent`` configuration setting for control of default `HTML` or `JSON`
rendering by requests from web browsers.
- Refactor ``pyramid`` configuration to employ ``Configurator.add_cornice_service``
utility instead of ``Configurator.add_route`` and ``Configurator.add_view`` handlers that were causing a lot of
duplication between the ``cornice.Service`` parametrization and their corresponding view decorators. All metadata
is now embedded within the same decorator operation.
- Add missing documentation for ``weaver.wps_restapi_doc`` and ``weaver.wps_restapi_ref`` configuration settings.
- Modified the base path/URL resolution of the `OpenAPI` endpoint to be located at the application root instead of being
nested under ``weaver.wps_restapi_path`` or ``weaver.wps_restapi_url``, since the OpenAPI `JSON` and `HTML` responses
are employed for representing supported requests and responses of both the `REST` and the `OWS` `WPS` interfaces.
- Update `Swagger-UI` version for latest rendering fixes of `OpenAPI` definitions.
- Add automatic redirect from ``/api?f=json`` to ``/json`` response to allow `OpenAPI` schema access directly
from the same endpoint as the `Swagger-UI` rendering of the schemas. The ``Accept`` header
for ``application/json`` or explicitly ``application/vnd.oai.openapi+json; version=3.0`` are also supported
(fixes `#623 <https://github.com/crim-ca/weaver/issues/623>`_)
- Add `OpenAPI` response rendering as `YAML` using ``/api?f=yaml`` or ``Accept: application/yaml``
(relates to `#456 <https://github.com/crim-ca/weaver/issues/456>`_).

Fixes:
------
- Fix ``weaver.wps_restapi_path`` incorrectly resolved when populating `Process` paging links.
- Fix invalid resolution of reported API endpoints in the `OpenAPI` and frontpage response when
``weaver.wps_restapi_path``, ``weaver.wps_restapi_url``, ``weaver.wps_path`` or ``weaver.wps_url``
were set to other prefix path values than the default root base URL.
- Fix ``weaver.formats.OutputFormat`` to return ``JSON`` by default when an invalid format could not be resolved.

.. _changes_5.6.1:

Expand Down
6 changes: 6 additions & 0 deletions config/weaver.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ weaver.wps_metadata_contact_role=Information
weaver.wps_restapi = true
weaver.wps_restapi_url =
weaver.wps_restapi_path = /
# Allow OGC API - Processes endpoints to render
# contents in HTML as alternate responses to JSON.
weaver.wps_restapi_html = true
# Special handling of rendering default HTML vs JSON by web browsers.
# See documentation for details.
weaver.wps_restapi_html_override_user_agent = false

# --- Weaver job email notification ---
weaver.wps_email_encrypt_salt = salty-email
Expand Down
22 changes: 19 additions & 3 deletions docs/source/appendix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Glossary
API
| Application Programming Interface
| Most typically, referring to the use of HTTP(S) requests following an :term:`OpenAPI` specification.
|
| In the context of this project, it is also used in some occasion to refer to the RESTful interface
of :term:`OGC API - Processes`, in contrast to the :term:`OWS` :term:`WPS` interface.

Application Package
General term that refers to *"what and how to execute"* the :term:`Process`. Application Packages provide the
Expand Down Expand Up @@ -110,9 +113,18 @@ Glossary
Ontology that regroups multiple definitions, amongst which `Weaver` looks up most of its known and supported
:term:`MIME-types` (|iana-link|_) when resolving file formats.

HTML
| HyperText Markup Language
| Alternative representation of some endpoints provided by the application.
Requires appropriate ``Accept`` header or ``f``/``format`` query to return this format.

.. seealso::
See :ref:`OpenAPI Specification` for details.

JSON
| JavaScript Object Notation
| Default data representation of all objects contained in the application or for their creation.
| Default data representation of all objects contained in the application or for their creation
when using the :term:`API`, except for the :term:`OWS` :term:`WPS` endpoint.

Job
Definition of a :term:`Process` execution state with applicable operation metadata.
Expand Down Expand Up @@ -262,8 +274,12 @@ Glossary

XML
| Extensible Markup Language
| Alternative representation of some data object provided by the application. Requires appropriate ``Accept``
header to return this format. See :ref:`OpenAPI Specification` for details.
| Alternative representation of some data object provided by the application.
Requires appropriate ``Accept`` header or ``f``/``format`` query to return this format.
For the :term:`OWS` :term:`WPS` endpoint, this is the default representation instead of :term:`JSON`.

.. seealso::
See :ref:`OpenAPI Specification` for details.

YAML
| YAML Ain't Markup Language
Expand Down
9 changes: 8 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,16 @@ def doc_redirect_include(file_path):
# configuration for the purpose of parsing the source to generate the OpenAPI
config = Configurator(settings={"weaver.wps": True, "weaver.wps_restapi": True, "weaver.build_docs": True})
config.include("weaver") # need to include package to apply decorators and parse routes
config.commit()
api_spec_file = os.path.join(DOC_BLD_ROOT, "api.json")
# must disable references when using redoc (alpha version note rendering them correctly)
api_spec_json = get_openapi_json(http_host="example", http_scheme="https", use_docstring_summary=True, use_refs=False)
api_spec_json = get_openapi_json(
http_host="example",
http_scheme="https",
use_docstring_summary=True,
use_refs=False,
container=config,
)
if not os.path.isdir(DOC_BLD_ROOT):
os.makedirs(DOC_BLD_ROOT)
with open(api_spec_file, "w") as f:
Expand Down
Loading
Loading