From 985c4b36a7bdc0e1e06d42aefa16018206c974b6 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 21 Sep 2020 13:23:45 +0800 Subject: [PATCH] [Ruby] fix port in the Ruby client (#7464) * fix port in ruby client * use serverPort instead * update samples, skip if port is 80 --- .../main/java/org/openapitools/codegen/DefaultGenerator.java | 3 +++ .../src/main/resources/ruby-client/configuration.mustache | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index dbb263babdf..4ee200fc1a8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -775,6 +775,9 @@ public class DefaultGenerator implements Generator { bundle.put("basePathWithoutHost", basePathWithoutHost); bundle.put("scheme", URLPathUtils.getScheme(url, config)); bundle.put("host", url.getHost()); + if (url.getPort() != 80 ) { + bundle.put("port", url.getPort()); + } bundle.put("contextPath", contextPath); bundle.put("apiInfo", apis); bundle.put("models", allModels); diff --git a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache index 5e2f57980c4..ba9eda72eef 100644 --- a/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/ruby-client/configuration.mustache @@ -90,7 +90,7 @@ module {{moduleName}} def initialize @scheme = '{{scheme}}' - @host = '{{host}}' + @host = '{{host}}{{#port}}:{{{.}}}{{/port}}' @base_path = '{{contextPath}}' @api_key = {} @api_key_prefix = {}