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

Comments

Projects
None yet
2 participants
@sanjeevdatla
Copy link

sanjeevdatla commented Apr 8, 2017

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

This comment has been minimized.

Copy link
Member

casualjim commented Apr 10, 2017

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

@sanjeevdatla

This comment has been minimized.

Copy link

sanjeevdatla commented Apr 10, 2017

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

This comment has been minimized.

Copy link

sanjeevdatla commented Apr 10, 2017

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

This comment has been minimized.

Copy link
Member

casualjim commented Apr 22, 2017

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

@casualjim casualjim added the question label Apr 22, 2017

@fredbi fredbi referenced this issue Dec 23, 2017

Merged

A FAQ md to recap questions #1342

4 of 4 tasks complete

@fredbi fredbi closed this in #1342 Dec 23, 2017

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