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

[erlang-client] Fix url path generation being passed to hackney_url #14821

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

dweinstein
Copy link
Contributor

@dweinstein dweinstein commented Feb 26, 2023

This change is attempting to fix a regression in URL Paths in the erlang-client. The current pet_store sample erlang-client does not work against the real petstore.swagger.io because of a regression in the Path introduced in cdc0076.

Currently if one makes a request for pet id 10 the api client will make a request for %0a instead.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date.sh
    
    Commit all changed files.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@dweinstein dweinstein changed the title [erlang-client] Fix Path [erlang-client] Fix url path generation being passed to hackney_url Feb 26, 2023
@dweinstein
Copy link
Contributor Author

dweinstein commented Feb 26, 2023

Looks like the change to the path generation was made in cdc0076 which was trying to fix another issue perhaps.

cdc0076#diff-8a7b672a5f73867d594118b21ae6930335ddfb72e820a10c1c94a2773a494e76R6-R24

Here's an example where the current sample client fails--we are supposed to be requesting pet id 10 but instead we request %0A:

2> petstore_pet_api:get_pet_by_id(#{}, 10, #{cfg => #{host => "https://petstore.swagger.io"}}).
[hackney trace 80 <0.275.0> 2023:02:26 18:39:25 4415] request 
   Content: [{module,hackney},
             {line,313},
             {method,get},
             {url,{hackney_url,hackney_ssl,https,<<"petstore.swagger.io">>,
                               <<"/v2/pet/\n">>,<<"/v2/pet/%0A">>,<<>>,<<>>, % <---- notice how 10 is converted to %0A
                               "petstore.swagger.io",443,<<>>,<<>>}},
             {headers,[]},
             {body,[]},
             {options,[]}]
[hackney trace 60 <0.275.0> 2023:02:26 18:39:25 4417] request without proxy 
   Content: [{module,hackney},{line,685}]
[hackney trace 60 <0.275.0> 2023:02:26 18:39:25 4425] connect 
   Content: [{module,hackney_connect},
             {line,32},
             {transport,hackney_ssl},
             {host,"petstore.swagger.io"},
             {port,443},
             {dynamic,true}]
[hackney trace 80 <0.275.0> 2023:02:26 18:39:25 4453] no socket in the pool 
   Content: [{module,hackney_pool},{line,88},{pool,default}]
[hackney trace 80 <0.275.0> 2023:02:26 18:39:25 4816] new connection 
   Content: [{module,hackney_pool},{line,94}]
[hackney trace 60 <0.275.0> 2023:02:26 18:39:25 4816] reuse a connection 
   Content: [{module,hackney_connect},{line,216},{pool,default}]
[hackney trace 40 <0.275.0> 2023:02:26 18:39:25 4817] perform request 
   Content: [{module,hackney_request},
             {line,106},
             {header_data,[<<"GET /v2/pet/%0A HTTP/1.1\r\n">>,
                           [[<<"Host">>,": ",<<"petstore.swagger.io">>,"\r\n"],
                            [<<"User-Agent">>,": ",<<"hackney/1.18.1">>,
                             "\r\n"],
                            "\r\n"]]},
             {perform_all,true},
             {expect,false}]
[hackney trace 80 <0.275.0> 2023:02:26 18:39:25 4930] got response 

cc @lixen-wg2 please let me know if you agree?

@wing328
Copy link
Member

wing328 commented Mar 1, 2023

@dweinstein thanks for the PR. can you please PM me via Slack when you've time?

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

@wing328
Copy link
Member

wing328 commented Mar 13, 2023

as discussed, let's move ahead with this change. i'll merge and update the samples.

@wing328 wing328 marked this pull request as ready for review March 13, 2023 07:40
@wing328 wing328 merged commit 43697d2 into OpenAPITools:master Mar 13, 2023
@wing328
Copy link
Member

wing328 commented Mar 13, 2023

samples updated via 6d71db3

@dweinstein dweinstein deleted the patch-2 branch March 17, 2023 00:39
@dweinstein
Copy link
Contributor Author

thanks @wing328 sorry that I hadn't had the chance to make the tweaks to the mustache stuff for the integer handling. It's still on my list.

@wing328
Copy link
Member

wing328 commented Mar 17, 2023

take your time.

in other generators, we use something like String.valueOf() to force the input (integer, double, string, etc) into string.

not sure if erlang has something similar.

@dweinstein dweinstein mentioned this pull request Mar 18, 2023
6 tasks
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.

None yet

2 participants