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

Add GDAX OpenAPI specification (only the public API for now) #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tbourvon
Copy link

@tbourvon tbourvon commented Jan 1, 2018

This is a first shot at writing an OpenAPI specification for an exchange.

It's only the public API for now, and it still has some rough edges (for example, most fields should be marked as required so that we don't have useless Option wrappers around the API data models).

The API can be generated using swagger-codegen (https://github.com/swagger-api/swagger-codegen). Note that since the OpenAPI file uses OpenAPI v3.0.0, you need to use the 3.0.0 version of swagger-codegen as well.

There were some issues with the Rust code generation as swagger-codegen is still transitioning to 3.0.0. I submitted PRs upstream to fix the problems I've encountered, they should be merged soon. In the meantime you can build swagger-codegen from my fork (which contains the 4 commits being landed as PRs): https://github.com/tbourvon/swagger-codegen/tree/3.0.0

Since GDAX requires a User-Agent to be provided, here is the full swagger-codegen command you need to run:

java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i apis/gdax/openapi.yaml \
   -l rust \
   -o src/gdax/generated_api/ \
   --http-user-agent "Coinnect/0.5.8"

A very good bonus to this is that the generated API uses Hyper async, so this is already a great step towards the async version of Coinnect.

Feel free to comment if you have specific remarks on the patch. Otherwise, I think it's best to keep the general discussion around OpenAPI in the issue #47.

@hugues31
Copy link
Owner

hugues31 commented Jan 2, 2018

Hi! Thanks for your contribution.
As I was very busy with this end of year holidays I didn't had the time to look at all the discussion around Coinnect. I will look at your OpenAPI implementation tomorrow. I wish you (and all other contributors) a good year ;)

@crackcomm
Copy link

crackcomm commented Jan 3, 2018

I certainly appreciate that very much, thank you @tbourvon.

@hugues31 happy new year to you too :)

@hugues31
Copy link
Owner

hugues31 commented Jan 3, 2018

mmmh.. for some reason when generating the lib with swagger-codegen (version 2.3) I get an error:

[main] ERROR io.swagger.parser.SwaggerCompatConverter - failed to read resource listing
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'openapi': was expecting ('true', 'false' or 'null')
 at [Source: openapi.yaml; line: 1, column: 9]

And same thing with version 3.0 :

Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate model 'Candle'
	at io.swagger.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:409)
	at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:721)
	at io.swagger.codegen.cmd.Generate.run(Generate.java:290)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.github.jknack.handlebars.HandlebarsException: /rust/model.mustache:26:57: found: '-last', expected: 'no viable alternative at input '{{^-last''
  pub fn new({{#requiredVars}}{{name}}: {{{datatype}}}{{^-last}}, {{/-last}}{{/requiredVars}}) -> {{classname}} {

I'm on Mac currently (with java 1.8). I will retry this later

@tbourvon
Copy link
Author

tbourvon commented Jan 3, 2018

Happy new year to all of you!
@hugues31 the error with version 2.3 is normal, since this OpenAPI file uses the 3.0.0 specification.
As for the other error, it's one that my PRs to swagger-codegen fix (but they haven't been merged yet, you can use my fork as indicated in the first post).

@hugues31
Copy link
Owner

hugues31 commented Jan 3, 2018

@tbourvon Oh, my bad! Didn't read that part... I'll try now
EDIT: It works fine now

@crackcomm
Copy link

I hope to see private API too @tbourvon 👍

I will submit pull request with Poloniex private API soon, I will also look around for existing OpenAPI schemas for other exchanges.

@tbourvon
Copy link
Author

tbourvon commented Jan 8, 2018

@crackcomm Will be coming soon, but it's a much bigger piece, and I'm not on holidays anymore.

@crackcomm
Copy link

I have most of Poloniex trading API ready but it needs some polishing.

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

Successfully merging this pull request may close these issues.

3 participants