Skip to content

Conversation

@wing328
Copy link
Member

@wing328 wing328 commented Nov 30, 2020

To fix #8047

TODO: will add a test case shortly

cc @OpenAPITools/generator-core-team

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.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. 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.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

bundle.put("scheme", URLPathUtils.getScheme(url, config));
bundle.put("host", url.getHost());
if (url.getPort() != 80 && url.getPort() != 443 ) {
if (url.getPort() != 80 && url.getPort() != 443 && url.getPort() != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that does the trick but why was the port -1 to begin with? Some default value? Unfortunate conversion or something?
If there's no way to make it so it doesn't get the -1 value I suppose a comment explaining why -1 is a possible value and needs to be handled would help in the future.
Port 80 and 443 people can figure it out, -1, not so much I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

The getPort() function is a part of URL class. The function getPort() returns the port of a specified URL. The function returns the port number or -1 if the port is not set

Ref: https://www.geeksforgeeks.org/url-getport-method-in-java-with-examples/

@wing328 wing328 changed the title Fix port set to -1 Fix port when the URL doesn't have port specified Dec 1, 2020
@wing328 wing328 merged commit e040a5f into master Dec 1, 2020
@wing328 wing328 deleted the fix_port branch December 1, 2020 07:24
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] port :-1 generated in configuration.rb

3 participants