Skip to content

[Ruby] [Faraday] Adds 'params_encoder' config option for clients#9839

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
dkliban:params_encoder
Apr 9, 2022
Merged

[Ruby] [Faraday] Adds 'params_encoder' config option for clients#9839
wing328 merged 1 commit intoOpenAPITools:masterfrom
dkliban:params_encoder

Conversation

@dkliban
Copy link
Contributor

@dkliban dkliban commented Jun 24, 2021

The partial templates were renamed because they no longer hold tls
settings exclusively.

fixes: #9838

@dkliban dkliban changed the title Adds 'params_encoder' config option for Ruby clients using Faraday [Ruby] Adds 'params_encoder' config option for Ruby clients using Faraday Jun 24, 2021
dkliban added a commit to dkliban/pulp-openapi-generator that referenced this pull request Jun 24, 2021
@dkliban dkliban changed the title [Ruby] Adds 'params_encoder' config option for Ruby clients using Faraday [Ruby] [Faraday] Adds 'params_encoder' config option for clients Jun 25, 2021
@wing328
Copy link
Member

wing328 commented Jun 29, 2021

cc @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion: what about declaring the hash inline without declaring a variable request_options to store it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way works for me. I'll update to be inline.

I can't find instructions for how to regenerate the samples. Can you please remind me?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevemind ... I found the command in the failed CI run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you pushed some changes but don't any changes to this file. Did you commit the change before the push?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided not to make the change because the line was very long.

I ran the script to update the samples, but it seems like there are more changes that it didn't pick up. Do you know what I am doing wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ok. Let's see if someone from the community can help make that enhancement later.

I've updated the samples via 46cd6b8

@dkliban dkliban force-pushed the params_encoder branch 2 times, most recently from 95125ac to 7cd00a9 Compare July 4, 2021 01:29
@wing328
Copy link
Member

wing328 commented Jul 13, 2021

CI reported the following errors:

13) Store should fetch an order
      Failure/Error: :params_encoding => @config.params_encoding,
      NoMethodError:
        undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001c3ce30>
        Did you mean?  params_encoder
                       params_encoder=
      # ./lib/petstore/api_client.rb:125:in `build_request'
      # ./lib/petstore/api_client.rb:71:in `block in call_api'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:492:in `block in run_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:509:in `block in build_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:57:in `block in create'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:56:in `tap'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:56:in `create'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:505:in `build_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:487:in `run_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:280:in `post'
      # ./lib/petstore/api_client.rb:70:in `public_send'
      # ./lib/petstore/api_client.rb:70:in `call_api'
      # ./lib/petstore/api/store_api.rb:267:in `place_order_with_http_info'
      # ./lib/petstore/api/store_api.rb:216:in `place_order'
      # ./spec/petstore_helper.rb:32:in `prepare_store'
      # ./spec/custom/store_spec.rb:10:in `block (2 levels) in <top (required)>'

Can you please take a look when you've time?

Ref: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/232392701

@dkliban
Copy link
Contributor Author

dkliban commented Jul 26, 2021

CI reported the following errors:

13) Store should fetch an order
      Failure/Error: :params_encoding => @config.params_encoding,
      NoMethodError:
        undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001c3ce30>
        Did you mean?  params_encoder
                       params_encoder=
      # ./lib/petstore/api_client.rb:125:in `build_request'
      # ./lib/petstore/api_client.rb:71:in `block in call_api'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:492:in `block in run_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:509:in `block in build_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:57:in `block in create'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:56:in `tap'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/request.rb:56:in `create'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:505:in `build_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:487:in `run_request'
      # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.5.0/lib/faraday/connection.rb:280:in `post'
      # ./lib/petstore/api_client.rb:70:in `public_send'
      # ./lib/petstore/api_client.rb:70:in `call_api'
      # ./lib/petstore/api/store_api.rb:267:in `place_order_with_http_info'
      # ./lib/petstore/api/store_api.rb:216:in `place_order'
      # ./spec/petstore_helper.rb:32:in `prepare_store'
      # ./spec/custom/store_spec.rb:10:in `block (2 levels) in <top (required)>'

Can you please take a look when you've time?

Ref: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/232392701

I'll take a look

@dkliban
Copy link
Contributor Author

dkliban commented Mar 28, 2022

@wing328 I finally updated this PR. Please re-review. cc @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02)

@wing328 wing328 added this to the 6.0.0 milestone Apr 5, 2022
@wing328
Copy link
Member

wing328 commented Apr 5, 2022

Travis CI tests failed:

Your RubyGems version (3.0.8) has a bug that prevents `required_ruby_version` from working for Bundler. Any scripts that use `gem install bundler` will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running `gem update --system 3.2.3`
..........................................................................FFFF**FFFFFFFFFF*.......................................................................................................................................................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Pet pet methods should create and get pet with byte array (binary, string)
     # Temporarily skipped with xit
     # ./spec/custom/pet_spec.rb:91

  2) Pet pet methods should get pet in object
     # Temporarily skipped with xit
     # ./spec/custom/pet_spec.rb:110

  3) Store should fetch the inventory in object
     # Temporarily skipped with xit
     # ./spec/custom/store_spec.rb:30

Failures:

  1) Pet pet methods should construct a new pet object
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     1.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          ArgumentError:
            Missing the required parameter 'pet_id' when calling PetApi.delete_pet
          # ./lib/petstore/api/pet_api.rb:111:in `delete_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:95:in `delete_pet'
          # ./spec/custom/pet_spec.rb:14:in `block (2 levels) in <top (required)>'

  2) Pet pet methods should fetch a pet object
     Got 0 failures and 2 other errors:

     2.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     2.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          ArgumentError:
            Missing the required parameter 'pet_id' when calling PetApi.delete_pet
          # ./lib/petstore/api/pet_api.rb:111:in `delete_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:95:in `delete_pet'
          # ./spec/custom/pet_spec.rb:14:in `block (2 levels) in <top (required)>'

  3) Pet pet methods should fetch a pet object with http info
     Got 0 failures and 2 other errors:

     3.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     3.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          ArgumentError:
            Missing the required parameter 'pet_id' when calling PetApi.delete_pet
          # ./lib/petstore/api/pet_api.rb:111:in `delete_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:95:in `delete_pet'
          # ./spec/custom/pet_spec.rb:14:in `block (2 levels) in <top (required)>'

  4) Pet pet methods should not find a pet that does not exist
     Got 0 failures and 2 other errors:

     4.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     4.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          ArgumentError:
            Missing the required parameter 'pet_id' when calling PetApi.delete_pet
          # ./lib/petstore/api/pet_api.rb:111:in `delete_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:95:in `delete_pet'
          # ./spec/custom/pet_spec.rb:14:in `block (2 levels) in <top (required)>'

  5) Pet pet methods should update a pet
     Got 0 failures and 2 other errors:

     5.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     5.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          ArgumentError:
            Missing the required parameter 'pet_id' when calling PetApi.delete_pet
          # ./lib/petstore/api/pet_api.rb:111:in `delete_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:95:in `delete_pet'
          # ./spec/custom/pet_spec.rb:14:in `block (2 levels) in <top (required)>'

  6) Pet pet methods should find pets by status
     Got 0 failures and 2 other errors:

     6.1) Failure/Error: request.options.params_encoding = @config.params_encoding if @config.params_encoding

          NoMethodError:
            undefined method `params_encoding' for #<Petstore::Configuration:0x0000000001536708>
            Did you mean?  params_encoder
                           params_encoder=
          # ./lib/petstore/api_client.rb:132:in `build_request'
          # ./lib/petstore/api_client.rb:72:in `block in call_api'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:513:in `block in run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:530:in `block in build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:56:in `block in create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `tap'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/request.rb:55:in `create'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:526:in `build_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:508:in `run_request'
          # ./vendor/bundle/ruby/2.5.0/gems/faraday-1.10.0/lib/faraday/connection.rb:281:in `post'
          # ./lib/petstore/api_client.rb:71:in `public_send'
          # ./lib/petstore/api_client.rb:71:in `call_api'
          # ./lib/petstore/api/pet_api.rb:81:in `add_pet_with_http_info'
          # ./lib/petstore/api/pet_api.rb:28:in `add_pet'
          # ./spec/petstore_helper.rb:19:in `prepare_pet'
          # ./spec/custom/pet_spec.rb:8:in `block (2 levels) in <top (required)>'

     6.2) Failure/Error: fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"

          Argume

Please take a look when you've time: https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/248929415

To run the test locally please refer to https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests#how-to-add-integration-tests-for-new-petstore-samples.

The partial templates were renamed because they no longer hold tls
settings exclusively.

fixes: OpenAPITools#9838
@wing328
Copy link
Member

wing328 commented Apr 9, 2022

@wing328 wing328 merged commit e783e9b into OpenAPITools:master Apr 9, 2022
cachescrubber pushed a commit to cachescrubber/openapi-generator that referenced this pull request Apr 9, 2022
…penAPITools#9839)

The partial templates were renamed because they no longer hold tls
settings exclusively.

fixes: OpenAPITools#9838
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Ruby Faraday client encodes arrays in parameters only for Rails (array_name[])

2 participants