-
Notifications
You must be signed in to change notification settings - Fork 211
Extend preferredScheme to become baseUrl #102
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
Comments
I think the The issues that I am encountering stems from what you mentioned, that while Swagger makes explicit use of schemes, OAS only implies them. OAS does not guarantee that the URL stored in the I still think |
@Alan-Cha In the context of a Swagger definition, dynamically using multiple servers does not exist, as far as I know. There is only a single URL created from one of the schemes, the host, and the base path. While OAS definitions allow using multiple servers, I think that the |
Maybe I misspoke. By dynamically using multiple servers, I was still talking about in the OAS 3 context. Hmmm, I see what you're saying but at the same time, GraphQL is suited for calling against different backends, using different protocols, and obtaining data from different sources so I don't see it as a far stretch to provide flexibility. In addition, we toyed around with the idea of forming GraphQL interfaces from from multiple APIs. I had this in mind when I proposed the idea of |
@Alan-Cha Exactly, we should leave such cases to the OAS definition! They provide a thought-through, iterated upon, and standardized (and thus also increasingly adopted) mechanism for such complex cases. So the support already exists. The nature of a |
Hello guys, I think we all agree that arbitraly taking the first server of the list is more of a workaround than a feature. So any way that allows to pick a server less arbitraly is good. I see the concern about OAS v3 (list of base urls) vs OAS v2 (schemes). But in both case, what you get in OASGraph is a list of servers. OAS v3 states:
and
So I think that either:
Both ways are not incompatibles though. |
@thejibz Thanks for chiming in! I fully agree with your assessment, the two ways are not incompatible. I think we should offer a Do you have concerns with replacing the |
You're welcome ! +1 for the "baseURL" option. It offers even more control. I already had the case where I had to use an URL not listed in the OAS. I will see what I can do ;) |
@thejibz Hey, I did not want to imply that you should have to take on this issue, of course. I merely wanted to ask for your input, because you raised the original issue and made the PR for the |
@ErikWittern Ok, I must admit I wouldn't mind if you take on this ! I will stay around if you need my input ;) |
As suggested in IBM#102 and added documentation for baseUrl Signed-off-by: Alan Cha <[email protected]>
As suggested in #102 and added documentation for baseUrl Signed-off-by: Alan Cha <[email protected]>
A recent issue (#96) lead to a pull request (#97) by @thejibz introducing the option to pass a
preferredScheme
, e.g., to specify whether to usehttp
orhttps
.This option is relevant mostly in the context of Swagger definitions, though, and does not apply well to OAS 3 definitions: while the former define the base URL to call using
schemes
,host
, andbasePath
fields, the latter use one of multipleServer Object
s to do so. Thus, in the case of an OAS 3 definition being passed to OASGraph, some questions arise: what is the expected behavior if, let's say,preferredScheme
is set tohttps
but there are multiple server objects that define a URL with https? What if none of the server objects defines a URL with https? What if different operations in the OAS reference different server objects with different schemes?Thinking about this, one compromise may be to extend the
preferredScheme
option by changing it into abaseUrl
option. By providing a base URL to call, this option would encompass the functionality provided bypreferredScheme
in the context of a Swagger being passed to OASGraph. In addition, there could be simple semantics to also solve the issue of selecting a server object to use when an OAS 3 is passed to OASGraph: if present, OASGraph will always use the passedbaseUrl
for requests, and ignore server objects. This simplified behavior has, of course, the downside of not allowing to use different servers for different operations. However, if that is desired, I would argue that the OAS definition needs to be changed accordingly. AbaseUrl
option would still be valuable for development and testing purposes.@thejibz and @Alan-Cha, what do you think?
The text was updated successfully, but these errors were encountered: