From 6aab7f31739435a45df0f36eeb4d3c0fc8a21977 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 29 Jan 2022 11:14:57 +0800 Subject: [PATCH] use encode_path instead in crystal --- README.md | 1 + .../src/main/resources/crystal/api.mustache | 2 +- .../client/petstore/crystal/src/petstore/api/pet_api.cr | 8 ++++---- .../client/petstore/crystal/src/petstore/api/store_api.cr | 4 ++-- .../client/petstore/crystal/src/petstore/api/user_api.cr | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6a23fc7554a2..52ce37403e8d 100644 --- a/README.md +++ b/README.md @@ -1052,6 +1052,7 @@ If you want to join the committee, please kindly apply by sending an email to te | C++ | @ravinikam (2017/07) @stkrwork (2017/07) @etherealjoy (2018/02) @martindelille (2018/03) @muttleyxd (2019/08) | | C# | @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) | | Clojure | | +| Crystal | @cyangle (2021/01) | | Dart | @jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08) | | Eiffel | @jvelilla (2017/09) | | Elixir | @mrmstn (2018/12) | diff --git a/modules/openapi-generator/src/main/resources/crystal/api.mustache b/modules/openapi-generator/src/main/resources/crystal/api.mustache index 28758d68a5f3..c39d99bf0fe6 100644 --- a/modules/openapi-generator/src/main/resources/crystal/api.mustache +++ b/modules/openapi-generator/src/main/resources/crystal/api.mustache @@ -125,7 +125,7 @@ module {{moduleName}} {{/hasValidation}} {{/allParams}} # resource path - local_var_path = "{{{path}}}"{{#pathParams}}.sub("{" + "{{baseName}}" + "}", URI.encode({{paramName}}.to_s){{^strictSpecBehavior}}.gsub("%2F", "/"){{/strictSpecBehavior}}){{/pathParams}} + local_var_path = "{{{path}}}"{{#pathParams}}.sub("{" + "{{baseName}}" + "}", URI.encode_path({{paramName}}.to_s){{^strictSpecBehavior}}.gsub("%2F", "/"){{/strictSpecBehavior}}){{/pathParams}} # query parameters query_params = Hash(String, String).new diff --git a/samples/client/petstore/crystal/src/petstore/api/pet_api.cr b/samples/client/petstore/crystal/src/petstore/api/pet_api.cr index a808853db0c5..e4c825e67953 100644 --- a/samples/client/petstore/crystal/src/petstore/api/pet_api.cr +++ b/samples/client/petstore/crystal/src/petstore/api/pet_api.cr @@ -96,7 +96,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'pet_id' when calling PetApi.delete_pet") end # resource path - local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode(pet_id.to_s).gsub("%2F", "/")) + local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode_path(pet_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -274,7 +274,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id") end # resource path - local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode(pet_id.to_s).gsub("%2F", "/")) + local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode_path(pet_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -390,7 +390,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form") end # resource path - local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode(pet_id.to_s).gsub("%2F", "/")) + local_var_path = "/pet/{petId}".sub("{" + "petId" + "}", URI.encode_path(pet_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -449,7 +449,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'pet_id' when calling PetApi.upload_file") end # resource path - local_var_path = "/pet/{petId}/uploadImage".sub("{" + "petId" + "}", URI.encode(pet_id.to_s).gsub("%2F", "/")) + local_var_path = "/pet/{petId}/uploadImage".sub("{" + "petId" + "}", URI.encode_path(pet_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new diff --git a/samples/client/petstore/crystal/src/petstore/api/store_api.cr b/samples/client/petstore/crystal/src/petstore/api/store_api.cr index 633b3ca71fd0..c653a8714a38 100644 --- a/samples/client/petstore/crystal/src/petstore/api/store_api.cr +++ b/samples/client/petstore/crystal/src/petstore/api/store_api.cr @@ -39,7 +39,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'order_id' when calling StoreApi.delete_order") end # resource path - local_var_path = "/store/order/{orderId}".sub("{" + "orderId" + "}", URI.encode(order_id.to_s).gsub("%2F", "/")) + local_var_path = "/store/order/{orderId}".sub("{" + "orderId" + "}", URI.encode_path(order_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -157,7 +157,7 @@ module Petstore end # resource path - local_var_path = "/store/order/{orderId}".sub("{" + "orderId" + "}", URI.encode(order_id.to_s).gsub("%2F", "/")) + local_var_path = "/store/order/{orderId}".sub("{" + "orderId" + "}", URI.encode_path(order_id.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new diff --git a/samples/client/petstore/crystal/src/petstore/api/user_api.cr b/samples/client/petstore/crystal/src/petstore/api/user_api.cr index 9809fc615e87..e40ed1611723 100644 --- a/samples/client/petstore/crystal/src/petstore/api/user_api.cr +++ b/samples/client/petstore/crystal/src/petstore/api/user_api.cr @@ -212,7 +212,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'username' when calling UserApi.delete_user") end # resource path - local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode(username.to_s).gsub("%2F", "/")) + local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode_path(username.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -267,7 +267,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'username' when calling UserApi.get_user_by_name") end # resource path - local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode(username.to_s).gsub("%2F", "/")) + local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode_path(username.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new @@ -451,7 +451,7 @@ module Petstore raise ArgumentError.new("Missing the required parameter 'user' when calling UserApi.update_user") end # resource path - local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode(username.to_s).gsub("%2F", "/")) + local_var_path = "/user/{username}".sub("{" + "username" + "}", URI.encode_path(username.to_s).gsub("%2F", "/")) # query parameters query_params = Hash(String, String).new