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

STAC and coverages endpoints are duplicated in OpenAPI page #965

Closed
pont-us opened this issue Apr 10, 2024 · 1 comment · Fixed by #1018
Closed

STAC and coverages endpoints are duplicated in OpenAPI page #965

pont-us opened this issue Apr 10, 2024 · 1 comment · Fixed by #1018

Comments

@pont-us
Copy link
Member

pont-us commented Apr 10, 2024

For compatibility with a range of clients, STAC and coverages endpoints need to support URLs both with and without a trailing slash. Due to time pressure during OGC Testbed-19, this was implemented very simplistically by adding an extra api.route decorator to the implementations, e.g.

@api.route(PATH_PREFIX + "/collections")
@api.route(PATH_PREFIX + "/collections/")
class CatalogCollectionsHandler(ApiHandler[StacContext]):
    …

In source code this is non-DRY, and in deployment it has the unfortunate effect of duplicating the generated OpenAPI documentation for every endpoint:

aaaaaaa

Slash / no-slash handling should be implemented in a way that avoids cut-and-paste source code and duplicated OpenAPI entries.

@forman
Copy link
Member

forman commented Jun 5, 2024

My preferred solution:

@api.route("ogc/collections/{collectionId}/coverage", slash=True)
class CoveragesCoverageHandler(ApiHandler[CoveragesContext]):
    ...

where slash=True adds an internal (!) second route with a trailing slash or it causes a redirect. For implementation https://www.tornadoweb.org/en/stable/web.html#tornado.web.addslash and https://www.tornadoweb.org/en/stable/web.html#tornado.web.removeslash might be useful.

pont-us added a commit that referenced this issue Jun 18, 2024
Add an optional "slash" parameter to the server.api.Api.route
decorator, a corresponding constructor parameter and field to
ApiRoute, and code to handle this field to
TornadoFramework.add_routes.

Passing slash=True causes the framework to add an additional
second route, handling the same path as the specified route
but with a suffixed "/" character.

Addresses issue #965.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants