BitMEX / api-connectors

Libraries for connecting to the BitMEX API.
https://www.bitmex.com/app/restAPI
910 stars 795 forks source link

Ruby gem doesn't work (syntax errors in code) #23

Closed hakunin closed 7 years ago

hakunin commented 7 years ago

For instance this bit of code in models/api_key.rb:

    # Check to see if the all the properties in the model are valid
    # @return true if the model is valid
    def valid?
      return false if @id.nil?
      return false if @id.to_s.length < # <-- parse error here
      return false if @secret.nil?
      return false if @secret.to_s.length < # <-- parse error here
      return false if @name.nil?
      return false if @name.to_s.length < # <-- parse error here
      return false if @nonce.nil?
      return false if @cidr.to_s.length < # <-- parse error here
      return false if @user_id.nil?
      return true
    end
STRML commented 7 years ago

Let me regenerate the connector and see if it fixes it.

hakunin commented 7 years ago

Going to http://editor.swagger.io/ and re-generating the ruby gem worked

STRML commented 7 years ago

Something odd about this in swagger-codegen:

https://github.com/swagger-api/swagger-codegen/blob/82b6e81897ac6ab86f5476bbabdf6c68fbcf0ca1/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache#L150

So this shouldn't even print if maxLength is empty, but it does anyway. Other connectors, like Python, have similar logic but don't fail in this way.

STRML commented 7 years ago

Good to go now with swagger-codegen 3.0:

https://github.com/BitMEX/api-connectors/blob/498fa7443a0cb3fb46b2bdb3befb8cdebd4164d7/clients/ruby/lib/swagger_client/models/api_key.rb#L162-L172