-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
sdk: client libraries for all languages #249
Comments
Auto-generated libraries is probably a good starting point when there is nothing else. But they usually don't follow the form you'd expect from the language you're using them within. I don't want to make any promises for myself and @andrewmcnamara but we might be able to release what we're creating for Ruby as open-source. Although not for our first implementation which is a combination of both it being more tightly wound in our existing application and us still getting our heads around the exact implementation details here. |
That would be awesome, let me know if I can help! :)
|
@arekkas do you have any other plans to include swagger in hydra? |
@amerdidit the api docs are available on apiary, which supports export to swager iirc. |
@arekkas as we discussed in the gitter, I've tried to convert API spec from apiary to swagger and generate code from it in my own project (using go-swagger). You may check results here (this is a folder of my project, containing interface to Hydra and unit-test for it). Here is the difference between API invocation without and with swagger-generated code (to highlight "sdk" usage). update-spec is a script I used to fetch API spec from apiary and convert it to swagger 2.0 yaml with online converter API (you need an account to execute it). After conversion, script applies 3 patches to downloaded yaml file. I intentionally separated this patches to clarify required changes. First of them only fixes spec so it won't fail validation (online or with go-swagger). Next patch adds some missing parts to the spec ( Actual generation runs during project build with Below is a summary of my findings about Hydra API and generation process:
Regarding PR, I just don't know what is worth to pull into Hydra project at the moment. I may give you partially fixed swagger spec (or you may easily create it with my script). But someone should check and fix the rest of the spec. Regarding this issue as whole, I think, I'd be pretty happy to have actualized swagger spec in the Hydra project, so that I would fetch it into my own project, remove all unnecessary parts from it and generate my own lean API. It would be even better, if Hydra used API versioning and versions wouldn't change between major releases. This way, I'd be able just generate "sdk" for my own use on whatever language I need. I suppose, it can be pretty difficult to test and support all SDKs on all different languages. If you want to do this, it's, probably, worth to move this support into different github projects and leave only spec in the main project. If you are interested in using go-swagger in your project, you have a couple of options:
Obviously, you'll need to use some other swagger tool to generate SDKs for other languages. |
Hey @nikolay-turpitko thank you so much for the sump up and the hard work. The system behind apiary is open source, it's called api blueprint. There are some converters for it that work with command line:
Also it looks like apiary will move to OpenAPI spec anyways: https://blog.apiary.io/2016/01/18/We-ve-got-Swagger By the way, I think we should define the APIs in OpenAPI spec as well (which is swagger iirc) |
The api blueprint is: https://gist.github.com/arekkas/e5cd5a455d68ba4e5bc0457144125a68 |
@arekkas I've tried to use both
|
Damn this sucks. Maybe there is no way around this and I just need to convert this manually. Could also be an idea to improve the API docs. |
@arekkas: https://gist.github.com/nikolay-turpitko/472213904f324ef89cb27a9225adb142#file-hydra-yaml I've merged output of all 3 tools. Process was mostly manual. File validates with go-swagger and online swagger editor. Both online and go-swagger can serve it with swagger UI, seems OK. Go code for client also can be generated from it. I've tried to convert it back to apib with apimatic, but, of course, result is not quite similar to original file. You should check this file, because something may be missing. For example, basic auth headers are lost for sure. They, probably, should be similar to Edit: changed link, so it point directly to file, because I added also both script and generated apib there and yaml get lost between them. Also, I've tried to compile generated code, but after some "beautification" - I've changed human readable names in spec to generate less ugly names in the code (don't know how to do it right, probably it should be done right in the swagger spec). It works.
Edit 2: You may also use this link to see spec it UI, just submit it with previous link in the field at the top. And here is the patch which highlights fields of yaml files, used by go-swagger to generate code. It uses tags as package names, so I converted them to lowercase and just one word. It uses |
Hey @nikolay-turpitko thanks for everything. I have some things to do, but I'll check over it soon! |
We now have swagger-based docs! |
This is now possible using swagger-codegen |
Apparently, there are ways to do with using swagger/raml, which can be transformed with e.g. https://apitransformer.com/ or directly from API blueprint
The text was updated successfully, but these errors were encountered: