Open-EO / openeo-api

The openEO API specification
http://api.openeo.org
Apache License 2.0
91 stars 11 forks source link

well-known/openeo confusion #460

Closed soxofaan closed 1 year ago

soxofaan commented 1 year ago

https://github.com/Open-EO/openeo-api/blob/16b1122c7090cc4fedcabace48686a4f73c1c876/openapi.yaml#L883-L886

While I was discussing something about .well-known/openeo with @dthiex I found this "URI MUST NOT be versioned" is a bit confusing: is it really "forbidden" to support a not-toplevel .well-known/openeo, e.g. something like https://example.com/api/v1/.well-known/openeo or https://example.com/foobar/.well-known/openeo? Or should it just be a recommendation: "URI SHOULD NOT be versioned" ?

m-mohr commented 1 year ago

https://example.com/api/v1/.well-known/openeo doesn't make a lot of sense because the intention of the well-known document to hide the versioning from the user so that the client simply can choose the best version (i.e. latest supported production usually). It is also meant to provide a uniform URL so whenever your version changes, the user doesn't need to change the URL. So if you version it, the URL to connect to changes from the user POV and stuff may break. So yeah, of course you can relax to "SHOULD NOT", but it really is against what it is meant to be used for so I'd stick with it as it is.

soxofaan commented 1 year ago

I understand the goal of course, but I guess the thing that I find confusing or unclear about the current explanation is that it mixes up two aspects of .well-known URLs:

I think you can have one without the other:

Examples use cases that are not clear how to handle (both from client and back-end viewpoint) from the description:

m-mohr commented 1 year ago

If you click the path in redoc (what renders our OpenAPI docs), you can see the so called "server". You can also see them in the document: https://github.com/Open-EO/openeo-api/blob/master/openapi.yaml#L523 This applies to all endpoints except ./well-known/openeo (i.e. the "API"). For the well-known document (WKD) a separate "server" is specified: https://github.com/Open-EO/openeo-api/blob/master/openapi.yaml#L895

As OpenAPI is/was(?) meant for specific APIs, you can't really fill that very well and it's also not very flexible. What is specified there are really just examples. What it is meant to say is:

Top-level for the WKD is really just what you define as your top-level, but it doesn't make sense to place it wherever versioning is in place. "production" is also some kind of versioning though. So you could also write in the API docs:

A client MUST request https://example.com/blabla/.well-known/openeo if a user tries to connect to https://example.com/blabla.

Whatever the client gets provided by the user, they must append the well-known path to that URL and connect to the newly constructed URL. That can also be in a sub-folder (but ideally it would not be). If that doesn't exist, they fall back to the given URL.

More schematically:

  1. User provides a URL (may consist of protocol, host, tld, port, path) to the client
  2. URL gets parsed, /.well-known/openeo is appended to the path, a request is sent to this URL
    • On success: Read WKD, detect the best entry, and connect to that "API URL"
    • On failure: Directly connect to the given URL as if it would have been detected from the WKD as the "API URL" (that's a fallback mechanism to enforce a specific version and that's why there should not be a well-known versioned document as otherwise you can't enforce this route as it would read the WKD again)