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

Example for dynamic client? #996

Closed
sanjeevdatla opened this issue Apr 8, 2017 · 4 comments · Fixed by #1342
Closed

Example for dynamic client? #996

sanjeevdatla opened this issue Apr 8, 2017 · 4 comments · Fixed by #1342
Labels

Comments

@sanjeevdatla
Copy link

Problem statement

Just like the untyped dynamic server example in go-swagger, is there an example for a dynamic client. Can a REST client be created at runtime by loading a swagger spec file, without going through a code generation and compilation? Thanks.

@casualjim
Copy link
Member

What would you expect from a dynamic client?
What would it add on top of the default http client?

@sanjeevdatla
Copy link
Author

Thanks for taking the time to ask. If I have the swagger spec file for an existing 3rd party REST service for their application, a dynamic client would allow me to load the swagger spec file and provide the ability to formulate requests and parse responses based on the loaded spec file. For e.g. there are REST client packages for go like go-resty that provide a nice interface to interact with a REST server, but go-resty doesn't comprehend swagger specs.

@sanjeevdatla
Copy link
Author

Adding a bit more context, can I get the rest client functionality without first generating a client using go-swagger and then compiling it back into the code. Can this be done dynamically like the dynamic server example.

@casualjim
Copy link
Member

I think I still don't fully understand the use case because you'd have to do everything the code generator does for you by hand. Every time the API changes you have to do this again.
I get the use case for the server side but for the client side I don't get the value proposition.

That being said you might find this test useful as an example:
https://github.com/go-openapi/runtime/blob/master/client/runtime_test.go#L144-L188

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

Successfully merging a pull request may close this issue.

2 participants