binance / binance-api-swagger

Swagger for the Binance Public API
132 stars 36 forks source link

Make it possible to generate API client from swagger file #17

Closed inferrna closed 2 years ago

inferrna commented 2 years ago
  1. Currently, swagger-codegen doesn't support oneOf and anyOf tags, sot it needed to be manually fixed each time.

  2. Also, it's just stupid to make things this way. For example: Endpoint /sapi/v1/accountSnapshot has parameter "type" which is enum with values [SPOT, MARGIN, FUTURES] and depending on its value endpoint returns one of [snapshotSpot, snapshotMargin, snapshotFutures]. Which is.. just madness if you use strong-typed language (using weak/dynamic typed language to trade crypto is madness itself). Why don't simple use 3 endpoints with 3 different returning types instead? /sapi/v1/accountSnapshotSpot -> snapshotSpot /sapi/v1/accountSnapshotMargin -> snapshotMargin /sapi/v1/accountSnapshotFutures -> snapshotFutures

  3. No hope you will fix first 2 points, but this one is pretty simple. Please, move inlined responses to the components section. Currently this structures has no names, so swagger-codegen naming it like InlineResponse2005, InlineResponse20054, etc. But when you use a language with types, it is very nice to have not just a variable with some sort of data, but also its type which may be a hint by itself in some cases.

tantialex commented 2 years ago

Currently, swagger-codegen doesn't support oneOf and anyOf tags, sot it needed to be manually fixed each time.

The lack of a functionality of a third-party tool should not impact the content of the core swagger file. Therefore, the ideal solution is for the third-party tool to support oneOf and anyOf tags.

Also, it's just stupid to make things this way. For example: Endpoint /sapi/v1/accountSnapshot has parameter "type" which is enum with values [SPOT, MARGIN, FUTURES] and depending on its value endpoint returns one of [snapshotSpot, snapshotMargin, snapshotFutures]. Which is.. just madness if you use strong-typed language (using weak/dynamic typed language to trade crypto is madness itself). Why don't simple use 3 endpoints with 3 different returning types instead? /sapi/v1/accountSnapshotSpot -> snapshotSpot /sapi/v1/accountSnapshotMargin -> snapshotMargin /sapi/v1/accountSnapshotFutures -> snapshotFutures

This is a design of the API not the swagger implementation.

No hope you will fix first 2 points, but this one is pretty simple. Please, move inlined responses to the components section. Currently this structures has no names, so swagger-codegen naming it like InlineResponse2005, InlineResponse20054, etc. But when you use a language with types, it is very nice to have not just a variable with some sort of data, but also its type which may be a hint by itself in some cases.

Response schema are only moved to the components sections when the schema is used more than once in multiple endpoints, to avoid redundancy.

Overall, the swagger implementation is not intended to be defined by third-party tools.