diff --git a/modules/openapi-generator/src/main/resources/crystal/api.mustache b/modules/openapi-generator/src/main/resources/crystal/api.mustache index 550f017c4c6..8b8daabb5f3 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api.mustache @@ -55,7 +55,7 @@ module {{moduleName}} {{^isContainer}} # verify enum value allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}] - if @api_client.config.client_side_validation && !allowable_values.include?({{{paramName}}}) + if @api_client.config.client_side_validation && !allowable_values.includes?({{{paramName}}}) raise ArgumentError.new("invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}") end {{/isContainer}} @@ -66,13 +66,13 @@ module {{moduleName}} {{#isEnum}} {{#collectionFormat}} allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}] - if @api_client.config.client_side_validation && {{{paramName}}} && {{{paramName}}}.all? { |item| allowable_values.include?(item) } + if @api_client.config.client_side_validation && {{{paramName}}} && {{{paramName}}}.all? { |item| allowable_values.includes?(item) } raise ArgumentError.new("invalid value for \"{{{paramName}}}\", must include one of #{allowable_values}") end {{/collectionFormat}} {{^collectionFormat}} allowable_values = [{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}] - if @api_client.config.client_side_validation && {{{paramName}}} && !allowable_values.include?({{{paramName}}}]) + if @api_client.config.client_side_validation && {{{paramName}}} && !allowable_values.includes?({{{paramName}}}) raise ArgumentError.new("invalid value for \"{{{paramName}}}\", must be one of #{allowable_values}") end {{/collectionFormat}} diff --git a/modules/openapi-generator/src/main/resources/crystal/api_client.mustache b/modules/openapi-generator/src/main/resources/crystal/api_client.mustache index 5352175b00e..6831e51bae0 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api_client.mustache @@ -342,7 +342,7 @@ module {{moduleName}} :verbose => @config.debugging } - if [:post, :patch, :put, :delete].include?(http_method) + if [:post, :patch, :put, :delete].includes?(http_method) req_body = build_request_body(header_params, form_params, opts[:body]) req_opts.update body: req_body if @config.debugging diff --git a/modules/openapi-generator/src/main/resources/crystal/api_client_faraday_partial.mustache b/modules/openapi-generator/src/main/resources/crystal/api_client_faraday_partial.mustache index dfef217e037..d1782b5e348 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api_client_faraday_partial.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api_client_faraday_partial.mustache @@ -81,7 +81,7 @@ :verbose => @config.debugging } - if [:post, :patch, :put, :delete].include?(http_method) + if [:post, :patch, :put, :delete].includes?(http_method) req_body = build_request_body(header_params, form_params, opts[:body]) req_opts.update body: req_body if @config.debugging diff --git a/modules/openapi-generator/src/main/resources/crystal/api_client_typhoeus_partial.mustache b/modules/openapi-generator/src/main/resources/crystal/api_client_typhoeus_partial.mustache index d8e95e77461..e076e92c9fd 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api_client_typhoeus_partial.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api_client_typhoeus_partial.mustache @@ -73,7 +73,7 @@ # set custom cert, if provided req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert - if [:post, :patch, :put, :delete].include?(http_method) + if [:post, :patch, :put, :delete].includes?(http_method) req_body = build_request_body(header_params, form_params, opts[:body]) req_opts.update body: req_body if @config.debugging diff --git a/modules/openapi-generator/src/main/resources/crystal/base_object.mustache b/modules/openapi-generator/src/main/resources/crystal/base_object.mustache index c7abd09b36b..22dafd41120 100644 --- a/modules/openapi-generator/src/main/resources/crystal/base_object.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/base_object.mustache @@ -14,7 +14,7 @@ super(attributes) {{/parent}} self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -92,7 +92,7 @@ self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/modules/openapi-generator/src/main/resources/crystal/configuration.mustache b/modules/openapi-generator/src/main/resources/crystal/configuration.mustache index a3a815fc042..7111ba75e75 100644 --- a/modules/openapi-generator/src/main/resources/crystal/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/configuration.mustache @@ -334,12 +334,12 @@ module {{moduleName}} server = servers[index] url = server[:url] - return url unless server.key? :variables + return url unless server.has_key? :variables # go through variable and assign a value server[:variables].each do |name, variable| - if variables.key?(name) - if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) + if variables.has_key?(name) + if (!server[:variables][name].has_key?(:enum_values) || server[:variables][name][:enum_values].includes?(variables[name])) url.gsub! "{" + name.to_s + "}", variables[name] else raise ArgumentError.new("The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}.") diff --git a/modules/openapi-generator/src/main/resources/crystal/partial_model_generic.mustache b/modules/openapi-generator/src/main/resources/crystal/partial_model_generic.mustache index 18f00b1d529..c36181c48dc 100644 --- a/modules/openapi-generator/src/main/resources/crystal/partial_model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/partial_model_generic.mustache @@ -30,7 +30,7 @@ end def valid?(value) - !value || allowable_values.include?(value) + !value || allowable_values.includes?(value) end end @@ -225,7 +225,7 @@ {{/isNullable}} {{#maxLength}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}} - raise ArgumentError.new("invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.") + raise ArgumentError.new("invalid value for \"{{{name}}}\", the character length must be smaller than or equal to {{{maxLength}}}.") end {{/maxLength}} diff --git a/modules/openapi-generator/src/main/resources/crystal/partial_oneof_module.mustache b/modules/openapi-generator/src/main/resources/crystal/partial_oneof_module.mustache index 14dc1635bb7..18c0a0cffdb 100644 --- a/modules/openapi-generator/src/main/resources/crystal/partial_oneof_module.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/partial_oneof_module.mustache @@ -75,7 +75,7 @@ end end - openapi_one_of.include?(:AnyType) ? data : nil + openapi_one_of.includes?(:AnyType) ? data : nil {{/discriminator}} end {{^discriminator}} diff --git a/samples/client/petstore/crystal/src/petstore/api_client.cr b/samples/client/petstore/crystal/src/petstore/api_client.cr index b768948f758..4a87147e84d 100644 --- a/samples/client/petstore/crystal/src/petstore/api_client.cr +++ b/samples/client/petstore/crystal/src/petstore/api_client.cr @@ -350,7 +350,7 @@ module Petstore :verbose => @config.debugging } - if [:post, :patch, :put, :delete].include?(http_method) + if [:post, :patch, :put, :delete].includes?(http_method) req_body = build_request_body(header_params, form_params, opts[:body]) req_opts.update body: req_body if @config.debugging diff --git a/samples/client/petstore/crystal/src/petstore/configuration.cr b/samples/client/petstore/crystal/src/petstore/configuration.cr index 380963045b2..ca837b43ed7 100644 --- a/samples/client/petstore/crystal/src/petstore/configuration.cr +++ b/samples/client/petstore/crystal/src/petstore/configuration.cr @@ -249,12 +249,12 @@ module Petstore server = servers[index] url = server[:url] - return url unless server.key? :variables + return url unless server.has_key? :variables # go through variable and assign a value server[:variables].each do |name, variable| - if variables.key?(name) - if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) + if variables.has_key?(name) + if (!server[:variables][name].has_key?(:enum_values) || server[:variables][name][:enum_values].includes?(variables[name])) url.gsub! "{" + name.to_s + "}", variables[name] else raise ArgumentError.new("The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}.") diff --git a/samples/client/petstore/crystal/src/petstore/models/api_response.cr b/samples/client/petstore/crystal/src/petstore/models/api_response.cr index f6e71542f7e..60c0a64d975 100644 --- a/samples/client/petstore/crystal/src/petstore/models/api_response.cr +++ b/samples/client/petstore/crystal/src/petstore/models/api_response.cr @@ -78,7 +78,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -156,7 +156,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/crystal/src/petstore/models/category.cr b/samples/client/petstore/crystal/src/petstore/models/category.cr index 0fab536acb3..33c9acd68cf 100644 --- a/samples/client/petstore/crystal/src/petstore/models/category.cr +++ b/samples/client/petstore/crystal/src/petstore/models/category.cr @@ -90,7 +90,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -168,7 +168,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/crystal/src/petstore/models/order.cr b/samples/client/petstore/crystal/src/petstore/models/order.cr index 634d33fdae7..0e036a735c3 100644 --- a/samples/client/petstore/crystal/src/petstore/models/order.cr +++ b/samples/client/petstore/crystal/src/petstore/models/order.cr @@ -57,7 +57,7 @@ module Petstore end def valid?(value) - !value || allowable_values.include?(value) + !value || allowable_values.includes?(value) end end @@ -129,7 +129,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -207,7 +207,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/crystal/src/petstore/models/pet.cr b/samples/client/petstore/crystal/src/petstore/models/pet.cr index d4431c6aa1e..460ca48c902 100644 --- a/samples/client/petstore/crystal/src/petstore/models/pet.cr +++ b/samples/client/petstore/crystal/src/petstore/models/pet.cr @@ -57,7 +57,7 @@ module Petstore end def valid?(value) - !value || allowable_values.include?(value) + !value || allowable_values.includes?(value) end end @@ -139,7 +139,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -217,7 +217,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/crystal/src/petstore/models/tag.cr b/samples/client/petstore/crystal/src/petstore/models/tag.cr index fa2968a9035..d377ddcdf74 100644 --- a/samples/client/petstore/crystal/src/petstore/models/tag.cr +++ b/samples/client/petstore/crystal/src/petstore/models/tag.cr @@ -73,7 +73,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -151,7 +151,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end diff --git a/samples/client/petstore/crystal/src/petstore/models/user.cr b/samples/client/petstore/crystal/src/petstore/models/user.cr index d3922e82394..5794e52d4f0 100644 --- a/samples/client/petstore/crystal/src/petstore/models/user.cr +++ b/samples/client/petstore/crystal/src/petstore/models/user.cr @@ -104,7 +104,7 @@ module Petstore def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| - if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + if !attributes[self.class.attribute_map[key]]? && self.class.openapi_nullable.includes?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute @@ -182,7 +182,7 @@ module Petstore self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) + is_nullable = self.class.openapi_nullable.includes?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end