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

Allow use of relative URLs for queries in yaml specification files #331

Closed
jaw111 opened this issue Apr 7, 2021 · 5 comments
Closed

Allow use of relative URLs for queries in yaml specification files #331

jaw111 opened this issue Apr 7, 2021 · 5 comments

Comments

@jaw111
Copy link

jaw111 commented Apr 7, 2021

When using an yaml specification file to generate an API, it appears the queries must be referenced by absolute URLs. This does not make the specifications very portable e.g. if I want to deploy (different versions of) a specification in different environments, I need to change those URLs per environment.

It would be a nice improvement if the query URLs were resolved relative to the URL of the yaml specification file.

@c-martinez
Copy link
Collaborator

c-martinez commented May 18, 2021

Hi @jaw111 -- could you explain your use case a little bit further? Without knowing what you are trying to achieve, I am not sure the yaml specification will work for your. The yaml specification files builds an API from queries which are available on the web. Those queries are findable via their URLs, but it was not designed with the idea of those URLs being dynamic.

My way of viewing the problem is as follows:

  • The same specification file using different URL's depending on the environment will generate different API's.
  • The same specification file using different URL's gives the specification flexibility.
  • The same specification file generating different API's means the specification file could have inconsistent behaviours.

I see it as a trade-off between flexibility and consistency. And while flexibility is always nice to have, I think from the point of view of reproducibility, consistency should take priority.

That is my point of view, but I would like to hear your thoughts.

@jaw111
Copy link
Author

jaw111 commented May 18, 2021 via email

@c-martinez
Copy link
Collaborator

My main worry is that it could become ambiguous which query is behind a specific API endpoint. But after actually I don't think that would be the case. I think it would work as follows:

For a spec file such as:

title: TestAPI
queries:
  - http://otherserver/remote-query.rq
  - ./local-query.rq

Spec file could be available at http://myserver/repo/url.yml and a query on the same folder http://myserver/repo/local-query.rq

This would generate the following API:

Resource URL
Swagger UI http://grlc.io/api-url?specUrl=http://myserver/repo/url.yml
Query 1 http://grlc.io/api-url/local-query?&specUrl=http://myserver/repo/url.yml
Query 2 http://grlc.io/api-url/remote-query?&specUrl=http://myserver/repo/url.yml

If we move the spec file to a different folder in the same server (or even to a different server)

Spec file could be available at http://myserver/other-repo/url.yml and the query on the same folder http://myserver/other-repo/local-query.rq

This would generate the following API:

Resource URL
Swagger UI http://grlc.io/api-url?specUrl=http://myserver/other-repo/url.yml
Query 1 http://grlc.io/api-url/local-query?&specUrl=http://myserver/other-repo/url.yml
Query 2 http://grlc.io/api-url/remote-query?&specUrl=http://myserver/other-repo/url.yml

From the query URL, it is always possible to trace back which query is behind that endpoint. @jaw111, does this cover your expected functionality? Do you see any gaps in what I'm proposing?

@jaw111
Copy link
Author

jaw111 commented May 29, 2021 via email

@c-martinez
Copy link
Collaborator

Ok, created a PR implementing this.

Yes, there might be clashes on the names of the endpoints. Without looking into it, I think only the last endpoint in the specification (with the conflicting name) will be created. But indeed this will happen even with absolute URLs, so perhaps should be a separate issue.

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

No branches or pull requests

3 participants