-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mapping features to crystal client generator (#16253)
- Loading branch information
Showing
8 changed files
with
470 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# #OpenAPI Petstore | ||
# | ||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
# | ||
#The version of the OpenAPI document: 1.0.0 | ||
# | ||
#Generated by: https://openapi-generator.tech | ||
#OpenAPI Generator version: 7.0.0-SNAPSHOT | ||
# | ||
|
||
require "../spec_helper" | ||
require "json" | ||
require "time" | ||
|
||
# Unit tests for Petstore::FakeApi | ||
# Automatically generated by openapi-generator (https://openapi-generator.tech) | ||
# Please update as you see appropriate | ||
describe "FakeApi" do | ||
describe "test an instance of FakeApi" do | ||
it "should create an instance of FakeApi" do | ||
api_instance = Petstore::FakeApi.new | ||
# TODO expect(api_instance).to be_instance_of(Petstore::FakeApi) | ||
end | ||
end | ||
|
||
# unit tests for get_parameter_name_mapping | ||
# parameter name mapping test | ||
# @param _type _type | ||
# @param _type2 type | ||
# @param type_ type_ | ||
# @param type_2 type- | ||
# @param http_debug_option http debug option (to test parameter naming option) | ||
# @param [Hash] opts the optional parameters | ||
# @return [nil] | ||
describe "get_parameter_name_mapping test" do | ||
it "should work" do | ||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html | ||
end | ||
end | ||
|
||
end |
50 changes: 50 additions & 0 deletions
50
samples/client/petstore/crystal/spec/models/another_property_name_mapping_spec.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# #OpenAPI Petstore | ||
# | ||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
# | ||
#The version of the OpenAPI document: 1.0.0 | ||
# | ||
#Generated by: https://openapi-generator.tech | ||
#OpenAPI Generator version: 7.0.0-SNAPSHOT | ||
# | ||
|
||
require "../spec_helper" | ||
require "json" | ||
require "time" | ||
|
||
# Unit tests for Petstore::AnotherPropertyNameMapping | ||
# Automatically generated by openapi-generator (https://openapi-generator.tech) | ||
# Please update as you see appropriate | ||
describe Petstore::AnotherPropertyNameMapping do | ||
|
||
describe "test an instance of AnotherPropertyNameMapping" do | ||
it "should create an instance of AnotherPropertyNameMapping" do | ||
#instance = Petstore::AnotherPropertyNameMapping.new | ||
#expect(instance).to be_instance_of(Petstore::AnotherPropertyNameMapping) | ||
end | ||
end | ||
describe "test attribute 'http_debug_operation'" do | ||
it "should work" do | ||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html | ||
end | ||
end | ||
|
||
describe "test attribute 'underscore_type'" do | ||
it "should work" do | ||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html | ||
end | ||
end | ||
|
||
describe "test attribute '_type'" do | ||
it "should work" do | ||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html | ||
end | ||
end | ||
|
||
describe "test attribute 'type_with_underscore'" do | ||
it "should work" do | ||
# assertion here. ref: https://crystal-lang.org/reference/guides/testing.html | ||
end | ||
end | ||
|
||
end |
104 changes: 104 additions & 0 deletions
104
samples/client/petstore/crystal/src/petstore/api/fake_api.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# #OpenAPI Petstore | ||
# | ||
##This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. | ||
# | ||
#The version of the OpenAPI document: 1.0.0 | ||
# | ||
#Generated by: https://openapi-generator.tech | ||
#OpenAPI Generator version: 7.0.0-SNAPSHOT | ||
# | ||
|
||
require "uri" | ||
|
||
module Petstore | ||
class FakeApi | ||
property api_client : ApiClient | ||
|
||
def initialize(api_client = ApiClient.default) | ||
@api_client = api_client | ||
end | ||
# parameter name mapping test | ||
# @param underscore_type [Int64] _type | ||
# @param _type [String] type | ||
# @param type_with_underscore [String] type_ | ||
# @param type_with_dash [String] type- | ||
# @param http_debug_option [String] http debug option (to test parameter naming option) | ||
# @return [nil] | ||
def get_parameter_name_mapping(underscore_type : Int64, _type : String, type_with_underscore : String, type_with_dash : String, http_debug_option : String) | ||
get_parameter_name_mapping_with_http_info(underscore_type, _type, type_with_underscore, type_with_dash, http_debug_option) | ||
nil | ||
end | ||
|
||
# parameter name mapping test | ||
# @param underscore_type [Int64] _type | ||
# @param _type [String] type | ||
# @param type_with_underscore [String] type_ | ||
# @param type_with_dash [String] type- | ||
# @param http_debug_option [String] http debug option (to test parameter naming option) | ||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers | ||
def get_parameter_name_mapping_with_http_info(underscore_type : Int64, _type : String, type_with_underscore : String, type_with_dash : String, http_debug_option : String) | ||
if @api_client.config.debugging | ||
Log.debug {"Calling API: FakeApi.get_parameter_name_mapping ..."} | ||
end | ||
# verify the required parameter "underscore_type" is set | ||
if @api_client.config.client_side_validation && underscore_type.nil? | ||
raise ArgumentError.new("Missing the required parameter 'underscore_type' when calling FakeApi.get_parameter_name_mapping") | ||
end | ||
# verify the required parameter "_type" is set | ||
if @api_client.config.client_side_validation && _type.nil? | ||
raise ArgumentError.new("Missing the required parameter '_type' when calling FakeApi.get_parameter_name_mapping") | ||
end | ||
# verify the required parameter "type_with_underscore" is set | ||
if @api_client.config.client_side_validation && type_with_underscore.nil? | ||
raise ArgumentError.new("Missing the required parameter 'type_with_underscore' when calling FakeApi.get_parameter_name_mapping") | ||
end | ||
# verify the required parameter "type_with_dash" is set | ||
if @api_client.config.client_side_validation && type_with_dash.nil? | ||
raise ArgumentError.new("Missing the required parameter 'type_with_dash' when calling FakeApi.get_parameter_name_mapping") | ||
end | ||
# verify the required parameter "http_debug_option" is set | ||
if @api_client.config.client_side_validation && http_debug_option.nil? | ||
raise ArgumentError.new("Missing the required parameter 'http_debug_option' when calling FakeApi.get_parameter_name_mapping") | ||
end | ||
# resource path | ||
local_var_path = "/fake/parameter-name-mapping" | ||
|
||
# query parameters | ||
query_params = Hash(String, String).new | ||
query_params["type"] = _type.to_s unless _type.nil? | ||
query_params["http_debug_option"] = http_debug_option.to_s unless http_debug_option.nil? | ||
|
||
# header parameters | ||
header_params = Hash(String, String).new | ||
header_params["_type"] = underscore_type | ||
header_params["type_"] = type_with_underscore | ||
header_params["type-"] = type_with_dash | ||
|
||
# form parameters | ||
form_params = Hash(Symbol, (String | ::File)).new | ||
|
||
# http body (model) | ||
post_body = nil | ||
|
||
# return_type | ||
return_type = nil | ||
|
||
# auth_names | ||
auth_names = [] of String | ||
|
||
data, status_code, headers = @api_client.call_api(:GET, | ||
local_var_path, | ||
:"FakeApi.get_parameter_name_mapping", | ||
return_type, | ||
post_body, | ||
auth_names, | ||
header_params, | ||
query_params, | ||
form_params) | ||
if @api_client.config.debugging | ||
Log.debug {"API called: FakeApi#get_parameter_name_mapping\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"} | ||
end | ||
return nil, status_code, headers | ||
end | ||
end | ||
end |
Oops, something went wrong.