From 0e693cd9a84afbe5bd864ad830610e86a15f6982 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 19 Nov 2018 11:05:44 +0800 Subject: [PATCH 01/14] Fix NPE with `cpp-restsdk` client generator (#1477) * fix_cpprest_npe * fix_code_format --- .../languages/CppRestSdkClientCodegen.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java index 5a8424838bad..7e119662ded6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java @@ -285,8 +285,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen { Map operations = (Map) objs.get("operations"); List operationList = (List) operations.get("operation"); for (CodegenOperation op : operationList) { - for(String hdr : op.imports) { - if(importMapping.containsKey(hdr)) { + for (String hdr : op.imports) { + if (importMapping.containsKey(hdr)) { continue; } operations.put("hasModelImport", true); @@ -295,7 +295,7 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen { } return objs; } - + protected boolean isFileSchema(CodegenProperty property) { return property.baseType.equals("HttpContent"); } @@ -411,7 +411,6 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen { @Override public Map postProcessAllModels(final Map models) { - final Map processed = super.postProcessAllModels(models); postProcessParentModels(models); return processed; @@ -432,13 +431,18 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen { */ private void processParentPropertiesInChildModel(final CodegenModel parent, final CodegenModel child) { final Map childPropertiesByName = new HashMap<>(child.vars.size()); - for (final CodegenProperty childSchema : child.vars) { - childPropertiesByName.put(childSchema.name, childSchema); + if (child != null && child.vars != null && !child.vars.isEmpty()) { + for (final CodegenProperty childSchema : child.vars) { + childPropertiesByName.put(childSchema.name, childSchema); + } } - for (final CodegenProperty parentSchema : parent.vars) { - final CodegenProperty duplicatedByParent = childPropertiesByName.get(parentSchema.name); - if (duplicatedByParent != null) { - duplicatedByParent.isInherited = true; + + if (parent != null && parent.vars != null && !parent.vars.isEmpty()) { + for (final CodegenProperty parentSchema : parent.vars) { + final CodegenProperty duplicatedByParent = childPropertiesByName.get(parentSchema.name); + if (duplicatedByParent != null) { + duplicatedByParent.isInherited = true; + } } } } From f58bd6d8399085a3205f5738b949b4d42e5b442f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 19 Nov 2018 11:06:16 +0800 Subject: [PATCH 02/14] fix NPE for scala gatling generator (#1479) --- .../openapitools/codegen/languages/ScalaGatlingCodegen.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java index df68da860498..bf7b0beccf94 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java @@ -239,6 +239,11 @@ public class ScalaGatlingCodegen extends AbstractScalaCodegen implements Codegen continue; } for (Operation operation : path.readOperations()) { + + if (operation.getExtensions() == null) { + operation.setExtensions(new HashMap()); + } + if (!operation.getExtensions().keySet().contains("x-gatling-path")) { if (pathname.contains("{")) { String gatlingPath = pathname.replaceAll("\\{", "\\$\\{"); From b9949e1a8e835a4993c2187580a9ed94ee0b72da Mon Sep 17 00:00:00 2001 From: meganemura Date: Mon, 19 Nov 2018 18:02:19 +0900 Subject: [PATCH 03/14] Generate a ruby-client sample for OpenAPI 2.0 (#1482) * Move output directory for bin/openapi3/ruby-client-petstore.sh $ git mv sample/client/petstore/ruby sample/openapi3/client/petstore/ruby-client * $ bin/ruby-client-petstore.sh * Run bin/ruby-client-petstore.sh in bin/utils/ensure-up-to-date --- bin/openapi3/ruby-client-petstore.sh | 2 +- bin/utils/ensure-up-to-date | 1 + pom.xml | 2 +- samples/client/petstore/ruby/README.md | 3 - samples/client/petstore/ruby/docs/FakeApi.md | 8 +- .../client/petstore/ruby/docs/FormatTest.md | 2 - samples/client/petstore/ruby/docs/StoreApi.md | 2 +- samples/client/petstore/ruby/docs/UserApi.md | 8 +- samples/client/petstore/ruby/lib/petstore.rb | 3 - .../ruby/lib/petstore/api/fake_api.rb | 10 +- .../ruby/lib/petstore/api/store_api.rb | 2 - .../ruby/lib/petstore/api/user_api.rb | 8 - .../ruby/lib/petstore/configuration.rb | 37 +- .../ruby/lib/petstore/models/format_test.rb | 77 +- .../ruby/spec/api/another_fake_api_spec.rb | 20 +- .../petstore/ruby/spec/api/fake_api_spec.rb | 159 +++- .../api/fake_classname_tags123_api_spec.rb | 17 +- .../petstore/ruby/spec/api/pet_api_spec.rb | 52 +- .../petstore/ruby/spec/api/store_api_spec.rb | 25 +- .../petstore/ruby/spec/api/user_api_spec.rb | 45 +- .../petstore/ruby/spec/api_client_spec.rb | 203 ++--- .../petstore/ruby/spec/configuration_spec.rb | 59 +- .../additional_properties_class_spec.rb | 10 +- .../ruby/spec/models/animal_farm_spec.rb | 10 +- .../petstore/ruby/spec/models/animal_spec.rb | 10 +- .../ruby/spec/models/api_response_spec.rb | 10 +- .../array_of_array_of_number_only_spec.rb | 10 +- .../spec/models/array_of_number_only_spec.rb | 10 +- .../ruby/spec/models/array_test_spec.rb | 10 +- .../ruby/spec/models/capitalization_spec.rb | 10 +- .../petstore/ruby/spec/models/cat_spec.rb | 10 +- .../ruby/spec/models/category_spec.rb | 10 +- .../ruby/spec/models/class_model_spec.rb | 10 +- .../petstore/ruby/spec/models/client_spec.rb | 10 +- .../petstore/ruby/spec/models/dog_spec.rb | 10 +- .../ruby/spec/models/enum_arrays_spec.rb | 10 +- .../ruby/spec/models/enum_class_spec.rb | 10 +- .../ruby/spec/models/enum_test_spec.rb | 10 +- .../models/file_schema_test_class_spec.rb | 2 +- .../petstore/ruby/spec/models/file_spec.rb | 2 +- .../ruby/spec/models/format_test_spec.rb | 37 +- .../spec/models/has_only_read_only_spec.rb | 10 +- .../petstore/ruby/spec/models/list_spec.rb | 10 +- .../ruby/spec/models/map_test_spec.rb | 22 +- ...es_and_additional_properties_class_spec.rb | 10 +- .../spec/models/model200_response_spec.rb | 10 +- .../ruby/spec/models/model_return_spec.rb | 10 +- .../petstore/ruby/spec/models/name_spec.rb | 10 +- .../ruby/spec/models/number_only_spec.rb | 10 +- .../petstore/ruby/spec/models/order_spec.rb | 10 +- .../ruby/spec/models/outer_composite_spec.rb | 10 +- .../ruby/spec/models/outer_enum_spec.rb | 10 +- .../petstore/ruby/spec/models/pet_spec.rb | 10 +- .../ruby/spec/models/read_only_first_spec.rb | 10 +- .../spec/models/special_model_name_spec.rb | 10 +- .../spec/models/string_boolean_map_spec.rb | 2 +- .../petstore/ruby/spec/models/tag_spec.rb | 10 +- .../petstore/ruby/spec/models/user_spec.rb | 10 +- .../client/petstore/ruby/spec/spec_helper.rb | 60 +- .../openapi3/client/petstore/ruby/.gitignore | 39 + .../petstore/ruby/.openapi-generator-ignore | 23 + .../petstore/ruby/.openapi-generator/VERSION | 1 + samples/openapi3/client/petstore/ruby/.rspec | 2 + .../client/petstore/ruby/.rubocop.yml | 154 ++++ samples/openapi3/client/petstore/ruby/Gemfile | 8 + .../client/petstore/ruby/Gemfile.lock | 79 ++ .../openapi3/client/petstore/ruby/README.md | 183 ++++ .../openapi3/client/petstore/ruby/Rakefile | 10 + .../ruby/docs/AdditionalPropertiesClass.md | 9 + .../client/petstore/ruby/docs/Animal.md | 9 + .../client/petstore/ruby/docs/AnimalFarm.md | 7 + .../petstore/ruby/docs/AnotherFakeApi.md | 54 ++ .../client/petstore/ruby/docs/ApiResponse.md | 10 + .../ruby/docs/ArrayOfArrayOfNumberOnly.md | 8 + .../petstore/ruby/docs/ArrayOfNumberOnly.md | 8 + .../client/petstore/ruby/docs/ArrayTest.md | 10 + .../petstore/ruby/docs/Capitalization.md | 13 + .../openapi3/client/petstore/ruby/docs/Cat.md | 10 + .../client/petstore/ruby/docs/Category.md | 9 + .../client/petstore/ruby/docs/ClassModel.md | 8 + .../client/petstore/ruby/docs/Client.md | 8 + .../client/petstore/ruby/docs/DefaultApi.md | 0 .../openapi3/client/petstore/ruby/docs/Dog.md | 10 + .../client/petstore/ruby/docs/EnumArrays.md | 9 + .../client/petstore/ruby/docs/EnumClass.md | 7 + .../client/petstore/ruby/docs/EnumTest.md | 12 + .../client/petstore/ruby/docs/FakeApi.md | 615 +++++++++++++ .../ruby/docs/FakeClassnameTags123Api.md | 61 ++ .../client/petstore/ruby/docs/File.md | 8 + .../petstore/ruby/docs/FileSchemaTestClass.md | 9 + .../client/petstore/ruby/docs/Foo.md | 0 .../client/petstore/ruby/docs/FormatTest.md | 22 + .../petstore/ruby/docs/HasOnlyReadOnly.md | 9 + .../ruby/docs/InlineResponseDefault.md | 0 .../client/petstore/ruby/docs/List.md | 8 + .../client/petstore/ruby/docs/MapTest.md | 11 + ...dPropertiesAndAdditionalPropertiesClass.md | 10 + .../petstore/ruby/docs/Model200Response.md | 9 + .../client/petstore/ruby/docs/ModelReturn.md | 8 + .../client/petstore/ruby/docs/Name.md | 11 + .../client/petstore/ruby/docs/NumberOnly.md | 8 + .../client/petstore/ruby/docs/Order.md | 13 + .../petstore/ruby/docs/OuterComposite.md | 10 + .../client/petstore/ruby/docs/OuterEnum.md | 7 + .../openapi3/client/petstore/ruby/docs/Pet.md | 13 + .../client/petstore/ruby/docs/PetApi.md | 475 ++++++++++ .../petstore/ruby/docs/ReadOnlyFirst.md | 9 + .../petstore/ruby/docs/SpecialModelName.md | 8 + .../client/petstore/ruby/docs/StoreApi.md | 192 +++++ .../petstore/ruby/docs/StringBooleanMap.md | 7 + .../openapi3/client/petstore/ruby/docs/Tag.md | 9 + .../client/petstore/ruby/docs/User.md | 15 + .../client/petstore/ruby/docs/UserApi.md | 360 ++++++++ .../openapi3/client/petstore/ruby/git_push.sh | 55 ++ .../client/petstore/ruby/hello.txt | 0 .../client/petstore/ruby/lib/petstore.rb | 84 ++ .../ruby/lib/petstore/api/another_fake_api.rb | 78 ++ .../ruby/lib/petstore/api/default_api.rb | 0 .../ruby/lib/petstore/api/fake_api.rb | 811 ++++++++++++++++++ .../api/fake_classname_tags123_api.rb | 78 ++ .../petstore/ruby/lib/petstore/api/pet_api.rb | 513 +++++++++++ .../ruby/lib/petstore/api/store_api.rb | 234 +++++ .../ruby/lib/petstore/api/user_api.rb | 435 ++++++++++ .../petstore/ruby/lib/petstore/api_client.rb | 389 +++++++++ .../petstore/ruby/lib/petstore/api_error.rb | 38 + .../ruby/lib/petstore/configuration.rb | 305 +++++++ .../models/additional_properties_class.rb | 196 +++++ .../ruby/lib/petstore/models/animal.rb | 199 +++++ .../ruby/lib/petstore/models/animal_farm.rb | 174 ++++ .../ruby/lib/petstore/models/api_response.rb | 201 +++++ .../models/array_of_array_of_number_only.rb | 185 ++++ .../petstore/models/array_of_number_only.rb | 185 ++++ .../ruby/lib/petstore/models/array_test.rb | 207 +++++ .../ruby/lib/petstore/models/body4.rb | 0 .../lib/petstore/models/capitalization.rb | 229 +++++ .../petstore/ruby/lib/petstore/models/cat.rb | 208 +++++ .../ruby/lib/petstore/models/category.rb | 199 +++++ .../ruby/lib/petstore/models/class_model.rb | 184 ++++ .../ruby/lib/petstore/models/client.rb | 183 ++++ .../petstore/ruby/lib/petstore/models/dog.rb | 208 +++++ .../ruby/lib/petstore/models/enum_arrays.rb | 228 +++++ .../ruby/lib/petstore/models/enum_class.rb | 31 + .../ruby/lib/petstore/models/enum_test.rb | 294 +++++++ .../petstore/ruby/lib/petstore/models/file.rb | 185 ++++ .../petstore/models/file_schema_test_class.rb | 194 +++++ .../petstore/ruby/lib/petstore/models/foo.rb | 0 .../ruby/lib/petstore/models/format_test.rb | 528 ++++++++++++ .../lib/petstore/models/has_only_read_only.rb | 192 +++++ .../models/inline_response_default.rb | 0 .../petstore/ruby/lib/petstore/models/list.rb | 183 ++++ .../ruby/lib/petstore/models/map_test.rb | 240 ++++++ ...perties_and_additional_properties_class.rb | 203 +++++ .../lib/petstore/models/model200_response.rb | 193 +++++ .../ruby/lib/petstore/models/model_return.rb | 184 ++++ .../petstore/ruby/lib/petstore/models/name.rb | 216 +++++ .../ruby/lib/petstore/models/number_only.rb | 183 ++++ .../ruby/lib/petstore/models/order.rb | 265 ++++++ .../ruby/lib/petstore/models/outer_boolean.rb | 0 .../lib/petstore/models/outer_composite.rb | 201 +++++ .../ruby/lib/petstore/models/outer_enum.rb | 31 + .../ruby/lib/petstore/models/outer_number.rb | 0 .../ruby/lib/petstore/models/outer_string.rb | 0 .../petstore/ruby/lib/petstore/models/pet.rb | 277 ++++++ .../lib/petstore/models/read_only_first.rb | 192 +++++ .../lib/petstore/models/special_model_name.rb | 183 ++++ .../lib/petstore/models/string_boolean_map.rb | 174 ++++ .../petstore/ruby/lib/petstore/models/tag.rb | 192 +++++ .../petstore/ruby/lib/petstore/models/user.rb | 247 ++++++ .../petstore/ruby/lib/petstore/version.rb | 15 + .../client/petstore/ruby/petstore.gemspec | 45 + .../petstore/ruby/petstore_profiling.output | 0 .../petstore/ruby/petstore_profiling.rb | 0 .../client/petstore/ruby/pom.xml | 0 .../petstore/ruby/press_anykey_to_continue.sh | 0 .../client/petstore/ruby/spec/.spec_helper.rb | 0 .../ruby/spec/api/another_fake_api_spec.rb | 47 + .../ruby/spec/api/default_api_spec.rb | 0 .../petstore/ruby/spec/api/fake_api_spec.rb | 62 ++ .../api/fake_classname_tags123_api_spec.rb | 46 + .../petstore/ruby/spec/api/pet_api_spec.rb | 140 +++ .../petstore/ruby/spec/api/store_api_spec.rb | 86 ++ .../petstore/ruby/spec/api/user_api_spec.rb | 136 +++ .../petstore/ruby/spec/api_client_spec.rb | 277 ++++++ .../petstore/ruby/spec/api_error_spec.rb | 0 .../petstore/ruby/spec/base_object_spec.rb | 0 .../petstore/ruby/spec/configuration_spec.rb | 55 ++ .../additional_properties_class_spec.rb | 47 + .../ruby/spec/models/animal_farm_spec.rb | 35 + .../petstore/ruby/spec/models/animal_spec.rb | 47 + .../ruby/spec/models/api_response_spec.rb | 53 ++ .../array_of_array_of_number_only_spec.rb | 41 + .../spec/models/array_of_number_only_spec.rb | 41 + .../ruby/spec/models/array_test_spec.rb | 53 ++ .../ruby/spec/models/capitalization_spec.rb | 71 ++ .../petstore/ruby/spec/models/cat_spec.rb | 53 ++ .../ruby/spec/models/category_spec.rb | 47 + .../ruby/spec/models/class_model_spec.rb | 41 + .../petstore/ruby/spec/models/client_spec.rb | 41 + .../petstore/ruby/spec/models/dog_spec.rb | 53 ++ .../ruby/spec/models/enum_arrays_spec.rb | 55 ++ .../ruby/spec/models/enum_class_spec.rb | 35 + .../ruby/spec/models/enum_test_spec.rb | 81 ++ .../models/file_schema_test_class_spec.rb | 47 + .../petstore/ruby/spec/models/file_spec.rb | 41 + .../petstore/ruby/spec/models/foo_spec.rb | 0 .../ruby/spec/models/format_test_spec.rb | 140 +++ .../spec/models/has_only_read_only_spec.rb | 47 + .../models/inline_response_default_spec.rb | 0 .../petstore/ruby/spec/models/list_spec.rb | 41 + .../ruby/spec/models/map_test_spec.rb | 51 ++ ...es_and_additional_properties_class_spec.rb | 53 ++ .../spec/models/model200_response_spec.rb | 47 + .../ruby/spec/models/model_return_spec.rb | 41 + .../petstore/ruby/spec/models/name_spec.rb | 59 ++ .../ruby/spec/models/number_only_spec.rb | 41 + .../petstore/ruby/spec/models/order_spec.rb | 75 ++ .../ruby/spec/models/outer_composite_spec.rb | 53 ++ .../ruby/spec/models/outer_enum_spec.rb | 35 + .../petstore/ruby/spec/models/pet_spec.rb | 75 ++ .../ruby/spec/models/read_only_first_spec.rb | 47 + .../spec/models/special_model_name_spec.rb | 41 + .../spec/models/string_boolean_map_spec.rb | 35 + .../petstore/ruby/spec/models/tag_spec.rb | 47 + .../petstore/ruby/spec/models/user_spec.rb | 83 ++ .../client/petstore/ruby/spec/pet_spec.rb | 0 .../client/petstore/ruby/spec/spec_helper.rb | 147 ++++ .../client/petstore/ruby/spec/store_spec.rb | 0 227 files changed, 16501 insertions(+), 629 deletions(-) create mode 100644 samples/openapi3/client/petstore/ruby/.gitignore create mode 100644 samples/openapi3/client/petstore/ruby/.openapi-generator-ignore create mode 100644 samples/openapi3/client/petstore/ruby/.openapi-generator/VERSION create mode 100644 samples/openapi3/client/petstore/ruby/.rspec create mode 100644 samples/openapi3/client/petstore/ruby/.rubocop.yml create mode 100644 samples/openapi3/client/petstore/ruby/Gemfile create mode 100644 samples/openapi3/client/petstore/ruby/Gemfile.lock create mode 100644 samples/openapi3/client/petstore/ruby/README.md create mode 100644 samples/openapi3/client/petstore/ruby/Rakefile create mode 100644 samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Animal.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/AnimalFarm.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/AnotherFakeApi.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ApiResponse.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ArrayTest.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Capitalization.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Cat.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Category.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ClassModel.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Client.md rename samples/{ => openapi3}/client/petstore/ruby/docs/DefaultApi.md (100%) create mode 100644 samples/openapi3/client/petstore/ruby/docs/Dog.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/EnumArrays.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/EnumClass.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/EnumTest.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/FakeApi.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/FakeClassnameTags123Api.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/File.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md rename samples/{ => openapi3}/client/petstore/ruby/docs/Foo.md (100%) create mode 100644 samples/openapi3/client/petstore/ruby/docs/FormatTest.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md rename samples/{ => openapi3}/client/petstore/ruby/docs/InlineResponseDefault.md (100%) create mode 100644 samples/openapi3/client/petstore/ruby/docs/List.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/MapTest.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Model200Response.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ModelReturn.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Name.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/NumberOnly.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Order.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/OuterComposite.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/OuterEnum.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Pet.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/PetApi.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/StoreApi.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/StringBooleanMap.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/Tag.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/User.md create mode 100644 samples/openapi3/client/petstore/ruby/docs/UserApi.md create mode 100644 samples/openapi3/client/petstore/ruby/git_push.sh rename samples/{ => openapi3}/client/petstore/ruby/hello.txt (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/another_fake_api.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/api/default_api.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_api.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/pet_api.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/store_api.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api/user_api.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/animal_farm.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/body4.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/foo.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/inline_response_default.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/outer_boolean.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/outer_number.rb (100%) rename samples/{ => openapi3}/client/petstore/ruby/lib/petstore/models/outer_string.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/string_boolean_map.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb create mode 100644 samples/openapi3/client/petstore/ruby/lib/petstore/version.rb create mode 100644 samples/openapi3/client/petstore/ruby/petstore.gemspec rename samples/{ => openapi3}/client/petstore/ruby/petstore_profiling.output (100%) rename samples/{ => openapi3}/client/petstore/ruby/petstore_profiling.rb (100%) rename samples/{ => openapi3}/client/petstore/ruby/pom.xml (100%) rename samples/{ => openapi3}/client/petstore/ruby/press_anykey_to_continue.sh (100%) rename samples/{ => openapi3}/client/petstore/ruby/spec/.spec_helper.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/another_fake_api_spec.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/api/default_api_spec.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/fake_api_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/pet_api_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/store_api_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/api/user_api_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/api_client_spec.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/api_error_spec.rb (100%) rename samples/{ => openapi3}/client/petstore/ruby/spec/base_object_spec.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/configuration_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/additional_properties_class_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/animal_farm_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/animal_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/api_response_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/array_of_number_only_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/array_test_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/capitalization_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/cat_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/category_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/class_model_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/client_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/dog_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/enum_arrays_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/enum_class_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/enum_test_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/file_spec.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/models/foo_spec.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/format_test_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/has_only_read_only_spec.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/models/inline_response_default_spec.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/list_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/map_test_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/model200_response_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/model_return_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/name_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/number_only_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/order_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/outer_composite_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/outer_enum_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/pet_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/read_only_first_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/special_model_name_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/string_boolean_map_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/tag_spec.rb create mode 100644 samples/openapi3/client/petstore/ruby/spec/models/user_spec.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/pet_spec.rb (100%) create mode 100644 samples/openapi3/client/petstore/ruby/spec/spec_helper.rb rename samples/{ => openapi3}/client/petstore/ruby/spec/store_spec.rb (100%) diff --git a/bin/openapi3/ruby-client-petstore.sh b/bin/openapi3/ruby-client-petstore.sh index 67420ee1df5c..a1daedaccbe5 100755 --- a/bin/openapi3/ruby-client-petstore.sh +++ b/bin/openapi3/ruby-client-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby -DskipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/openapi3/client/petstore/ruby -DskipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/utils/ensure-up-to-date b/bin/utils/ensure-up-to-date index 19d9003d1a06..5f91c3986a50 100755 --- a/bin/utils/ensure-up-to-date +++ b/bin/utils/ensure-up-to-date @@ -11,6 +11,7 @@ sleep 5 # LIST OF SCRIPTS: declare -a scripts=("./bin/openapi3/ruby-client-petstore.sh" +"./bin/ruby-client-petstore.sh" "./bin/java-petstore-all.sh" "./bin/java-jaxrs-petstore-server-all.sh" "./bin/openapi3/jaxrs-jersey-petstore.sh" diff --git a/pom.xml b/pom.xml index 42c022a81dc2..2f002b6778e7 100644 --- a/pom.xml +++ b/pom.xml @@ -1054,7 +1054,7 @@ samples/client/petstore/typescript-angular-v4.3/npm samples/client/petstore/typescript-angular-v6-provided-in-root - samples/client/petstore/ruby + samples/openapi3/client/petstore/ruby samples/server/petstore/rust-server diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 17dab7764b22..9e3a1180a6bf 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -74,7 +74,6 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *Petstore::AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags -*Petstore::DefaultApi* | [**foo_get**](docs/DefaultApi.md#foo_get) | **GET** /foo | *Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | *Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | @@ -131,10 +130,8 @@ Class | Method | HTTP request | Description - [Petstore::EnumTest](docs/EnumTest.md) - [Petstore::File](docs/File.md) - [Petstore::FileSchemaTestClass](docs/FileSchemaTestClass.md) - - [Petstore::Foo](docs/Foo.md) - [Petstore::FormatTest](docs/FormatTest.md) - [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - - [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md) - [Petstore::List](docs/List.md) - [Petstore::MapTest](docs/MapTest.md) - [Petstore::MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md index 3a26c4926c1c..e7e995492663 100644 --- a/samples/client/petstore/ruby/docs/FakeApi.md +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -59,7 +59,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: */* @@ -105,7 +105,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: */* @@ -151,7 +151,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: */* @@ -197,7 +197,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: */* diff --git a/samples/client/petstore/ruby/docs/FormatTest.md b/samples/client/petstore/ruby/docs/FormatTest.md index 8682ea539e82..ad9b8191dceb 100644 --- a/samples/client/petstore/ruby/docs/FormatTest.md +++ b/samples/client/petstore/ruby/docs/FormatTest.md @@ -16,7 +16,5 @@ Name | Type | Description | Notes **date_time** | **DateTime** | | [optional] **uuid** | **String** | | [optional] **password** | **String** | | -**pattern_with_digits** | **String** | A string that is a 10 digit number. Can have leading zeros. | [optional] -**pattern_with_digits_and_delimiter** | **String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 464c8dbb854d..2ebdc4ddc0ed 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -185,7 +185,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/xml, application/json diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md index 8981435d9d9a..ae8f3fad0f13 100644 --- a/samples/client/petstore/ruby/docs/UserApi.md +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -53,7 +53,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: Not defined @@ -95,7 +95,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: Not defined @@ -137,7 +137,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: Not defined @@ -353,7 +353,7 @@ No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: Not defined diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 109971ea30ef..92113f6cbf4b 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -35,10 +35,8 @@ require 'petstore/models/enum_class' require 'petstore/models/enum_test' require 'petstore/models/file' require 'petstore/models/file_schema_test_class' -require 'petstore/models/foo' require 'petstore/models/format_test' require 'petstore/models/has_only_read_only' -require 'petstore/models/inline_response_default' require 'petstore/models/list' require 'petstore/models/map_test' require 'petstore/models/mixed_properties_and_additional_properties_class' @@ -58,7 +56,6 @@ require 'petstore/models/user' # APIs require 'petstore/api/another_fake_api' -require 'petstore/api/default_api' require 'petstore/api/fake_api' require 'petstore/api/fake_classname_tags123_api' require 'petstore/api/pet_api' diff --git a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb index 6ddf4371a962..3c11afd67b55 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -46,8 +46,6 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -95,8 +93,6 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -144,8 +140,6 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -193,8 +187,6 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['*/*']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -593,7 +585,7 @@ module Petstore # query parameters query_params = {} - query_params[:'enum_query_string_array'] = @api_client.build_collection_param(opts[:'enum_query_string_array'], :multi) if !opts[:'enum_query_string_array'].nil? + query_params[:'enum_query_string_array'] = @api_client.build_collection_param(opts[:'enum_query_string_array'], :csv) if !opts[:'enum_query_string_array'].nil? query_params[:'enum_query_string'] = opts[:'enum_query_string'] if !opts[:'enum_query_string'].nil? query_params[:'enum_query_integer'] = opts[:'enum_query_integer'] if !opts[:'enum_query_integer'].nil? query_params[:'enum_query_double'] = opts[:'enum_query_double'] if !opts[:'enum_query_double'].nil? diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 63c02b8e2640..8017a32073e6 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -208,8 +208,6 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 665064293480..1109b183162c 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -50,8 +50,6 @@ module Petstore # header parameters header_params = {} - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -100,8 +98,6 @@ module Petstore # header parameters header_params = {} - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -150,8 +146,6 @@ module Petstore # header parameters header_params = {} - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} @@ -410,8 +404,6 @@ module Petstore # header parameters header_params = {} - # HTTP header 'Content-Type' - header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 20bfc4d720f8..2eab1740879f 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -231,41 +231,8 @@ module Petstore def server_settings [ { - url: "http://{server}.swagger.io:{port}/v2", - description: "petstore server", - variables: { - server: { - description: "No descriptoin provided", - default_value: "petstore", - enum_values: [ - "petstore", - "qa-petstore", - "dev-petstore" - ] - }, - port: { - description: "No descriptoin provided", - default_value: "80", - enum_values: [ - "80", - "8080" - ] - } - } - }, - { - url: "https://localhost:8080/{version}", - description: "The local server", - variables: { - version: { - description: "No descriptoin provided", - default_value: "v2", - enum_values: [ - "v1", - "v2" - ] - } - } + url: "http://petstore.swagger.io:80/v2", + description: "No descriptoin provided", } ] end diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index be1927e8e7f7..2ac0fe6b4b14 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -40,12 +40,6 @@ module Petstore attr_accessor :password - # A string that is a 10 digit number. Can have leading zeros. - attr_accessor :pattern_with_digits - - # A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. - attr_accessor :pattern_with_digits_and_delimiter - # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -61,9 +55,7 @@ module Petstore :'date' => :'date', :'date_time' => :'dateTime', :'uuid' => :'uuid', - :'password' => :'password', - :'pattern_with_digits' => :'pattern_with_digits', - :'pattern_with_digits_and_delimiter' => :'pattern_with_digits_and_delimiter' + :'password' => :'password' } end @@ -82,9 +74,7 @@ module Petstore :'date' => :'Date', :'date_time' => :'DateTime', :'uuid' => :'String', - :'password' => :'String', - :'pattern_with_digits' => :'String', - :'pattern_with_digits_and_delimiter' => :'String' + :'password' => :'String' } end @@ -147,14 +137,6 @@ module Petstore if attributes.has_key?(:'password') self.password = attributes[:'password'] end - - if attributes.has_key?(:'pattern_with_digits') - self.pattern_with_digits = attributes[:'pattern_with_digits'] - end - - if attributes.has_key?(:'pattern_with_digits_and_delimiter') - self.pattern_with_digits_and_delimiter = attributes[:'pattern_with_digits_and_delimiter'] - end end # Show invalid properties with the reasons. Usually used together with valid? @@ -213,6 +195,10 @@ module Petstore invalid_properties.push('invalid value for "byte", byte cannot be nil.') end + if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$) + invalid_properties.push('invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$.') + end + if @date.nil? invalid_properties.push('invalid value for "date", date cannot be nil.') end @@ -229,14 +215,6 @@ module Petstore invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.') end - if !@pattern_with_digits.nil? && @pattern_with_digits !~ Regexp.new(/^\d{10}$/) - invalid_properties.push('invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.') - end - - if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) - invalid_properties.push('invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.') - end - invalid_properties end @@ -256,12 +234,11 @@ module Petstore return false if !@double.nil? && @double < 67.8 return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) return false if @byte.nil? + return false if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$) return false if @date.nil? return false if @password.nil? return false if @password.to_s.length > 64 return false if @password.to_s.length < 10 - return false if !@pattern_with_digits.nil? && @pattern_with_digits !~ Regexp.new(/^\d{10}$/) - return false if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) true end @@ -349,6 +326,20 @@ module Petstore @string = string end + # Custom attribute writer method with validation + # @param [Object] byte Value to be assigned + def byte=(byte) + if byte.nil? + fail ArgumentError, 'byte cannot be nil' + end + + if byte !~ Regexp.new(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$) + fail ArgumentError, 'invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$.' + end + + @byte = byte + end + # Custom attribute writer method with validation # @param [Object] password Value to be assigned def password=(password) @@ -367,26 +358,6 @@ module Petstore @password = password end - # Custom attribute writer method with validation - # @param [Object] pattern_with_digits Value to be assigned - def pattern_with_digits=(pattern_with_digits) - if !pattern_with_digits.nil? && pattern_with_digits !~ Regexp.new(/^\d{10}$/) - fail ArgumentError, 'invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.' - end - - @pattern_with_digits = pattern_with_digits - end - - # Custom attribute writer method with validation - # @param [Object] pattern_with_digits_and_delimiter Value to be assigned - def pattern_with_digits_and_delimiter=(pattern_with_digits_and_delimiter) - if !pattern_with_digits_and_delimiter.nil? && pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) - fail ArgumentError, 'invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.' - end - - @pattern_with_digits_and_delimiter = pattern_with_digits_and_delimiter - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) @@ -404,9 +375,7 @@ module Petstore date == o.date && date_time == o.date_time && uuid == o.uuid && - password == o.password && - pattern_with_digits == o.pattern_with_digits && - pattern_with_digits_and_delimiter == o.pattern_with_digits_and_delimiter + password == o.password end # @see the `==` method @@ -418,7 +387,7 @@ module Petstore # Calculates hash code according to all attributes. # @return [Fixnum] Hash code def hash - [integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password, pattern_with_digits, pattern_with_digits_and_delimiter].hash + [integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password].hash end # Builds the object from hash diff --git a/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb b/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb index 269359233163..29e7b19c54dc 100644 --- a/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/another_fake_api_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 2.3.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -14,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::AnotherFakeApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'AnotherFakeApi' do before do @@ -32,14 +32,14 @@ describe 'AnotherFakeApi' do end end - # unit tests for test_special_tags + # unit tests for call_123_test_special_tags # To test special tags - # To test special tags - # @param body client model + # To test special tags and operation ID starting with number + # @param client client model # @param [Hash] opts the optional parameters # @return [Client] - describe 'test_special_tags test' do - it "should work" do + describe 'call_123_test_special_tags test' do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api/fake_api_spec.rb b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb index 1d6acc72bfa7..8368aac468b2 100644 --- a/samples/client/petstore/ruby/spec/api/fake_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/fake_api_spec.rb @@ -1,16 +1,12 @@ =begin -Swagger Petstore +#OpenAPI Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -License: Apache 2.0 -http://www.apache.org/licenses/LICENSE-2.0.html - -Terms of Service: http://swagger.io/terms/ +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -18,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::FakeApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'FakeApi' do before do @@ -36,25 +32,164 @@ describe 'FakeApi' do end end + # unit tests for fake_outer_boolean_serialize + # Test serialization of outer boolean types + # @param [Hash] opts the optional parameters + # @option opts [BOOLEAN] :body Input boolean as post body + # @return [BOOLEAN] + describe 'fake_outer_boolean_serialize test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for fake_outer_composite_serialize + # Test serialization of object with outer number type + # @param [Hash] opts the optional parameters + # @option opts [OuterComposite] :outer_composite Input composite as post body + # @return [OuterComposite] + describe 'fake_outer_composite_serialize test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for fake_outer_number_serialize + # Test serialization of outer number types + # @param [Hash] opts the optional parameters + # @option opts [Float] :body Input number as post body + # @return [Float] + describe 'fake_outer_number_serialize test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for fake_outer_string_serialize + # Test serialization of outer string types + # @param [Hash] opts the optional parameters + # @option opts [String] :body Input string as post body + # @return [String] + describe 'fake_outer_string_serialize test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_body_with_file_schema + # For this test, the body for this request much reference a schema named `File`. + # @param file_schema_test_class + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'test_body_with_file_schema test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_body_with_query_params + # @param query + # @param user + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'test_body_with_query_params test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_client_model + # To test \"client\" model + # To test \"client\" model + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Client] + describe 'test_client_model test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + # unit tests for test_endpoint_parameters # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # @param number None # @param double None - # @param string None + # @param pattern_without_delimiter None # @param byte None # @param [Hash] opts the optional parameters # @option opts [Integer] :integer None # @option opts [Integer] :int32 None # @option opts [Integer] :int64 None # @option opts [Float] :float None - # @option opts [String] :binary None + # @option opts [String] :string None + # @option opts [File] :binary None # @option opts [Date] :date None # @option opts [DateTime] :date_time None # @option opts [String] :password None + # @option opts [String] :callback None # @return [nil] describe 'test_endpoint_parameters test' do - it "should work" do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_enum_parameters + # To test enum parameters + # To test enum parameters + # @param [Hash] opts the optional parameters + # @option opts [Array] :enum_header_string_array Header parameter enum test (string array) + # @option opts [String] :enum_header_string Header parameter enum test (string) + # @option opts [Array] :enum_query_string_array Query parameter enum test (string array) + # @option opts [String] :enum_query_string Query parameter enum test (string) + # @option opts [Integer] :enum_query_integer Query parameter enum test (double) + # @option opts [Float] :enum_query_double Query parameter enum test (double) + # @option opts [Array] :enum_form_string_array Form parameter enum test (string array) + # @option opts [String] :enum_form_string Form parameter enum test (string) + # @return [nil] + describe 'test_enum_parameters test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_group_parameters + # Fake endpoint to test group parameters (optional) + # Fake endpoint to test group parameters (optional) + # @param required_string_group Required String in group parameters + # @param required_boolean_group Required Boolean in group parameters + # @param required_int64_group Required Integer in group parameters + # @param [Hash] opts the optional parameters + # @option opts [Integer] :string_group String in group parameters + # @option opts [BOOLEAN] :boolean_group Boolean in group parameters + # @option opts [Integer] :int64_group Integer in group parameters + # @return [nil] + describe 'test_group_parameters test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_inline_additional_properties + # test inline additionalProperties + # @param request_body request body + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'test_inline_additional_properties test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for test_json_form_data + # test json serialization of form data + # @param param field1 + # @param param2 field2 + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'test_json_form_data test' do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb b/samples/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb index 581f228fb663..a748b48c3f29 100644 --- a/samples/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb @@ -1,11 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -13,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::FakeClassnameTags123Api -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'FakeClassnameTags123Api' do before do @@ -26,19 +27,19 @@ describe 'FakeClassnameTags123Api' do end describe 'test an instance of FakeClassnameTags123Api' do - it 'should create an instact of FakeClassnameTags123Api' do + it 'should create an instance of FakeClassnameTags123Api' do expect(@instance).to be_instance_of(Petstore::FakeClassnameTags123Api) end end # unit tests for test_classname # To test class name in snake case - # - # @param body client model + # To test class name in snake case + # @param client client model # @param [Hash] opts the optional parameters # @return [Client] describe 'test_classname test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api/pet_api_spec.rb b/samples/client/petstore/ruby/spec/api/pet_api_spec.rb index 75fcc384bd3a..ac6990b1a22a 100644 --- a/samples/client/petstore/ruby/spec/api/pet_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/pet_api_spec.rb @@ -1,16 +1,12 @@ =begin -Swagger Petstore +#OpenAPI Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -License: Apache 2.0 -http://www.apache.org/licenses/LICENSE-2.0.html - -Terms of Service: http://swagger.io/terms/ +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -18,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::PetApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'PetApi' do before do @@ -38,25 +34,23 @@ describe 'PetApi' do # unit tests for add_pet # Add a new pet to the store - # - # @param body Pet object that needs to be added to the store + # @param pet Pet object that needs to be added to the store # @param [Hash] opts the optional parameters # @return [nil] describe 'add_pet test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for delete_pet # Deletes a pet - # # @param pet_id Pet id to delete # @param [Hash] opts the optional parameters # @option opts [String] :api_key # @return [nil] describe 'delete_pet test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -68,7 +62,7 @@ describe 'PetApi' do # @param [Hash] opts the optional parameters # @return [Array] describe 'find_pets_by_status test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -80,7 +74,7 @@ describe 'PetApi' do # @param [Hash] opts the optional parameters # @return [Array] describe 'find_pets_by_tags test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -92,47 +86,57 @@ describe 'PetApi' do # @param [Hash] opts the optional parameters # @return [Pet] describe 'get_pet_by_id test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for update_pet # Update an existing pet - # - # @param body Pet object that needs to be added to the store + # @param pet Pet object that needs to be added to the store # @param [Hash] opts the optional parameters # @return [nil] describe 'update_pet test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for update_pet_with_form # Updates a pet in the store with form data - # # @param pet_id ID of pet that needs to be updated # @param [Hash] opts the optional parameters # @option opts [String] :name Updated name of the pet # @option opts [String] :status Updated status of the pet # @return [nil] describe 'update_pet_with_form test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for upload_file # uploads an image - # # @param pet_id ID of pet to update # @param [Hash] opts the optional parameters # @option opts [String] :additional_metadata Additional data to pass to server # @option opts [File] :file file to upload # @return [ApiResponse] describe 'upload_file test' do - it "should work" do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for upload_file_with_required_file + # uploads an image (required) + # @param pet_id ID of pet to update + # @param required_file file to upload + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @return [ApiResponse] + describe 'upload_file_with_required_file test' do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api/store_api_spec.rb b/samples/client/petstore/ruby/spec/api/store_api_spec.rb index c75373a9ad62..cbe4f7f41b2c 100644 --- a/samples/client/petstore/ruby/spec/api/store_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/store_api_spec.rb @@ -1,16 +1,12 @@ =begin -Swagger Petstore +#OpenAPI Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -License: Apache 2.0 -http://www.apache.org/licenses/LICENSE-2.0.html - -Terms of Service: http://swagger.io/terms/ +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -18,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::StoreApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'StoreApi' do before do @@ -43,7 +39,7 @@ describe 'StoreApi' do # @param [Hash] opts the optional parameters # @return [nil] describe 'delete_order test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -54,7 +50,7 @@ describe 'StoreApi' do # @param [Hash] opts the optional parameters # @return [Hash] describe 'get_inventory test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -66,19 +62,18 @@ describe 'StoreApi' do # @param [Hash] opts the optional parameters # @return [Order] describe 'get_order_by_id test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for place_order # Place an order for a pet - # - # @param body order placed for purchasing the pet + # @param order order placed for purchasing the pet # @param [Hash] opts the optional parameters # @return [Order] describe 'place_order test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api/user_api_spec.rb b/samples/client/petstore/ruby/spec/api/user_api_spec.rb index bacd7c90c9d0..0d2dca6e12b1 100644 --- a/samples/client/petstore/ruby/spec/api/user_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/user_api_spec.rb @@ -1,16 +1,12 @@ =begin -Swagger Petstore +#OpenAPI Petstore -This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -License: Apache 2.0 -http://www.apache.org/licenses/LICENSE-2.0.html - -Terms of Service: http://swagger.io/terms/ +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -18,7 +14,7 @@ require 'spec_helper' require 'json' # Unit tests for Petstore::UserApi -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'UserApi' do before do @@ -39,35 +35,33 @@ describe 'UserApi' do # unit tests for create_user # Create user # This can only be done by the logged in user. - # @param body Created user object + # @param user Created user object # @param [Hash] opts the optional parameters # @return [nil] describe 'create_user test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for create_users_with_array_input # Creates list of users with given input array - # - # @param body List of user object + # @param user List of user object # @param [Hash] opts the optional parameters # @return [nil] describe 'create_users_with_array_input test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for create_users_with_list_input # Creates list of users with given input array - # - # @param body List of user object + # @param user List of user object # @param [Hash] opts the optional parameters # @return [nil] describe 'create_users_with_list_input test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -79,43 +73,40 @@ describe 'UserApi' do # @param [Hash] opts the optional parameters # @return [nil] describe 'delete_user test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for get_user_by_name # Get user by user name - # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] describe 'get_user_by_name test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for login_user # Logs user into the system - # # @param username The user name for login # @param password The password for login in clear text # @param [Hash] opts the optional parameters # @return [String] describe 'login_user test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for logout_user # Logs out current logged in user session - # # @param [Hash] opts the optional parameters # @return [nil] describe 'logout_user test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end @@ -124,11 +115,11 @@ describe 'UserApi' do # Updated user # This can only be done by the logged in user. # @param username name that need to be deleted - # @param body Updated user object + # @param user Updated user object # @param [Hash] opts the optional parameters # @return [nil] describe 'update_user test' do - it "should work" do + it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end diff --git a/samples/client/petstore/ruby/spec/api_client_spec.rb b/samples/client/petstore/ruby/spec/api_client_spec.rb index ec2939f83933..762fac64471d 100644 --- a/samples/client/petstore/ruby/spec/api_client_spec.rb +++ b/samples/client/petstore/ruby/spec/api_client_spec.rb @@ -1,12 +1,20 @@ -# require 'spec_helper' -require File.dirname(__FILE__) + '/spec_helper' +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'spec_helper' describe Petstore::ApiClient do - context 'initialization' do - context 'URL stuff' do - context 'host' do it 'removes http from host' do Petstore.configure { |c| c.host = 'http://example.com' } @@ -40,63 +48,33 @@ describe Petstore::ApiClient do expect(Petstore::Configuration.default.base_path).to eq('') end end - - end - - end - - describe "#update_params_for_auth!" do - it "sets header api-key parameter with prefix" do - Petstore.configure do |c| - c.api_key_prefix['api_key'] = 'PREFIX' - c.api_key['api_key'] = 'special-key' - end - - api_client = Petstore::ApiClient.new - - config2 = Petstore::Configuration.new do |c| - c.api_key_prefix['api_key'] = 'PREFIX2' - c.api_key['api_key'] = 'special-key2' - end - api_client2 = Petstore::ApiClient.new(config2) - - auth_names = ['api_key', 'unknown'] - - header_params = {} - query_params = {} - api_client.update_params_for_auth! header_params, query_params, auth_names - expect(header_params).to eq('api_key' => 'PREFIX special-key') - expect(query_params).to eq({}) - - header_params = {} - query_params = {} - api_client2.update_params_for_auth! header_params, query_params, auth_names - expect(header_params).to eq('api_key' => 'PREFIX2 special-key2') - expect(query_params).to eq({}) - end - - it "sets header api-key parameter without prefix" do - Petstore.configure do |c| - c.api_key_prefix['api_key'] = nil - c.api_key['api_key'] = 'special-key' - end - - api_client = Petstore::ApiClient.new - - header_params = {} - query_params = {} - auth_names = ['api_key', 'unknown'] - api_client.update_params_for_auth! header_params, query_params, auth_names - expect(header_params).to eq('api_key' => 'special-key') - expect(query_params).to eq({}) end end - describe "timeout in #build_request" do + describe 'params_encoding in #build_request' do let(:config) { Petstore::Configuration.new } let(:api_client) { Petstore::ApiClient.new(config) } - it "defaults to 0" do + it 'defaults to nil' do + expect(Petstore::Configuration.default.params_encoding).to eq(nil) + expect(config.params_encoding).to eq(nil) + + request = api_client.build_request(:get, '/test') + expect(request.options[:params_encoding]).to eq(nil) + end + + it 'can be customized' do + config.params_encoding = :multi + request = api_client.build_request(:get, '/test') + expect(request.options[:params_encoding]).to eq(:multi) + end + end + + describe 'timeout in #build_request' do + let(:config) { Petstore::Configuration.new } + let(:api_client) { Petstore::ApiClient.new(config) } + + it 'defaults to 0' do expect(Petstore::Configuration.default.timeout).to eq(0) expect(config.timeout).to eq(0) @@ -104,135 +82,107 @@ describe Petstore::ApiClient do expect(request.options[:timeout]).to eq(0) end - it "can be customized" do + it 'can be customized' do config.timeout = 100 request = api_client.build_request(:get, '/test') expect(request.options[:timeout]).to eq(100) end end - describe "#deserialize" do + describe '#deserialize' do it "handles Array" do api_client = Petstore::ApiClient.new headers = { 'Content-Type' => 'application/json' } response = double('response', headers: headers, body: '[12, 34]') data = api_client.deserialize(response, 'Array') - expect(data).to be_a(Array) + expect(data).to be_instance_of(Array) expect(data).to eq([12, 34]) end - it "handles Array>" do + it 'handles Array>' do api_client = Petstore::ApiClient.new headers = { 'Content-Type' => 'application/json' } response = double('response', headers: headers, body: '[[12, 34], [56]]') data = api_client.deserialize(response, 'Array>') - expect(data).to be_a(Array) + expect(data).to be_instance_of(Array) expect(data).to eq([[12, 34], [56]]) end - it "handles Hash" do + it 'handles Hash' do api_client = Petstore::ApiClient.new headers = { 'Content-Type' => 'application/json' } response = double('response', headers: headers, body: '{"message": "Hello"}') data = api_client.deserialize(response, 'Hash') - expect(data).to be_a(Hash) + expect(data).to be_instance_of(Hash) expect(data).to eq(:message => 'Hello') end - - it "handles Hash" do - api_client = Petstore::ApiClient.new - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: '{"pet": {"id": 1}}') - data = api_client.deserialize(response, 'Hash') - expect(data).to be_a(Hash) - expect(data.keys).to eq([:pet]) - pet = data[:pet] - expect(pet).to be_a(Petstore::Pet) - expect(pet.id).to eq(1) - end - - it "handles Hash>" do - api_client = Petstore::ApiClient.new - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}') - result = api_client.deserialize(response, 'Hash>') - expect(result).to be_a(Hash) - expect(result.keys).to eq([:data]) - data = result[:data] - expect(data).to be_a(Hash) - expect(data.keys).to eq([:pet]) - pet = data[:pet] - expect(pet).to be_a(Petstore::Pet) - expect(pet.id).to eq(1) - end end describe "#object_to_hash" do - it "ignores nils and includes empty arrays" do - api_client = Petstore::ApiClient.new - pet = Petstore::Pet.new - pet.id = 1 - pet.name = '' - pet.status = nil - pet.photo_urls = nil - pet.tags = [] - expected = { id: 1, name: '', tags: [] } - expect(api_client.object_to_hash(pet)).to eq(expected) + it 'ignores nils and includes empty arrays' do + # uncomment below to test object_to_hash for model + # api_client = Petstore::ApiClient.new + # _model = Petstore::ModelName.new + # update the model attribute below + # _model.id = 1 + # update the expected value (hash) below + # expected = {id: 1, name: '', tags: []} + # expect(api_client.object_to_hash(_model)).to eq(expected) end end - describe "#build_collection_param" do + describe '#build_collection_param' do let(:param) { ['aa', 'bb', 'cc'] } let(:api_client) { Petstore::ApiClient.new } - it "works for csv" do + it 'works for csv' do expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc') end - it "works for ssv" do + it 'works for ssv' do expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc') end - it "works for tsv" do + it 'works for tsv' do expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") end - it "works for pipes" do + it 'works for pipes' do expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc') end - it "works for multi" do + it 'works for multi' do expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) end - it "fails for invalid collection format" do - expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID') + it 'fails for invalid collection format' do + expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID') end end - describe "#json_mime?" do + describe '#json_mime?' do let(:api_client) { Petstore::ApiClient.new } - it "works" do - expect(api_client.json_mime?(nil)).to eq(false) - expect(api_client.json_mime?('')).to eq(false) + it 'works' do + expect(api_client.json_mime?(nil)).to eq false + expect(api_client.json_mime?('')).to eq false - expect(api_client.json_mime?('application/json')).to eq(true) - expect(api_client.json_mime?('application/json; charset=UTF8')).to eq(true) - expect(api_client.json_mime?('APPLICATION/JSON')).to eq(true) + expect(api_client.json_mime?('application/json')).to eq true + expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true + expect(api_client.json_mime?('APPLICATION/JSON')).to eq true - expect(api_client.json_mime?('application/xml')).to eq(false) - expect(api_client.json_mime?('text/plain')).to eq(false) - expect(api_client.json_mime?('application/jsonp')).to eq(false) + expect(api_client.json_mime?('application/xml')).to eq false + expect(api_client.json_mime?('text/plain')).to eq false + expect(api_client.json_mime?('application/jsonp')).to eq false end end - describe "#select_header_accept" do + describe '#select_header_accept' do let(:api_client) { Petstore::ApiClient.new } - it "works" do - expect(api_client.select_header_accept(nil)).to eq(nil) - expect(api_client.select_header_accept([])).to eq(nil) + it 'works' do + expect(api_client.select_header_accept(nil)).to be_nil + expect(api_client.select_header_accept([])).to be_nil expect(api_client.select_header_accept(['application/json'])).to eq('application/json') expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') @@ -243,10 +193,10 @@ describe Petstore::ApiClient do end end - describe "#select_header_content_type" do + describe '#select_header_content_type' do let(:api_client) { Petstore::ApiClient.new } - it "works" do + it 'works' do expect(api_client.select_header_content_type(nil)).to eq('application/json') expect(api_client.select_header_content_type([])).to eq('application/json') @@ -258,10 +208,10 @@ describe Petstore::ApiClient do end end - describe "#sanitize_filename" do + describe '#sanitize_filename' do let(:api_client) { Petstore::ApiClient.new } - it "works" do + it 'works' do expect(api_client.sanitize_filename('sun')).to eq('sun') expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif') expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif') @@ -273,5 +223,4 @@ describe Petstore::ApiClient do expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif') end end - end diff --git a/samples/client/petstore/ruby/spec/configuration_spec.rb b/samples/client/petstore/ruby/spec/configuration_spec.rb index e666b7bc0043..d20bbc57b4ba 100644 --- a/samples/client/petstore/ruby/spec/configuration_spec.rb +++ b/samples/client/petstore/ruby/spec/configuration_spec.rb @@ -1,55 +1,42 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + require 'spec_helper' describe Petstore::Configuration do let(:config) { Petstore::Configuration.default } before(:each) do - Petstore.configure do |c| - c.host = 'petstore.swagger.io' - c.base_path = 'v2' - end + # uncomment below to setup host and base_path + # require 'URI' + # uri = URI.parse("http://petstore.swagger.io:80/v2") + # Petstore.configure do |c| + # c.host = uri.host + # c.base_path = uri.path + # end end describe '#base_url' do it 'should have the default value' do - expect(config.base_url).to eq('http://petstore.swagger.io/v2') + # uncomment below to test default value of the base path + # expect(config.base_url).to eq("http://petstore.swagger.io:80/v2") end it 'should remove trailing slashes' do [nil, '', '/', '//'].each do |base_path| config.base_path = base_path - expect(config.base_url).to eq('http://petstore.swagger.io') + # uncomment below to test trailing slashes + # expect(config.base_url).to eq("http://petstore.swagger.io:80/v2") end end end - - describe 'server settings' do - it 'should return an array of server settings' do - expect(config.auth_settings).not_to be_empty - end - - it 'should get the first url' do - url = config.server_url(0, server: "dev-petstore", port: "8080") - expect(url).to eq("http://dev-petstore.swagger.io:8080/v2") - end - - it 'should get the first url with default values' do - url = config.server_url(0) - expect(url).to eq("http://petstore.swagger.io:80/v2") - end - - it 'should get the second url with default values' do - url = config.server_url(1) - expect(url).to eq("https://localhost:8080/v2") - end - - it 'should get the second url' do - url = config.server_url(1, version: "v1") - expect(url).to eq("https://localhost:8080/v1") - end - - it 'should raise error due to invalid enum value' do - expect{config.server_url(1, version: "v6")}.to raise_error(ArgumentError) - end - end end diff --git a/samples/client/petstore/ruby/spec/models/additional_properties_class_spec.rb b/samples/client/petstore/ruby/spec/models/additional_properties_class_spec.rb index 0e4c8bec34b4..11b00d944447 100644 --- a/samples/client/petstore/ruby/spec/models/additional_properties_class_spec.rb +++ b/samples/client/petstore/ruby/spec/models/additional_properties_class_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::AdditionalPropertiesClass -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'AdditionalPropertiesClass' do before do diff --git a/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb b/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb index 895781828d2f..fafc7166178a 100644 --- a/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb +++ b/samples/client/petstore/ruby/spec/models/animal_farm_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::AnimalFarm -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'AnimalFarm' do before do diff --git a/samples/client/petstore/ruby/spec/models/animal_spec.rb b/samples/client/petstore/ruby/spec/models/animal_spec.rb index 6b77f9af7286..2232084f63b2 100644 --- a/samples/client/petstore/ruby/spec/models/animal_spec.rb +++ b/samples/client/petstore/ruby/spec/models/animal_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Animal -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Animal' do before do diff --git a/samples/client/petstore/ruby/spec/models/api_response_spec.rb b/samples/client/petstore/ruby/spec/models/api_response_spec.rb index 52b8420ad71b..8dc41a1514b4 100644 --- a/samples/client/petstore/ruby/spec/models/api_response_spec.rb +++ b/samples/client/petstore/ruby/spec/models/api_response_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ApiResponse -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ApiResponse' do before do diff --git a/samples/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb b/samples/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb index 35bad7d85970..484566641c22 100644 --- a/samples/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb +++ b/samples/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ArrayOfArrayOfNumberOnly -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ArrayOfArrayOfNumberOnly' do before do diff --git a/samples/client/petstore/ruby/spec/models/array_of_number_only_spec.rb b/samples/client/petstore/ruby/spec/models/array_of_number_only_spec.rb index 84d4104b8006..13799c5c42f5 100644 --- a/samples/client/petstore/ruby/spec/models/array_of_number_only_spec.rb +++ b/samples/client/petstore/ruby/spec/models/array_of_number_only_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ArrayOfNumberOnly -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ArrayOfNumberOnly' do before do diff --git a/samples/client/petstore/ruby/spec/models/array_test_spec.rb b/samples/client/petstore/ruby/spec/models/array_test_spec.rb index a6a5fb998a9b..0b5a78b84705 100644 --- a/samples/client/petstore/ruby/spec/models/array_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/array_test_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ArrayTest -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ArrayTest' do before do diff --git a/samples/client/petstore/ruby/spec/models/capitalization_spec.rb b/samples/client/petstore/ruby/spec/models/capitalization_spec.rb index bcaa85523bc6..4f1e4c5e6331 100644 --- a/samples/client/petstore/ruby/spec/models/capitalization_spec.rb +++ b/samples/client/petstore/ruby/spec/models/capitalization_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Capitalization -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Capitalization' do before do diff --git a/samples/client/petstore/ruby/spec/models/cat_spec.rb b/samples/client/petstore/ruby/spec/models/cat_spec.rb index d01ff50499ad..9875f4b5bfa9 100644 --- a/samples/client/petstore/ruby/spec/models/cat_spec.rb +++ b/samples/client/petstore/ruby/spec/models/cat_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Cat -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Cat' do before do diff --git a/samples/client/petstore/ruby/spec/models/category_spec.rb b/samples/client/petstore/ruby/spec/models/category_spec.rb index ab8adb3fdae6..f018bfe471d5 100644 --- a/samples/client/petstore/ruby/spec/models/category_spec.rb +++ b/samples/client/petstore/ruby/spec/models/category_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Category -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Category' do before do diff --git a/samples/client/petstore/ruby/spec/models/class_model_spec.rb b/samples/client/petstore/ruby/spec/models/class_model_spec.rb index 6e5998b54c23..829e8a59043c 100644 --- a/samples/client/petstore/ruby/spec/models/class_model_spec.rb +++ b/samples/client/petstore/ruby/spec/models/class_model_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ClassModel -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ClassModel' do before do diff --git a/samples/client/petstore/ruby/spec/models/client_spec.rb b/samples/client/petstore/ruby/spec/models/client_spec.rb index 5d5766906338..8b7d71bb29a8 100644 --- a/samples/client/petstore/ruby/spec/models/client_spec.rb +++ b/samples/client/petstore/ruby/spec/models/client_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Client -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Client' do before do diff --git a/samples/client/petstore/ruby/spec/models/dog_spec.rb b/samples/client/petstore/ruby/spec/models/dog_spec.rb index 32acf1084db4..b34f329c86b2 100644 --- a/samples/client/petstore/ruby/spec/models/dog_spec.rb +++ b/samples/client/petstore/ruby/spec/models/dog_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Dog -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Dog' do before do diff --git a/samples/client/petstore/ruby/spec/models/enum_arrays_spec.rb b/samples/client/petstore/ruby/spec/models/enum_arrays_spec.rb index 17ac2e5e37f5..ec18c49c1f63 100644 --- a/samples/client/petstore/ruby/spec/models/enum_arrays_spec.rb +++ b/samples/client/petstore/ruby/spec/models/enum_arrays_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::EnumArrays -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'EnumArrays' do before do diff --git a/samples/client/petstore/ruby/spec/models/enum_class_spec.rb b/samples/client/petstore/ruby/spec/models/enum_class_spec.rb index 3c4caca91762..5e9d302f8760 100644 --- a/samples/client/petstore/ruby/spec/models/enum_class_spec.rb +++ b/samples/client/petstore/ruby/spec/models/enum_class_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::EnumClass -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'EnumClass' do before do diff --git a/samples/client/petstore/ruby/spec/models/enum_test_spec.rb b/samples/client/petstore/ruby/spec/models/enum_test_spec.rb index 6b4b966a6a53..9d5e96361c2d 100644 --- a/samples/client/petstore/ruby/spec/models/enum_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/enum_test_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::EnumTest -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'EnumTest' do before do diff --git a/samples/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb b/samples/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb index 4b6fad6e76ee..47e3c86d31d5 100644 --- a/samples/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb +++ b/samples/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb @@ -6,7 +6,7 @@ OpenAPI spec version: 1.0.0 Generated by: https://openapi-generator.tech -OpenAPI Generator version: 3.1.0-SNAPSHOT +OpenAPI Generator version: 3.3.4-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/spec/models/file_spec.rb b/samples/client/petstore/ruby/spec/models/file_spec.rb index 50a9f28078f4..5414e0a5d031 100644 --- a/samples/client/petstore/ruby/spec/models/file_spec.rb +++ b/samples/client/petstore/ruby/spec/models/file_spec.rb @@ -6,7 +6,7 @@ OpenAPI spec version: 1.0.0 Generated by: https://openapi-generator.tech -OpenAPI Generator version: 3.1.0-SNAPSHOT +OpenAPI Generator version: 3.3.4-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/spec/models/format_test_spec.rb b/samples/client/petstore/ruby/spec/models/format_test_spec.rb index 74f4fe9bedd7..10cb1224e7f0 100644 --- a/samples/client/petstore/ruby/spec/models/format_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/format_test_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::FormatTest -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'FormatTest' do before do @@ -110,31 +110,4 @@ describe 'FormatTest' do end end - describe 'test attribute "pattern_with_digits"' do - it 'should accept string "1234567890"' do - @instance.pattern_with_digits = '1234567890' - end - - it 'should accept string with leading zero "0123456789"' do - @instance.pattern_with_digits = '0123456789' - end - - it 'should reject string with non digits "ABC3456789"' do - expect {@instance.pattern_with_digits = 'ABC3456789'}.to raise_error(ArgumentError) - end - - it 'should reject string less than 10 in length "123456789"' do - expect {@instance.pattern_with_digits = '123456789'}.to raise_error(ArgumentError) - end - - it 'should reject string more than 10 in length "0123456789123"' do - expect {@instance.pattern_with_digits = '0123456789123'}.to raise_error(ArgumentError) - end - end - - describe 'test attribute "pattern_with_digits_and_delimiter"' do - it 'should accept string "Image_01"' do - @instance.pattern_with_digits_and_delimiter = 'Image_01' - end - end end diff --git a/samples/client/petstore/ruby/spec/models/has_only_read_only_spec.rb b/samples/client/petstore/ruby/spec/models/has_only_read_only_spec.rb index 9d84c9a07cd0..ae76dd4894ea 100644 --- a/samples/client/petstore/ruby/spec/models/has_only_read_only_spec.rb +++ b/samples/client/petstore/ruby/spec/models/has_only_read_only_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::HasOnlyReadOnly -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'HasOnlyReadOnly' do before do diff --git a/samples/client/petstore/ruby/spec/models/list_spec.rb b/samples/client/petstore/ruby/spec/models/list_spec.rb index 68bb5ae294d6..56d22c819060 100644 --- a/samples/client/petstore/ruby/spec/models/list_spec.rb +++ b/samples/client/petstore/ruby/spec/models/list_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::List -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'List' do before do diff --git a/samples/client/petstore/ruby/spec/models/map_test_spec.rb b/samples/client/petstore/ruby/spec/models/map_test_spec.rb index 1735496e090f..06b75c757ff3 100644 --- a/samples/client/petstore/ruby/spec/models/map_test_spec.rb +++ b/samples/client/petstore/ruby/spec/models/map_test_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::MapTest -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'MapTest' do before do @@ -48,4 +48,16 @@ describe 'MapTest' do end end + describe 'test attribute "direct_map"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "indirect_map"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + end diff --git a/samples/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb b/samples/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb index 510fc0825fac..5d65da14b4d4 100644 --- a/samples/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb +++ b/samples/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::MixedPropertiesAndAdditionalPropertiesClass -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'MixedPropertiesAndAdditionalPropertiesClass' do before do diff --git a/samples/client/petstore/ruby/spec/models/model200_response_spec.rb b/samples/client/petstore/ruby/spec/models/model200_response_spec.rb index 0a72f1cd7a51..987b07cf5fb5 100644 --- a/samples/client/petstore/ruby/spec/models/model200_response_spec.rb +++ b/samples/client/petstore/ruby/spec/models/model200_response_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Model200Response -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Model200Response' do before do diff --git a/samples/client/petstore/ruby/spec/models/model_return_spec.rb b/samples/client/petstore/ruby/spec/models/model_return_spec.rb index 9f0cce65e397..afa182fee452 100644 --- a/samples/client/petstore/ruby/spec/models/model_return_spec.rb +++ b/samples/client/petstore/ruby/spec/models/model_return_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ModelReturn -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ModelReturn' do before do diff --git a/samples/client/petstore/ruby/spec/models/name_spec.rb b/samples/client/petstore/ruby/spec/models/name_spec.rb index c39527e14b26..5ee9c2b9f4e4 100644 --- a/samples/client/petstore/ruby/spec/models/name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/name_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Name -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Name' do before do diff --git a/samples/client/petstore/ruby/spec/models/number_only_spec.rb b/samples/client/petstore/ruby/spec/models/number_only_spec.rb index 6aeeb6ca3271..f5ef7520c303 100644 --- a/samples/client/petstore/ruby/spec/models/number_only_spec.rb +++ b/samples/client/petstore/ruby/spec/models/number_only_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::NumberOnly -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'NumberOnly' do before do diff --git a/samples/client/petstore/ruby/spec/models/order_spec.rb b/samples/client/petstore/ruby/spec/models/order_spec.rb index 8f81f7a766e5..78081ab783e0 100644 --- a/samples/client/petstore/ruby/spec/models/order_spec.rb +++ b/samples/client/petstore/ruby/spec/models/order_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Order -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Order' do before do diff --git a/samples/client/petstore/ruby/spec/models/outer_composite_spec.rb b/samples/client/petstore/ruby/spec/models/outer_composite_spec.rb index d5dce679bcf4..fffe153ed132 100644 --- a/samples/client/petstore/ruby/spec/models/outer_composite_spec.rb +++ b/samples/client/petstore/ruby/spec/models/outer_composite_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::OuterComposite -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'OuterComposite' do before do diff --git a/samples/client/petstore/ruby/spec/models/outer_enum_spec.rb b/samples/client/petstore/ruby/spec/models/outer_enum_spec.rb index 08f34bc4080c..7ee4518ba123 100644 --- a/samples/client/petstore/ruby/spec/models/outer_enum_spec.rb +++ b/samples/client/petstore/ruby/spec/models/outer_enum_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::OuterEnum -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'OuterEnum' do before do diff --git a/samples/client/petstore/ruby/spec/models/pet_spec.rb b/samples/client/petstore/ruby/spec/models/pet_spec.rb index 9f7beebffe64..f40d61ce706a 100644 --- a/samples/client/petstore/ruby/spec/models/pet_spec.rb +++ b/samples/client/petstore/ruby/spec/models/pet_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Pet -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Pet' do before do diff --git a/samples/client/petstore/ruby/spec/models/read_only_first_spec.rb b/samples/client/petstore/ruby/spec/models/read_only_first_spec.rb index d3c18880b6fc..37e9239debb6 100644 --- a/samples/client/petstore/ruby/spec/models/read_only_first_spec.rb +++ b/samples/client/petstore/ruby/spec/models/read_only_first_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::ReadOnlyFirst -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'ReadOnlyFirst' do before do diff --git a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb index 10ae62410016..4e520a9ffa3a 100644 --- a/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb +++ b/samples/client/petstore/ruby/spec/models/special_model_name_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::SpecialModelName -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'SpecialModelName' do before do diff --git a/samples/client/petstore/ruby/spec/models/string_boolean_map_spec.rb b/samples/client/petstore/ruby/spec/models/string_boolean_map_spec.rb index 3f54837a62a4..921a427d6133 100644 --- a/samples/client/petstore/ruby/spec/models/string_boolean_map_spec.rb +++ b/samples/client/petstore/ruby/spec/models/string_boolean_map_spec.rb @@ -6,7 +6,7 @@ OpenAPI spec version: 1.0.0 Generated by: https://openapi-generator.tech -OpenAPI Generator version: 3.0.3-SNAPSHOT +OpenAPI Generator version: 3.3.4-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/spec/models/tag_spec.rb b/samples/client/petstore/ruby/spec/models/tag_spec.rb index f8f824471ff9..314b8a1ae247 100644 --- a/samples/client/petstore/ruby/spec/models/tag_spec.rb +++ b/samples/client/petstore/ruby/spec/models/tag_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::Tag -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'Tag' do before do diff --git a/samples/client/petstore/ruby/spec/models/user_spec.rb b/samples/client/petstore/ruby/spec/models/user_spec.rb index c47ad3967d51..728a827279b9 100644 --- a/samples/client/petstore/ruby/spec/models/user_spec.rb +++ b/samples/client/petstore/ruby/spec/models/user_spec.rb @@ -1,12 +1,12 @@ =begin -#Swagger Petstore +#OpenAPI Petstore #This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git -Swagger Codegen version: 3.0.0-SNAPSHOT + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT =end @@ -15,7 +15,7 @@ require 'json' require 'date' # Unit tests for Petstore::User -# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'User' do before do diff --git a/samples/client/petstore/ruby/spec/spec_helper.rb b/samples/client/petstore/ruby/spec/spec_helper.rb index 953ff788a870..61f41405091b 100644 --- a/samples/client/petstore/ruby/spec/spec_helper.rb +++ b/samples/client/petstore/ruby/spec/spec_helper.rb @@ -1,3 +1,15 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + # load the gem require 'petstore' @@ -97,51 +109,3 @@ RSpec.configure do |config| Kernel.srand config.seed =end end - -# API client (shared between all the test cases) -API_CLIENT = Petstore::ApiClient.new(Petstore::Configuration.new) - -# randomly generate an ID -def random_id - rand(1000000) + 20000 -end - -# create a random pet, return its id -def prepare_pet(pet_api) - pet_id = random_id - category = Petstore::Category.new('id' => 20002, 'name' => 'category test') - tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test') - pet = Petstore::Pet.new('id' => pet_id, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url', - 'category' => category, 'tags' => [tag], 'status' => 'pending') - pet_api.add_pet(pet) - pet_id -end - -# create a random order, return its id -def prepare_store(store_api) - order_id = 5 - order = Petstore::Order.new("id" => order_id, - "petId" => 123, - "quantity" => 789, - "shipDate" => "2015-04-06T23:42:01.678Z", - "status" => "placed", - "complete" => false) - store_api.place_order(order) - order_id -end - -# A random string to tack onto stuff to ensure we're not seeing -# data from a previous test run -RAND = ("a".."z").to_a.sample(8).join - -# helper method to serialize object to json string -def serialize_json(o) - API_CLIENT.object_to_http_body(o) -end - -# helper method to deserialize json string back to object -def deserialize_json(s, type) - headers = { 'Content-Type' => 'application/json' } - response = double('response', headers: headers, body: s) - API_CLIENT.deserialize(response, type) -end diff --git a/samples/openapi3/client/petstore/ruby/.gitignore b/samples/openapi3/client/petstore/ruby/.gitignore new file mode 100644 index 000000000000..05a17cb8f0a0 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.gitignore @@ -0,0 +1,39 @@ +# Generated by: https://openapi-generator.tech +# + +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/samples/openapi3/client/petstore/ruby/.openapi-generator-ignore b/samples/openapi3/client/petstore/ruby/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/openapi3/client/petstore/ruby/.openapi-generator/VERSION b/samples/openapi3/client/petstore/ruby/.openapi-generator/VERSION new file mode 100644 index 000000000000..d077ffb477a4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.openapi-generator/VERSION @@ -0,0 +1 @@ +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/client/petstore/ruby/.rspec b/samples/openapi3/client/petstore/ruby/.rspec new file mode 100644 index 000000000000..83e16f804474 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/samples/openapi3/client/petstore/ruby/.rubocop.yml b/samples/openapi3/client/petstore/ruby/.rubocop.yml new file mode 100644 index 000000000000..98c7e3c7e516 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/.rubocop.yml @@ -0,0 +1,154 @@ +# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) +# Automatically generated by OpenAPI Generator (https://openapi-generator.tech) +AllCops: + TargetRubyVersion: 2.2 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Do not use braces for hash literals when they are the last argument of a +# method call. +Style/BracesAroundHashParameters: + Enabled: true + EnforcedStyle: context_dependent + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/FirstParameterIndentation: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: false + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: rails + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: false + EnforcedStyle: always + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +#Style/StringLiterals: +# Enabled: true +# EnforcedStyle: single_quotes + +# Detect hard tabs, no hard tabs. +Layout/Tab: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingBlankLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: false + +# Use quotes for string literals when they are enough. +Style/UnneededPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true diff --git a/samples/openapi3/client/petstore/ruby/Gemfile b/samples/openapi3/client/petstore/ruby/Gemfile new file mode 100644 index 000000000000..01ba313fe124 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' + +gemspec + +group :development, :test do + gem 'rake', '~> 12.0.0' + gem 'pry-byebug' +end diff --git a/samples/openapi3/client/petstore/ruby/Gemfile.lock b/samples/openapi3/client/petstore/ruby/Gemfile.lock new file mode 100644 index 000000000000..995e71af95b0 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/Gemfile.lock @@ -0,0 +1,79 @@ +PATH + remote: . + specs: + petstore (1.0.0) + json (~> 2.1, >= 2.1.0) + typhoeus (~> 1.0, >= 1.0.1) + +GEM + remote: https://rubygems.org/ + specs: + ZenTest (4.11.1) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + autotest (4.4.6) + ZenTest (>= 4.4.1) + autotest-fsevent (0.2.14) + sys-uname + autotest-growl (0.2.16) + autotest-rails-pure (4.1.2) + byebug (10.0.2) + coderay (1.1.2) + crack (0.4.3) + safe_yaml (~> 1.0.0) + diff-lcs (1.3) + ethon (0.11.0) + ffi (>= 1.3.0) + ffi (1.9.25) + hashdiff (0.3.7) + json (2.1.0) + method_source (0.9.0) + pry (0.11.3) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + pry-byebug (3.6.0) + byebug (~> 10.0) + pry (~> 0.10) + public_suffix (3.0.3) + rake (12.0.0) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) + safe_yaml (1.0.4) + sys-uname (1.0.3) + ffi (>= 1.0.0) + typhoeus (1.3.0) + ethon (>= 0.9.0) + vcr (3.0.3) + webmock (1.24.6) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff + +PLATFORMS + ruby + +DEPENDENCIES + autotest (~> 4.4, >= 4.4.6) + autotest-fsevent (~> 0.2, >= 0.2.12) + autotest-growl (~> 0.2, >= 0.2.16) + autotest-rails-pure (~> 4.1, >= 4.1.2) + petstore! + pry-byebug + rake (~> 12.0.0) + rspec (~> 3.6, >= 3.6.0) + vcr (~> 3.0, >= 3.0.1) + webmock (~> 1.24, >= 1.24.3) + +BUNDLED WITH + 1.16.1 diff --git a/samples/openapi3/client/petstore/ruby/README.md b/samples/openapi3/client/petstore/ruby/README.md new file mode 100644 index 000000000000..17dab7764b22 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/README.md @@ -0,0 +1,183 @@ +# petstore + +Petstore - the Ruby gem for the OpenAPI Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.RubyClientCodegen + +## Installation + +### Build a gem + +To build the Ruby code into a gem: + +```shell +gem build petstore.gemspec +``` + +Then either install the gem locally: + +```shell +gem install ./petstore-1.0.0.gem +``` +(for development, run `gem install --dev ./petstore-1.0.0.gem` to install the development dependencies) + +or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). + +Finally add this to the Gemfile: + + gem 'petstore', '~> 1.0.0' + +### Install from Git + +If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile: + + gem 'petstore', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' + +### Include the Ruby code directly + +Include the Ruby code directly using `-I` as follows: + +```shell +ruby -Ilib script.rb +``` + +## Getting Started + +Please follow the [installation](#installation) procedure and then run the following code: +```ruby +# Load the gem +require 'petstore' + +api_instance = Petstore::AnotherFakeApi.new +client = Petstore::Client.new # Client | client model + +begin + #To test special tags + result = api_instance.call_123_test_special_tags(client) + p result +rescue Petstore::ApiError => e + puts "Exception when calling AnotherFakeApi->call_123_test_special_tags: #{e}" +end + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*Petstore::AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags +*Petstore::DefaultApi* | [**foo_get**](docs/DefaultApi.md#foo_get) | **GET** /foo | +*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | +*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | +*Petstore::FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | +*Petstore::FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +*Petstore::FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +*Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*Petstore::FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*Petstore::FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +*Petstore::FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +*Petstore::FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*Petstore::FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case +*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*Petstore::PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*Petstore::PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*Petstore::PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*Petstore::PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*Petstore::PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*Petstore::PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) +*Petstore::StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +*Petstore::StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*Petstore::StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +*Petstore::StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*Petstore::UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*Petstore::UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*Petstore::UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*Petstore::UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*Petstore::UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*Petstore::UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*Petstore::UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*Petstore::UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation for Models + + - [Petstore::AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [Petstore::Animal](docs/Animal.md) + - [Petstore::AnimalFarm](docs/AnimalFarm.md) + - [Petstore::ApiResponse](docs/ApiResponse.md) + - [Petstore::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [Petstore::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) + - [Petstore::ArrayTest](docs/ArrayTest.md) + - [Petstore::Capitalization](docs/Capitalization.md) + - [Petstore::Cat](docs/Cat.md) + - [Petstore::Category](docs/Category.md) + - [Petstore::ClassModel](docs/ClassModel.md) + - [Petstore::Client](docs/Client.md) + - [Petstore::Dog](docs/Dog.md) + - [Petstore::EnumArrays](docs/EnumArrays.md) + - [Petstore::EnumClass](docs/EnumClass.md) + - [Petstore::EnumTest](docs/EnumTest.md) + - [Petstore::File](docs/File.md) + - [Petstore::FileSchemaTestClass](docs/FileSchemaTestClass.md) + - [Petstore::Foo](docs/Foo.md) + - [Petstore::FormatTest](docs/FormatTest.md) + - [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md) + - [Petstore::List](docs/List.md) + - [Petstore::MapTest](docs/MapTest.md) + - [Petstore::MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Petstore::Model200Response](docs/Model200Response.md) + - [Petstore::ModelReturn](docs/ModelReturn.md) + - [Petstore::Name](docs/Name.md) + - [Petstore::NumberOnly](docs/NumberOnly.md) + - [Petstore::Order](docs/Order.md) + - [Petstore::OuterComposite](docs/OuterComposite.md) + - [Petstore::OuterEnum](docs/OuterEnum.md) + - [Petstore::Pet](docs/Pet.md) + - [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [Petstore::SpecialModelName](docs/SpecialModelName.md) + - [Petstore::StringBooleanMap](docs/StringBooleanMap.md) + - [Petstore::Tag](docs/Tag.md) + - [Petstore::User](docs/User.md) + + +## Documentation for Authorization + + +### api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + +### http_basic_test + +- **Type**: HTTP basic authentication + +### petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - write:pets: modify pets in your account + - read:pets: read your pets + diff --git a/samples/openapi3/client/petstore/ruby/Rakefile b/samples/openapi3/client/petstore/ruby/Rakefile new file mode 100644 index 000000000000..c72ca30d454e --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/Rakefile @@ -0,0 +1,10 @@ +require "bundler/gem_tasks" + +begin + require 'rspec/core/rake_task' + + RSpec::Core::RakeTask.new(:spec) + task default: :spec +rescue LoadError + # no rspec available +end diff --git a/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md new file mode 100644 index 000000000000..c3ee2cdf637b --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/AdditionalPropertiesClass.md @@ -0,0 +1,9 @@ +# Petstore::AdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_property** | **Hash<String, String>** | | [optional] +**map_of_map_property** | **Hash<String, Hash<String, String>>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Animal.md b/samples/openapi3/client/petstore/ruby/docs/Animal.md new file mode 100644 index 000000000000..077e6c2d87c7 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Animal.md @@ -0,0 +1,9 @@ +# Petstore::Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | +**color** | **String** | | [optional] [default to 'red'] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/AnimalFarm.md b/samples/openapi3/client/petstore/ruby/docs/AnimalFarm.md new file mode 100644 index 000000000000..30d704dc7d1d --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/AnimalFarm.md @@ -0,0 +1,7 @@ +# Petstore::AnimalFarm + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/openapi3/client/petstore/ruby/docs/AnotherFakeApi.md b/samples/openapi3/client/petstore/ruby/docs/AnotherFakeApi.md new file mode 100644 index 000000000000..2d4891e06601 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/AnotherFakeApi.md @@ -0,0 +1,54 @@ +# Petstore::AnotherFakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags + + +# **call_123_test_special_tags** +> Client call_123_test_special_tags(client) + +To test special tags + +To test special tags and operation ID starting with number + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::AnotherFakeApi.new +client = Petstore::Client.new # Client | client model + +begin + #To test special tags + result = api_instance.call_123_test_special_tags(client) + p result +rescue Petstore::ApiError => e + puts "Exception when calling AnotherFakeApi->call_123_test_special_tags: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md b/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md new file mode 100644 index 000000000000..843f9cc525b8 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ApiResponse.md @@ -0,0 +1,10 @@ +# Petstore::ApiResponse + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **Integer** | | [optional] +**type** | **String** | | [optional] +**message** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md new file mode 100644 index 000000000000..003cf9a8d6de --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayOfArrayOfNumberOnly.md @@ -0,0 +1,8 @@ +# Petstore::ArrayOfArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_array_number** | **Array<Array<Float>>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md new file mode 100644 index 000000000000..c2b9fada4f88 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayOfNumberOnly.md @@ -0,0 +1,8 @@ +# Petstore::ArrayOfNumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_number** | **Array<Float>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md b/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md new file mode 100644 index 000000000000..5fbfd67159b3 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ArrayTest.md @@ -0,0 +1,10 @@ +# Petstore::ArrayTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**array_of_string** | **Array<String>** | | [optional] +**array_array_of_integer** | **Array<Array<Integer>>** | | [optional] +**array_array_of_model** | **Array<Array<ReadOnlyFirst>>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Capitalization.md b/samples/openapi3/client/petstore/ruby/docs/Capitalization.md new file mode 100644 index 000000000000..d99c603f54a3 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Capitalization.md @@ -0,0 +1,13 @@ +# Petstore::Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **String** | | [optional] +**capital_camel** | **String** | | [optional] +**small_snake** | **String** | | [optional] +**capital_snake** | **String** | | [optional] +**sca_eth_flow_points** | **String** | | [optional] +**att_name** | **String** | Name of the pet | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Cat.md b/samples/openapi3/client/petstore/ruby/docs/Cat.md new file mode 100644 index 000000000000..d0fc50e4da88 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Cat.md @@ -0,0 +1,10 @@ +# Petstore::Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | +**color** | **String** | | [optional] [default to 'red'] +**declawed** | **BOOLEAN** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Category.md b/samples/openapi3/client/petstore/ruby/docs/Category.md new file mode 100644 index 000000000000..4500de105b22 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Category.md @@ -0,0 +1,9 @@ +# Petstore::Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [default to 'default-name'] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ClassModel.md b/samples/openapi3/client/petstore/ruby/docs/ClassModel.md new file mode 100644 index 000000000000..cd4de8506334 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ClassModel.md @@ -0,0 +1,8 @@ +# Petstore::ClassModel + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_class** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Client.md b/samples/openapi3/client/petstore/ruby/docs/Client.md new file mode 100644 index 000000000000..2b8e400aaeeb --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Client.md @@ -0,0 +1,8 @@ +# Petstore::Client + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**client** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/DefaultApi.md b/samples/openapi3/client/petstore/ruby/docs/DefaultApi.md similarity index 100% rename from samples/client/petstore/ruby/docs/DefaultApi.md rename to samples/openapi3/client/petstore/ruby/docs/DefaultApi.md diff --git a/samples/openapi3/client/petstore/ruby/docs/Dog.md b/samples/openapi3/client/petstore/ruby/docs/Dog.md new file mode 100644 index 000000000000..1e66990d593b --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Dog.md @@ -0,0 +1,10 @@ +# Petstore::Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **String** | | +**color** | **String** | | [optional] [default to 'red'] +**breed** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md b/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md new file mode 100644 index 000000000000..ef6a935fbd79 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/EnumArrays.md @@ -0,0 +1,9 @@ +# Petstore::EnumArrays + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_symbol** | **String** | | [optional] +**array_enum** | **Array<String>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumClass.md b/samples/openapi3/client/petstore/ruby/docs/EnumClass.md new file mode 100644 index 000000000000..8d56e1f88734 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/EnumClass.md @@ -0,0 +1,7 @@ +# Petstore::EnumClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/openapi3/client/petstore/ruby/docs/EnumTest.md b/samples/openapi3/client/petstore/ruby/docs/EnumTest.md new file mode 100644 index 000000000000..87297ac476ed --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/EnumTest.md @@ -0,0 +1,12 @@ +# Petstore::EnumTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_string** | **String** | | [optional] +**enum_string_required** | **String** | | +**enum_integer** | **Integer** | | [optional] +**enum_number** | **Float** | | [optional] +**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/FakeApi.md b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md new file mode 100644 index 000000000000..3a26c4926c1c --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/FakeApi.md @@ -0,0 +1,615 @@ +# Petstore::FakeApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**fake_outer_boolean_serialize**](FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | +[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | +[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | +[**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | +[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | +[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model +[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) +[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties +[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data + + +# **fake_outer_boolean_serialize** +> BOOLEAN fake_outer_boolean_serialize(opts) + + + +Test serialization of outer boolean types + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +opts = { + body: true # BOOLEAN | Input boolean as post body +} + +begin + result = api_instance.fake_outer_boolean_serialize(opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->fake_outer_boolean_serialize: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **BOOLEAN**| Input boolean as post body | [optional] + +### Return type + +**BOOLEAN** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + + +# **fake_outer_composite_serialize** +> OuterComposite fake_outer_composite_serialize(opts) + + + +Test serialization of object with outer number type + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +opts = { + outer_composite: Petstore::OuterComposite.new # OuterComposite | Input composite as post body +} + +begin + result = api_instance.fake_outer_composite_serialize(opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->fake_outer_composite_serialize: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **outer_composite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + + +# **fake_outer_number_serialize** +> Float fake_outer_number_serialize(opts) + + + +Test serialization of outer number types + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +opts = { + body: 3.4 # Float | Input number as post body +} + +begin + result = api_instance.fake_outer_number_serialize(opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->fake_outer_number_serialize: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **Float**| Input number as post body | [optional] + +### Return type + +**Float** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + + +# **fake_outer_string_serialize** +> String fake_outer_string_serialize(opts) + + + +Test serialization of outer string types + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +opts = { + body: 'body_example' # String | Input string as post body +} + +begin + result = api_instance.fake_outer_string_serialize(opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->fake_outer_string_serialize: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **String**| Input string as post body | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: */* + + + +# **test_body_with_file_schema** +> test_body_with_file_schema(file_schema_test_class) + + + +For this test, the body for this request much reference a schema named `File`. + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +file_schema_test_class = Petstore::FileSchemaTestClass.new # FileSchemaTestClass | + +begin + api_instance.test_body_with_file_schema(file_schema_test_class) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_body_with_file_schema: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **file_schema_test_class** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **test_body_with_query_params** +> test_body_with_query_params(query, user) + + + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +query = 'query_example' # String | +user = Petstore::User.new # User | + +begin + api_instance.test_body_with_query_params(query, user) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_body_with_query_params: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **query** | **String**| | + **user** | [**User**](User.md)| | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **test_client_model** +> Client test_client_model(client) + +To test \"client\" model + +To test \"client\" model + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +client = Petstore::Client.new # Client | client model + +begin + #To test \"client\" model + result = api_instance.test_client_model(client) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_client_model: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + + +# **test_endpoint_parameters** +> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts) + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure HTTP basic authorization: http_basic_test + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Petstore::FakeApi.new +number = 3.4 # Float | None +double = 3.4 # Float | None +pattern_without_delimiter = 'pattern_without_delimiter_example' # String | None +byte = 'byte_example' # String | None +opts = { + integer: 56, # Integer | None + int32: 56, # Integer | None + int64: 56, # Integer | None + float: 3.4, # Float | None + string: 'string_example', # String | None + binary: File.new('/path/to/file'), # File | None + date: Date.parse('2013-10-20'), # Date | None + date_time: DateTime.parse('2013-10-20T19:20:30+01:00'), # DateTime | None + password: 'password_example', # String | None + callback: 'callback_example' # String | None +} + +begin + #Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **number** | **Float**| None | + **double** | **Float**| None | + **pattern_without_delimiter** | **String**| None | + **byte** | **String**| None | + **integer** | **Integer**| None | [optional] + **int32** | **Integer**| None | [optional] + **int64** | **Integer**| None | [optional] + **float** | **Float**| None | [optional] + **string** | **String**| None | [optional] + **binary** | **File**| None | [optional] + **date** | **Date**| None | [optional] + **date_time** | **DateTime**| None | [optional] + **password** | **String**| None | [optional] + **callback** | **String**| None | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[http_basic_test](../README.md#http_basic_test) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + + +# **test_enum_parameters** +> test_enum_parameters(opts) + +To test enum parameters + +To test enum parameters + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +opts = { + enum_header_string_array: ['enum_header_string_array_example'], # Array | Header parameter enum test (string array) + enum_header_string: '-efg', # String | Header parameter enum test (string) + enum_query_string_array: ['enum_query_string_array_example'], # Array | Query parameter enum test (string array) + enum_query_string: '-efg', # String | Query parameter enum test (string) + enum_query_integer: 56, # Integer | Query parameter enum test (double) + enum_query_double: 3.4, # Float | Query parameter enum test (double) + enum_form_string_array: '$', # Array | Form parameter enum test (string array) + enum_form_string: '-efg' # String | Form parameter enum test (string) +} + +begin + #To test enum parameters + api_instance.test_enum_parameters(opts) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_enum_parameters: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **enum_header_string_array** | [**Array<String>**](String.md)| Header parameter enum test (string array) | [optional] + **enum_header_string** | **String**| Header parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_string_array** | [**Array<String>**](String.md)| Query parameter enum test (string array) | [optional] + **enum_query_string** | **String**| Query parameter enum test (string) | [optional] [default to '-efg'] + **enum_query_integer** | **Integer**| Query parameter enum test (double) | [optional] + **enum_query_double** | **Float**| Query parameter enum test (double) | [optional] + **enum_form_string_array** | [**Array<String>**](String.md)| Form parameter enum test (string array) | [optional] [default to '$'] + **enum_form_string** | **String**| Form parameter enum test (string) | [optional] [default to '-efg'] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + + +# **test_group_parameters** +> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +required_string_group = 56 # Integer | Required String in group parameters +required_boolean_group = true # BOOLEAN | Required Boolean in group parameters +required_int64_group = 56 # Integer | Required Integer in group parameters +opts = { + string_group: 56, # Integer | String in group parameters + boolean_group: true, # BOOLEAN | Boolean in group parameters + int64_group: 56 # Integer | Integer in group parameters +} + +begin + #Fake endpoint to test group parameters (optional) + api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_group_parameters: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **required_string_group** | **Integer**| Required String in group parameters | + **required_boolean_group** | **BOOLEAN**| Required Boolean in group parameters | + **required_int64_group** | **Integer**| Required Integer in group parameters | + **string_group** | **Integer**| String in group parameters | [optional] + **boolean_group** | **BOOLEAN**| Boolean in group parameters | [optional] + **int64_group** | **Integer**| Integer in group parameters | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + + +# **test_inline_additional_properties** +> test_inline_additional_properties(request_body) + +test inline additionalProperties + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +request_body = {'key' => 'request_body_example'} # Hash | request body + +begin + #test inline additionalProperties + api_instance.test_inline_additional_properties(request_body) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_inline_additional_properties: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **request_body** | [**Hash<String, String>**](String.md)| request body | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **test_json_form_data** +> test_json_form_data(param, param2) + +test json serialization of form data + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::FakeApi.new +param = 'param_example' # String | field1 +param2 = 'param2_example' # String | field2 + +begin + #test json serialization of form data + api_instance.test_json_form_data(param, param2) +rescue Petstore::ApiError => e + puts "Exception when calling FakeApi->test_json_form_data: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **String**| field1 | + **param2** | **String**| field2 | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + + diff --git a/samples/openapi3/client/petstore/ruby/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/ruby/docs/FakeClassnameTags123Api.md new file mode 100644 index 000000000000..a6153f02926a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/FakeClassnameTags123Api.md @@ -0,0 +1,61 @@ +# Petstore::FakeClassnameTags123Api + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_classname**](FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case + + +# **test_classname** +> Client test_classname(client) + +To test class name in snake case + +To test class name in snake case + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure API key authorization: api_key_query + config.api_key['api_key_query'] = 'YOUR API KEY' + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['api_key_query'] = 'Bearer' +end + +api_instance = Petstore::FakeClassnameTags123Api.new +client = Petstore::Client.new # Client | client model + +begin + #To test class name in snake case + result = api_instance.test_classname(client) + p result +rescue Petstore::ApiError => e + puts "Exception when calling FakeClassnameTags123Api->test_classname: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **client** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +[api_key_query](../README.md#api_key_query) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + + diff --git a/samples/openapi3/client/petstore/ruby/docs/File.md b/samples/openapi3/client/petstore/ruby/docs/File.md new file mode 100644 index 000000000000..428a5a04188d --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/File.md @@ -0,0 +1,8 @@ +# Petstore::File + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**source_uri** | **String** | Test capitalization | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md new file mode 100644 index 000000000000..d32819b35787 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/FileSchemaTestClass.md @@ -0,0 +1,9 @@ +# Petstore::FileSchemaTestClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**file** | **File** | | [optional] +**files** | **Array<File>** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/Foo.md b/samples/openapi3/client/petstore/ruby/docs/Foo.md similarity index 100% rename from samples/client/petstore/ruby/docs/Foo.md rename to samples/openapi3/client/petstore/ruby/docs/Foo.md diff --git a/samples/openapi3/client/petstore/ruby/docs/FormatTest.md b/samples/openapi3/client/petstore/ruby/docs/FormatTest.md new file mode 100644 index 000000000000..8682ea539e82 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/FormatTest.md @@ -0,0 +1,22 @@ +# Petstore::FormatTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **Integer** | | [optional] +**int32** | **Integer** | | [optional] +**int64** | **Integer** | | [optional] +**number** | **Float** | | +**float** | **Float** | | [optional] +**double** | **Float** | | [optional] +**string** | **String** | | [optional] +**byte** | **String** | | +**binary** | **File** | | [optional] +**date** | **Date** | | +**date_time** | **DateTime** | | [optional] +**uuid** | **String** | | [optional] +**password** | **String** | | +**pattern_with_digits** | **String** | A string that is a 10 digit number. Can have leading zeros. | [optional] +**pattern_with_digits_and_delimiter** | **String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md new file mode 100644 index 000000000000..16de3c060cc2 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/HasOnlyReadOnly.md @@ -0,0 +1,9 @@ +# Petstore::HasOnlyReadOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **String** | | [optional] +**foo** | **String** | | [optional] + + diff --git a/samples/client/petstore/ruby/docs/InlineResponseDefault.md b/samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md similarity index 100% rename from samples/client/petstore/ruby/docs/InlineResponseDefault.md rename to samples/openapi3/client/petstore/ruby/docs/InlineResponseDefault.md diff --git a/samples/openapi3/client/petstore/ruby/docs/List.md b/samples/openapi3/client/petstore/ruby/docs/List.md new file mode 100644 index 000000000000..211d299f6718 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/List.md @@ -0,0 +1,8 @@ +# Petstore::List + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_123_list** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/MapTest.md b/samples/openapi3/client/petstore/ruby/docs/MapTest.md new file mode 100644 index 000000000000..54e16e1933e2 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/MapTest.md @@ -0,0 +1,11 @@ +# Petstore::MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**map_map_of_string** | **Hash<String, Hash<String, String>>** | | [optional] +**map_of_enum_string** | **Hash<String, String>** | | [optional] +**direct_map** | **Hash<String, BOOLEAN>** | | [optional] +**indirect_map** | **Hash<String, BOOLEAN>** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md new file mode 100644 index 000000000000..dcb02e2ffa63 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -0,0 +1,10 @@ +# Petstore::MixedPropertiesAndAdditionalPropertiesClass + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uuid** | **String** | | [optional] +**date_time** | **DateTime** | | [optional] +**map** | [**Hash<String, Animal>**](Animal.md) | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Model200Response.md b/samples/openapi3/client/petstore/ruby/docs/Model200Response.md new file mode 100644 index 000000000000..e745da1a756d --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Model200Response.md @@ -0,0 +1,9 @@ +# Petstore::Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | [optional] +**_class** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md b/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md new file mode 100644 index 000000000000..dfcfff1dd064 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ModelReturn.md @@ -0,0 +1,8 @@ +# Petstore::ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **Integer** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Name.md b/samples/openapi3/client/petstore/ruby/docs/Name.md new file mode 100644 index 000000000000..1ae49f8ee1be --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Name.md @@ -0,0 +1,11 @@ +# Petstore::Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **Integer** | | +**snake_case** | **Integer** | | [optional] +**property** | **String** | | [optional] +**_123_number** | **Integer** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md b/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md new file mode 100644 index 000000000000..4be8a12a79df --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/NumberOnly.md @@ -0,0 +1,8 @@ +# Petstore::NumberOnly + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**just_number** | **Float** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Order.md b/samples/openapi3/client/petstore/ruby/docs/Order.md new file mode 100644 index 000000000000..52a832c51062 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Order.md @@ -0,0 +1,13 @@ +# Petstore::Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**pet_id** | **Integer** | | [optional] +**quantity** | **Integer** | | [optional] +**ship_date** | **DateTime** | | [optional] +**status** | **String** | Order Status | [optional] +**complete** | **BOOLEAN** | | [optional] [default to false] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md b/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md new file mode 100644 index 000000000000..e1548870a7b9 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/OuterComposite.md @@ -0,0 +1,10 @@ +# Petstore::OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**my_number** | **Float** | | [optional] +**my_string** | **String** | | [optional] +**my_boolean** | **BOOLEAN** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md b/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md new file mode 100644 index 000000000000..60d87c123819 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/OuterEnum.md @@ -0,0 +1,7 @@ +# Petstore::OuterEnum + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Pet.md b/samples/openapi3/client/petstore/ruby/docs/Pet.md new file mode 100644 index 000000000000..f4320a0b72b9 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Pet.md @@ -0,0 +1,13 @@ +# Petstore::Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **String** | | +**photo_urls** | **Array<String>** | | +**tags** | [**Array<Tag>**](Tag.md) | | [optional] +**status** | **String** | pet status in the store | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/PetApi.md b/samples/openapi3/client/petstore/ruby/docs/PetApi.md new file mode 100644 index 000000000000..61adf80830bc --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/PetApi.md @@ -0,0 +1,475 @@ +# Petstore::PetApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) + + +# **add_pet** +> add_pet(pet) + +Add a new pet to the store + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store + +begin + #Add a new pet to the store + api_instance.add_pet(pet) +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->add_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + + +# **delete_pet** +> delete_pet(pet_id, opts) + +Deletes a pet + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | Pet id to delete +opts = { + api_key: 'api_key_example' # String | +} + +begin + #Deletes a pet + api_instance.delete_pet(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->delete_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| Pet id to delete | + **api_key** | **String**| | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + + +# **find_pets_by_status** +> Array<Pet> find_pets_by_status(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +status = ['status_example'] # Array | Status values that need to be considered for filter + +begin + #Finds Pets by status + result = api_instance.find_pets_by_status(status) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->find_pets_by_status: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**Array<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**Array<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **find_pets_by_tags** +> Array<Pet> find_pets_by_tags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +tags = ['tags_example'] # Array | Tags to filter by + +begin + #Finds Pets by tags + result = api_instance.find_pets_by_tags(tags) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->find_pets_by_tags: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**Array<String>**](String.md)| Tags to filter by | + +### Return type + +[**Array<Pet>**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id) + +Find pet by ID + +Returns a single pet + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure API key authorization: api_key + config.api_key['api_key'] = 'YOUR API KEY' + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['api_key'] = 'Bearer' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | ID of pet to return + +begin + #Find pet by ID + result = api_instance.get_pet_by_id(pet_id) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->get_pet_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **update_pet** +> update_pet(pet) + +Update an existing pet + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store + +begin + #Update an existing pet + api_instance.update_pet(pet) +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->update_pet: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: Not defined + + + +# **update_pet_with_form** +> update_pet_with_form(pet_id, opts) + +Updates a pet in the store with form data + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | ID of pet that needs to be updated +opts = { + name: 'name_example', # String | Updated name of the pet + status: 'status_example' # String | Updated status of the pet +} + +begin + #Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id, opts) +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->update_pet_with_form: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +nil (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + + +# **upload_file** +> ApiResponse upload_file(pet_id, opts) + +uploads an image + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | ID of pet to update +opts = { + additional_metadata: 'additional_metadata_example', # String | Additional data to pass to server + file: File.new('/path/to/file') # File | file to upload +} + +begin + #uploads an image + result = api_instance.upload_file(pet_id, opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->upload_file: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to update | + **additional_metadata** | **String**| Additional data to pass to server | [optional] + **file** | **File**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + + +# **upload_file_with_required_file** +> ApiResponse upload_file_with_required_file(pet_id, required_file, opts) + +uploads an image (required) + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure OAuth2 access token for authorization: petstore_auth + config.access_token = 'YOUR ACCESS TOKEN' +end + +api_instance = Petstore::PetApi.new +pet_id = 56 # Integer | ID of pet to update +required_file = File.new('/path/to/file') # File | file to upload +opts = { + additional_metadata: 'additional_metadata_example' # String | Additional data to pass to server +} + +begin + #uploads an image (required) + result = api_instance.upload_file_with_required_file(pet_id, required_file, opts) + p result +rescue Petstore::ApiError => e + puts "Exception when calling PetApi->upload_file_with_required_file: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **Integer**| ID of pet to update | + **required_file** | **File**| file to upload | + **additional_metadata** | **String**| Additional data to pass to server | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + + + diff --git a/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md new file mode 100644 index 000000000000..e49b51194785 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/ReadOnlyFirst.md @@ -0,0 +1,9 @@ +# Petstore::ReadOnlyFirst + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bar** | **String** | | [optional] +**baz** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md b/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md new file mode 100644 index 000000000000..581ab6907efa --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/SpecialModelName.md @@ -0,0 +1,8 @@ +# Petstore::SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **Integer** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/StoreApi.md b/samples/openapi3/client/petstore/ruby/docs/StoreApi.md new file mode 100644 index 000000000000..464c8dbb854d --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/StoreApi.md @@ -0,0 +1,192 @@ +# Petstore::StoreApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::StoreApi.new +order_id = 'order_id_example' # String | ID of the order that needs to be deleted + +begin + #Delete purchase order by ID + api_instance.delete_order(order_id) +rescue Petstore::ApiError => e + puts "Exception when calling StoreApi->delete_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **String**| ID of the order that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + + +# **get_inventory** +> Hash<String, Integer> get_inventory + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```ruby +# load the gem +require 'petstore' +# setup authorization +Petstore.configure do |config| + # Configure API key authorization: api_key + config.api_key['api_key'] = 'YOUR API KEY' + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['api_key'] = 'Bearer' +end + +api_instance = Petstore::StoreApi.new + +begin + #Returns pet inventories by status + result = api_instance.get_inventory + p result +rescue Petstore::ApiError => e + puts "Exception when calling StoreApi->get_inventory: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Hash<String, Integer>** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + + +# **get_order_by_id** +> Order get_order_by_id(order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::StoreApi.new +order_id = 56 # Integer | ID of pet that needs to be fetched + +begin + #Find purchase order by ID + result = api_instance.get_order_by_id(order_id) + p result +rescue Petstore::ApiError => e + puts "Exception when calling StoreApi->get_order_by_id: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **Integer**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **place_order** +> Order place_order(order) + +Place an order for a pet + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::StoreApi.new +order = Petstore::Order.new # Order | order placed for purchasing the pet + +begin + #Place an order for a pet + result = api_instance.place_order(order) + p result +rescue Petstore::ApiError => e + puts "Exception when calling StoreApi->place_order: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/xml, application/json + + + diff --git a/samples/openapi3/client/petstore/ruby/docs/StringBooleanMap.md b/samples/openapi3/client/petstore/ruby/docs/StringBooleanMap.md new file mode 100644 index 000000000000..0fbc07cb043a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/StringBooleanMap.md @@ -0,0 +1,7 @@ +# Petstore::StringBooleanMap + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + + diff --git a/samples/openapi3/client/petstore/ruby/docs/Tag.md b/samples/openapi3/client/petstore/ruby/docs/Tag.md new file mode 100644 index 000000000000..5bd94d6c04e3 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/Tag.md @@ -0,0 +1,9 @@ +# Petstore::Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**name** | **String** | | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/User.md b/samples/openapi3/client/petstore/ruby/docs/User.md new file mode 100644 index 000000000000..bd76116e0233 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/User.md @@ -0,0 +1,15 @@ +# Petstore::User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **Integer** | | [optional] +**username** | **String** | | [optional] +**first_name** | **String** | | [optional] +**last_name** | **String** | | [optional] +**email** | **String** | | [optional] +**password** | **String** | | [optional] +**phone** | **String** | | [optional] +**user_status** | **Integer** | User Status | [optional] + + diff --git a/samples/openapi3/client/petstore/ruby/docs/UserApi.md b/samples/openapi3/client/petstore/ruby/docs/UserApi.md new file mode 100644 index 000000000000..8981435d9d9a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/docs/UserApi.md @@ -0,0 +1,360 @@ +# Petstore::UserApi + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(user) + +Create user + +This can only be done by the logged in user. + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +user = Petstore::User.new # User | Created user object + +begin + #Create user + api_instance.create_user(user) +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->create_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**User**](User.md)| Created user object | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **create_users_with_array_input** +> create_users_with_array_input(user) + +Creates list of users with given input array + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +user = nil # Array | List of user object + +begin + #Creates list of users with given input array + api_instance.create_users_with_array_input(user) +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->create_users_with_array_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**Array<User>**](Array.md)| List of user object | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **create_users_with_list_input** +> create_users_with_list_input(user) + +Creates list of users with given input array + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +user = nil # Array | List of user object + +begin + #Creates list of users with given input array + api_instance.create_users_with_list_input(user) +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->create_users_with_list_input: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **user** | [**Array<User>**](Array.md)| List of user object | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + +# **delete_user** +> delete_user(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +username = 'username_example' # String | The name that needs to be deleted + +begin + #Delete user + api_instance.delete_user(username) +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->delete_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + + +# **get_user_by_name** +> User get_user_by_name(username) + +Get user by user name + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +username = 'username_example' # String | The name that needs to be fetched. Use user1 for testing. + +begin + #Get user by user name + result = api_instance.get_user_by_name(username) + p result +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->get_user_by_name: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **login_user** +> String login_user(username, password) + +Logs user into the system + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +username = 'username_example' # String | The user name for login +password = 'password_example' # String | The password for login in clear text + +begin + #Logs user into the system + result = api_instance.login_user(username, password) + p result +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->login_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + + + +# **logout_user** +> logout_user + +Logs out current logged in user session + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new + +begin + #Logs out current logged in user session + api_instance.logout_user +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->logout_user: #{e}" +end +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + + +# **update_user** +> update_user(username, user) + +Updated user + +This can only be done by the logged in user. + +### Example +```ruby +# load the gem +require 'petstore' + +api_instance = Petstore::UserApi.new +username = 'username_example' # String | name that need to be deleted +user = Petstore::User.new # User | Updated user object + +begin + #Updated user + api_instance.update_user(username, user) +rescue Petstore::ApiError => e + puts "Exception when calling UserApi->update_user: #{e}" +end +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **user** | [**User**](User.md)| Updated user object | + +### Return type + +nil (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + + + diff --git a/samples/openapi3/client/petstore/ruby/git_push.sh b/samples/openapi3/client/petstore/ruby/git_push.sh new file mode 100644 index 000000000000..b9fd6af8e051 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/git_push.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Generated by: https://openapi-generator.tech +# +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/ruby/hello.txt b/samples/openapi3/client/petstore/ruby/hello.txt similarity index 100% rename from samples/client/petstore/ruby/hello.txt rename to samples/openapi3/client/petstore/ruby/hello.txt diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore.rb b/samples/openapi3/client/petstore/ruby/lib/petstore.rb new file mode 100644 index 000000000000..109971ea30ef --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore.rb @@ -0,0 +1,84 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +# Common files +require 'petstore/api_client' +require 'petstore/api_error' +require 'petstore/version' +require 'petstore/configuration' + +# Models +require 'petstore/models/additional_properties_class' +require 'petstore/models/animal' +require 'petstore/models/animal_farm' +require 'petstore/models/api_response' +require 'petstore/models/array_of_array_of_number_only' +require 'petstore/models/array_of_number_only' +require 'petstore/models/array_test' +require 'petstore/models/capitalization' +require 'petstore/models/cat' +require 'petstore/models/category' +require 'petstore/models/class_model' +require 'petstore/models/client' +require 'petstore/models/dog' +require 'petstore/models/enum_arrays' +require 'petstore/models/enum_class' +require 'petstore/models/enum_test' +require 'petstore/models/file' +require 'petstore/models/file_schema_test_class' +require 'petstore/models/foo' +require 'petstore/models/format_test' +require 'petstore/models/has_only_read_only' +require 'petstore/models/inline_response_default' +require 'petstore/models/list' +require 'petstore/models/map_test' +require 'petstore/models/mixed_properties_and_additional_properties_class' +require 'petstore/models/model200_response' +require 'petstore/models/model_return' +require 'petstore/models/name' +require 'petstore/models/number_only' +require 'petstore/models/order' +require 'petstore/models/outer_composite' +require 'petstore/models/outer_enum' +require 'petstore/models/pet' +require 'petstore/models/read_only_first' +require 'petstore/models/special_model_name' +require 'petstore/models/string_boolean_map' +require 'petstore/models/tag' +require 'petstore/models/user' + +# APIs +require 'petstore/api/another_fake_api' +require 'petstore/api/default_api' +require 'petstore/api/fake_api' +require 'petstore/api/fake_classname_tags123_api' +require 'petstore/api/pet_api' +require 'petstore/api/store_api' +require 'petstore/api/user_api' + +module Petstore + class << self + # Customize default settings for the SDK using block. + # Petstore.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/another_fake_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/another_fake_api.rb new file mode 100644 index 000000000000..7eada287ab3c --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/another_fake_api.rb @@ -0,0 +1,78 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class AnotherFakeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # To test special tags + # To test special tags and operation ID starting with number + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Client] + def call_123_test_special_tags(client, opts = {}) + data, _status_code, _headers = call_123_test_special_tags_with_http_info(client, opts) + data + end + + # To test special tags + # To test special tags and operation ID starting with number + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers + def call_123_test_special_tags_with_http_info(client, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AnotherFakeApi.call_123_test_special_tags ...' + end + # verify the required parameter 'client' is set + if @api_client.config.client_side_validation && client.nil? + fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.call_123_test_special_tags" + end + # resource path + local_var_path = '/another-fake/dummy' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(client) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Client') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AnotherFakeApi#call_123_test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/api/default_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/default_api.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/api/default_api.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/api/default_api.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_api.rb new file mode 100644 index 000000000000..6ddf4371a962 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_api.rb @@ -0,0 +1,811 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class FakeApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Test serialization of outer boolean types + # @param [Hash] opts the optional parameters + # @option opts [BOOLEAN] :body Input boolean as post body + # @return [BOOLEAN] + def fake_outer_boolean_serialize(opts = {}) + data, _status_code, _headers = fake_outer_boolean_serialize_with_http_info(opts) + data + end + + # Test serialization of outer boolean types + # @param [Hash] opts the optional parameters + # @option opts [BOOLEAN] :body Input boolean as post body + # @return [Array<(BOOLEAN, Fixnum, Hash)>] BOOLEAN data, response status code and response headers + def fake_outer_boolean_serialize_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_boolean_serialize ...' + end + # resource path + local_var_path = '/fake/outer/boolean' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(opts[:'body']) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'BOOLEAN') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#fake_outer_boolean_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Test serialization of object with outer number type + # @param [Hash] opts the optional parameters + # @option opts [OuterComposite] :outer_composite Input composite as post body + # @return [OuterComposite] + def fake_outer_composite_serialize(opts = {}) + data, _status_code, _headers = fake_outer_composite_serialize_with_http_info(opts) + data + end + + # Test serialization of object with outer number type + # @param [Hash] opts the optional parameters + # @option opts [OuterComposite] :outer_composite Input composite as post body + # @return [Array<(OuterComposite, Fixnum, Hash)>] OuterComposite data, response status code and response headers + def fake_outer_composite_serialize_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_composite_serialize ...' + end + # resource path + local_var_path = '/fake/outer/composite' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(opts[:'outer_composite']) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'OuterComposite') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#fake_outer_composite_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Test serialization of outer number types + # @param [Hash] opts the optional parameters + # @option opts [Float] :body Input number as post body + # @return [Float] + def fake_outer_number_serialize(opts = {}) + data, _status_code, _headers = fake_outer_number_serialize_with_http_info(opts) + data + end + + # Test serialization of outer number types + # @param [Hash] opts the optional parameters + # @option opts [Float] :body Input number as post body + # @return [Array<(Float, Fixnum, Hash)>] Float data, response status code and response headers + def fake_outer_number_serialize_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_number_serialize ...' + end + # resource path + local_var_path = '/fake/outer/number' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(opts[:'body']) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Float') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#fake_outer_number_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Test serialization of outer string types + # @param [Hash] opts the optional parameters + # @option opts [String] :body Input string as post body + # @return [String] + def fake_outer_string_serialize(opts = {}) + data, _status_code, _headers = fake_outer_string_serialize_with_http_info(opts) + data + end + + # Test serialization of outer string types + # @param [Hash] opts the optional parameters + # @option opts [String] :body Input string as post body + # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers + def fake_outer_string_serialize_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_string_serialize ...' + end + # resource path + local_var_path = '/fake/outer/string' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(opts[:'body']) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'String') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#fake_outer_string_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # For this test, the body for this request much reference a schema named `File`. + # @param file_schema_test_class + # @param [Hash] opts the optional parameters + # @return [nil] + def test_body_with_file_schema(file_schema_test_class, opts = {}) + test_body_with_file_schema_with_http_info(file_schema_test_class, opts) + nil + end + + # For this test, the body for this request much reference a schema named `File`. + # @param file_schema_test_class + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_body_with_file_schema_with_http_info(file_schema_test_class, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_file_schema ...' + end + # verify the required parameter 'file_schema_test_class' is set + if @api_client.config.client_side_validation && file_schema_test_class.nil? + fail ArgumentError, "Missing the required parameter 'file_schema_test_class' when calling FakeApi.test_body_with_file_schema" + end + # resource path + local_var_path = '/fake/body-with-file-schema' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(file_schema_test_class) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_body_with_file_schema\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # @param query + # @param user + # @param [Hash] opts the optional parameters + # @return [nil] + def test_body_with_query_params(query, user, opts = {}) + test_body_with_query_params_with_http_info(query, user, opts) + nil + end + + # @param query + # @param user + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_body_with_query_params_with_http_info(query, user, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_query_params ...' + end + # verify the required parameter 'query' is set + if @api_client.config.client_side_validation && query.nil? + fail ArgumentError, "Missing the required parameter 'query' when calling FakeApi.test_body_with_query_params" + end + # verify the required parameter 'user' is set + if @api_client.config.client_side_validation && user.nil? + fail ArgumentError, "Missing the required parameter 'user' when calling FakeApi.test_body_with_query_params" + end + # resource path + local_var_path = '/fake/body-with-query-params' + + # query parameters + query_params = {} + query_params[:'query'] = query + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(user) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_body_with_query_params\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # To test \"client\" model + # To test \"client\" model + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Client] + def test_client_model(client, opts = {}) + data, _status_code, _headers = test_client_model_with_http_info(client, opts) + data + end + + # To test \"client\" model + # To test \"client\" model + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers + def test_client_model_with_http_info(client, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_client_model ...' + end + # verify the required parameter 'client' is set + if @api_client.config.client_side_validation && client.nil? + fail ArgumentError, "Missing the required parameter 'client' when calling FakeApi.test_client_model" + end + # resource path + local_var_path = '/fake' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(client) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Client') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_client_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # @param number None + # @param double None + # @param pattern_without_delimiter None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :string None + # @option opts [File] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @option opts [String] :callback None + # @return [nil] + def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts = {}) + test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts) + nil + end + + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # @param number None + # @param double None + # @param pattern_without_delimiter None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :string None + # @option opts [File] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @option opts [String] :callback None + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_endpoint_parameters ...' + end + # verify the required parameter 'number' is set + if @api_client.config.client_side_validation && number.nil? + fail ArgumentError, "Missing the required parameter 'number' when calling FakeApi.test_endpoint_parameters" + end + if @api_client.config.client_side_validation && number > 543.2 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 543.2.' + end + + if @api_client.config.client_side_validation && number < 32.1 + fail ArgumentError, 'invalid value for "number" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 32.1.' + end + + # verify the required parameter 'double' is set + if @api_client.config.client_side_validation && double.nil? + fail ArgumentError, "Missing the required parameter 'double' when calling FakeApi.test_endpoint_parameters" + end + if @api_client.config.client_side_validation && double > 123.4 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 123.4.' + end + + if @api_client.config.client_side_validation && double < 67.8 + fail ArgumentError, 'invalid value for "double" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 67.8.' + end + + # verify the required parameter 'pattern_without_delimiter' is set + if @api_client.config.client_side_validation && pattern_without_delimiter.nil? + fail ArgumentError, "Missing the required parameter 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters" + end + if @api_client.config.client_side_validation && pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/) + fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /^[A-Z].*/." + end + + # verify the required parameter 'byte' is set + if @api_client.config.client_side_validation && byte.nil? + fail ArgumentError, "Missing the required parameter 'byte' when calling FakeApi.test_endpoint_parameters" + end + if @api_client.config.client_side_validation && !opts[:'integer'].nil? && opts[:'integer'] > 100 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 100.' + end + + if @api_client.config.client_side_validation && !opts[:'integer'].nil? && opts[:'integer'] < 10 + fail ArgumentError, 'invalid value for "opts[:"integer"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 10.' + end + + if @api_client.config.client_side_validation && !opts[:'int32'].nil? && opts[:'int32'] > 200 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 200.' + end + + if @api_client.config.client_side_validation && !opts[:'int32'].nil? && opts[:'int32'] < 20 + fail ArgumentError, 'invalid value for "opts[:"int32"]" when calling FakeApi.test_endpoint_parameters, must be greater than or equal to 20.' + end + + if @api_client.config.client_side_validation && !opts[:'float'].nil? && opts[:'float'] > 987.6 + fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.' + end + + if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ Regexp.new(/[a-z]/i) + fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i." + end + + if @api_client.config.client_side_validation && !opts[:'password'].nil? && opts[:'password'].to_s.length > 64 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be smaller than or equal to 64.' + end + + if @api_client.config.client_side_validation && !opts[:'password'].nil? && opts[:'password'].to_s.length < 10 + fail ArgumentError, 'invalid value for "opts[:"password"]" when calling FakeApi.test_endpoint_parameters, the character length must be great than or equal to 10.' + end + + # resource path + local_var_path = '/fake' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + + # form parameters + form_params = {} + form_params['number'] = number + form_params['double'] = double + form_params['pattern_without_delimiter'] = pattern_without_delimiter + form_params['byte'] = byte + form_params['integer'] = opts[:'integer'] if !opts[:'integer'].nil? + form_params['int32'] = opts[:'int32'] if !opts[:'int32'].nil? + form_params['int64'] = opts[:'int64'] if !opts[:'int64'].nil? + form_params['float'] = opts[:'float'] if !opts[:'float'].nil? + form_params['string'] = opts[:'string'] if !opts[:'string'].nil? + form_params['binary'] = opts[:'binary'] if !opts[:'binary'].nil? + form_params['date'] = opts[:'date'] if !opts[:'date'].nil? + form_params['dateTime'] = opts[:'date_time'] if !opts[:'date_time'].nil? + form_params['password'] = opts[:'password'] if !opts[:'password'].nil? + form_params['callback'] = opts[:'callback'] if !opts[:'callback'].nil? + + # http body (model) + post_body = nil + auth_names = ['http_basic_test'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_endpoint_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # To test enum parameters + # To test enum parameters + # @param [Hash] opts the optional parameters + # @option opts [Array] :enum_header_string_array Header parameter enum test (string array) + # @option opts [String] :enum_header_string Header parameter enum test (string) (default to '-efg') + # @option opts [Array] :enum_query_string_array Query parameter enum test (string array) + # @option opts [String] :enum_query_string Query parameter enum test (string) (default to '-efg') + # @option opts [Integer] :enum_query_integer Query parameter enum test (double) + # @option opts [Float] :enum_query_double Query parameter enum test (double) + # @option opts [Array] :enum_form_string_array Form parameter enum test (string array) (default to '$') + # @option opts [String] :enum_form_string Form parameter enum test (string) (default to '-efg') + # @return [nil] + def test_enum_parameters(opts = {}) + test_enum_parameters_with_http_info(opts) + nil + end + + # To test enum parameters + # To test enum parameters + # @param [Hash] opts the optional parameters + # @option opts [Array] :enum_header_string_array Header parameter enum test (string array) + # @option opts [String] :enum_header_string Header parameter enum test (string) + # @option opts [Array] :enum_query_string_array Query parameter enum test (string array) + # @option opts [String] :enum_query_string Query parameter enum test (string) + # @option opts [Integer] :enum_query_integer Query parameter enum test (double) + # @option opts [Float] :enum_query_double Query parameter enum test (double) + # @option opts [Array] :enum_form_string_array Form parameter enum test (string array) + # @option opts [String] :enum_form_string Form parameter enum test (string) + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_enum_parameters_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_enum_parameters ...' + end + if @api_client.config.client_side_validation && opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all? { |item| ['>', '$'].include?(item) } + fail ArgumentError, 'invalid value for "enum_header_string_array", must include one of >, $' + end + if @api_client.config.client_side_validation && opts[:'enum_header_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_header_string']) + fail ArgumentError, 'invalid value for "enum_header_string", must be one of _abc, -efg, (xyz)' + end + if @api_client.config.client_side_validation && opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all? { |item| ['>', '$'].include?(item) } + fail ArgumentError, 'invalid value for "enum_query_string_array", must include one of >, $' + end + if @api_client.config.client_side_validation && opts[:'enum_query_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_query_string']) + fail ArgumentError, 'invalid value for "enum_query_string", must be one of _abc, -efg, (xyz)' + end + if @api_client.config.client_side_validation && opts[:'enum_query_integer'] && !['1', '-2'].include?(opts[:'enum_query_integer']) + fail ArgumentError, 'invalid value for "enum_query_integer", must be one of 1, -2' + end + if @api_client.config.client_side_validation && opts[:'enum_query_double'] && !['1.1', '-1.2'].include?(opts[:'enum_query_double']) + fail ArgumentError, 'invalid value for "enum_query_double", must be one of 1.1, -1.2' + end + if @api_client.config.client_side_validation && opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all? { |item| ['>', '$'].include?(item) } + fail ArgumentError, 'invalid value for "enum_form_string_array", must include one of >, $' + end + if @api_client.config.client_side_validation && opts[:'enum_form_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_form_string']) + fail ArgumentError, 'invalid value for "enum_form_string", must be one of _abc, -efg, (xyz)' + end + # resource path + local_var_path = '/fake' + + # query parameters + query_params = {} + query_params[:'enum_query_string_array'] = @api_client.build_collection_param(opts[:'enum_query_string_array'], :multi) if !opts[:'enum_query_string_array'].nil? + query_params[:'enum_query_string'] = opts[:'enum_query_string'] if !opts[:'enum_query_string'].nil? + query_params[:'enum_query_integer'] = opts[:'enum_query_integer'] if !opts[:'enum_query_integer'].nil? + query_params[:'enum_query_double'] = opts[:'enum_query_double'] if !opts[:'enum_query_double'].nil? + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + header_params[:'enum_header_string_array'] = @api_client.build_collection_param(opts[:'enum_header_string_array'], :csv) if !opts[:'enum_header_string_array'].nil? + header_params[:'enum_header_string'] = opts[:'enum_header_string'] if !opts[:'enum_header_string'].nil? + + # form parameters + form_params = {} + form_params['enum_form_string_array'] = @api_client.build_collection_param(opts[:'enum_form_string_array'], :csv) if !opts[:'enum_form_string_array'].nil? + form_params['enum_form_string'] = opts[:'enum_form_string'] if !opts[:'enum_form_string'].nil? + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_enum_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Fake endpoint to test group parameters (optional) + # Fake endpoint to test group parameters (optional) + # @param required_string_group Required String in group parameters + # @param required_boolean_group Required Boolean in group parameters + # @param required_int64_group Required Integer in group parameters + # @param [Hash] opts the optional parameters + # @option opts [Integer] :string_group String in group parameters + # @option opts [BOOLEAN] :boolean_group Boolean in group parameters + # @option opts [Integer] :int64_group Integer in group parameters + # @return [nil] + def test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts = {}) + test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, opts) + nil + end + + # Fake endpoint to test group parameters (optional) + # Fake endpoint to test group parameters (optional) + # @param required_string_group Required String in group parameters + # @param required_boolean_group Required Boolean in group parameters + # @param required_int64_group Required Integer in group parameters + # @param [Hash] opts the optional parameters + # @option opts [Integer] :string_group String in group parameters + # @option opts [BOOLEAN] :boolean_group Boolean in group parameters + # @option opts [Integer] :int64_group Integer in group parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_group_parameters ...' + end + # verify the required parameter 'required_string_group' is set + if @api_client.config.client_side_validation && required_string_group.nil? + fail ArgumentError, "Missing the required parameter 'required_string_group' when calling FakeApi.test_group_parameters" + end + # verify the required parameter 'required_boolean_group' is set + if @api_client.config.client_side_validation && required_boolean_group.nil? + fail ArgumentError, "Missing the required parameter 'required_boolean_group' when calling FakeApi.test_group_parameters" + end + # verify the required parameter 'required_int64_group' is set + if @api_client.config.client_side_validation && required_int64_group.nil? + fail ArgumentError, "Missing the required parameter 'required_int64_group' when calling FakeApi.test_group_parameters" + end + # resource path + local_var_path = '/fake' + + # query parameters + query_params = {} + query_params[:'required_string_group'] = required_string_group + query_params[:'required_int64_group'] = required_int64_group + query_params[:'string_group'] = opts[:'string_group'] if !opts[:'string_group'].nil? + query_params[:'int64_group'] = opts[:'int64_group'] if !opts[:'int64_group'].nil? + + # header parameters + header_params = {} + header_params[:'required_boolean_group'] = required_boolean_group + header_params[:'boolean_group'] = opts[:'boolean_group'] if !opts[:'boolean_group'].nil? + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_group_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # test inline additionalProperties + # @param request_body request body + # @param [Hash] opts the optional parameters + # @return [nil] + def test_inline_additional_properties(request_body, opts = {}) + test_inline_additional_properties_with_http_info(request_body, opts) + nil + end + + # test inline additionalProperties + # @param request_body request body + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_inline_additional_properties_with_http_info(request_body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_inline_additional_properties ...' + end + # verify the required parameter 'request_body' is set + if @api_client.config.client_side_validation && request_body.nil? + fail ArgumentError, "Missing the required parameter 'request_body' when calling FakeApi.test_inline_additional_properties" + end + # resource path + local_var_path = '/fake/inline-additionalProperties' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(request_body) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_inline_additional_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # test json serialization of form data + # @param param field1 + # @param param2 field2 + # @param [Hash] opts the optional parameters + # @return [nil] + def test_json_form_data(param, param2, opts = {}) + test_json_form_data_with_http_info(param, param2, opts) + nil + end + + # test json serialization of form data + # @param param field1 + # @param param2 field2 + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def test_json_form_data_with_http_info(param, param2, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeApi.test_json_form_data ...' + end + # verify the required parameter 'param' is set + if @api_client.config.client_side_validation && param.nil? + fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_json_form_data" + end + # verify the required parameter 'param2' is set + if @api_client.config.client_side_validation && param2.nil? + fail ArgumentError, "Missing the required parameter 'param2' when calling FakeApi.test_json_form_data" + end + # resource path + local_var_path = '/fake/jsonFormData' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + + # form parameters + form_params = {} + form_params['param'] = param + form_params['param2'] = param2 + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeApi#test_json_form_data\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb new file mode 100644 index 000000000000..4f804e0676de --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/fake_classname_tags123_api.rb @@ -0,0 +1,78 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class FakeClassnameTags123Api + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # To test class name in snake case + # To test class name in snake case + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Client] + def test_classname(client, opts = {}) + data, _status_code, _headers = test_classname_with_http_info(client, opts) + data + end + + # To test class name in snake case + # To test class name in snake case + # @param client client model + # @param [Hash] opts the optional parameters + # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers + def test_classname_with_http_info(client, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: FakeClassnameTags123Api.test_classname ...' + end + # verify the required parameter 'client' is set + if @api_client.config.client_side_validation && client.nil? + fail ArgumentError, "Missing the required parameter 'client' when calling FakeClassnameTags123Api.test_classname" + end + # resource path + local_var_path = '/fake_classname_test' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(client) + auth_names = ['api_key_query'] + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Client') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: FakeClassnameTags123Api#test_classname\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/pet_api.rb new file mode 100644 index 000000000000..5cad4799abb4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -0,0 +1,513 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class PetApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Add a new pet to the store + # @param pet Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [nil] + def add_pet(pet, opts = {}) + add_pet_with_http_info(pet, opts) + nil + end + + # Add a new pet to the store + # @param pet Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def add_pet_with_http_info(pet, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.add_pet ...' + end + # verify the required parameter 'pet' is set + if @api_client.config.client_side_validation && pet.nil? + fail ArgumentError, "Missing the required parameter 'pet' when calling PetApi.add_pet" + end + # resource path + local_var_path = '/pet' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(pet) + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#add_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Deletes a pet + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [nil] + def delete_pet(pet_id, opts = {}) + delete_pet_with_http_info(pet_id, opts) + nil + end + + # Deletes a pet + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_pet_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.delete_pet ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet" + end + # resource path + local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + header_params[:'api_key'] = opts[:'api_key'] if !opts[:'api_key'].nil? + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Finds Pets by status + # Multiple status values can be provided with comma separated strings + # @param status Status values that need to be considered for filter + # @param [Hash] opts the optional parameters + # @return [Array] + def find_pets_by_status(status, opts = {}) + data, _status_code, _headers = find_pets_by_status_with_http_info(status, opts) + data + end + + # Finds Pets by status + # Multiple status values can be provided with comma separated strings + # @param status Status values that need to be considered for filter + # @param [Hash] opts the optional parameters + # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers + def find_pets_by_status_with_http_info(status, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_status ...' + end + # verify the required parameter 'status' is set + if @api_client.config.client_side_validation && status.nil? + fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status" + end + # resource path + local_var_path = '/pet/findByStatus' + + # query parameters + query_params = {} + query_params[:'status'] = @api_client.build_collection_param(status, :csv) + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Array') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#find_pets_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Finds Pets by tags + # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + # @param tags Tags to filter by + # @param [Hash] opts the optional parameters + # @return [Array] + def find_pets_by_tags(tags, opts = {}) + data, _status_code, _headers = find_pets_by_tags_with_http_info(tags, opts) + data + end + + # Finds Pets by tags + # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + # @param tags Tags to filter by + # @param [Hash] opts the optional parameters + # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers + def find_pets_by_tags_with_http_info(tags, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...' + end + # verify the required parameter 'tags' is set + if @api_client.config.client_side_validation && tags.nil? + fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags" + end + # resource path + local_var_path = '/pet/findByTags' + + # query parameters + query_params = {} + query_params[:'tags'] = @api_client.build_collection_param(tags, :csv) + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Array') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#find_pets_by_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Find pet by ID + # Returns a single pet + # @param pet_id ID of pet to return + # @param [Hash] opts the optional parameters + # @return [Pet] + def get_pet_by_id(pet_id, opts = {}) + data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts) + data + end + + # Find pet by ID + # Returns a single pet + # @param pet_id ID of pet to return + # @param [Hash] opts the optional parameters + # @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers + def get_pet_by_id_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.get_pet_by_id ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id" + end + # resource path + local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['api_key'] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Pet') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#get_pet_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update an existing pet + # @param pet Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [nil] + def update_pet(pet, opts = {}) + update_pet_with_http_info(pet, opts) + nil + end + + # Update an existing pet + # @param pet Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def update_pet_with_http_info(pet, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.update_pet ...' + end + # verify the required parameter 'pet' is set + if @api_client.config.client_side_validation && pet.nil? + fail ArgumentError, "Missing the required parameter 'pet' when calling PetApi.update_pet" + end + # resource path + local_var_path = '/pet' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(pet) + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Updates a pet in the store with form data + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [nil] + def update_pet_with_form(pet_id, opts = {}) + update_pet_with_form_with_http_info(pet_id, opts) + nil + end + + # Updates a pet in the store with form data + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def update_pet_with_form_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.update_pet_with_form ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form" + end + # resource path + local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) + + # form parameters + form_params = {} + form_params['name'] = opts[:'name'] if !opts[:'name'].nil? + form_params['status'] = opts[:'status'] if !opts[:'status'].nil? + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # uploads an image + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [ApiResponse] + def upload_file(pet_id, opts = {}) + data, _status_code, _headers = upload_file_with_http_info(pet_id, opts) + data + end + + # uploads an image + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers + def upload_file_with_http_info(pet_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.upload_file ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file" + end + # resource path + local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + + # form parameters + form_params = {} + form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil? + form_params['file'] = opts[:'file'] if !opts[:'file'].nil? + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'ApiResponse') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # uploads an image (required) + # @param pet_id ID of pet to update + # @param required_file file to upload + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @return [ApiResponse] + def upload_file_with_required_file(pet_id, required_file, opts = {}) + data, _status_code, _headers = upload_file_with_required_file_with_http_info(pet_id, required_file, opts) + data + end + + # uploads an image (required) + # @param pet_id ID of pet to update + # @param required_file file to upload + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers + def upload_file_with_required_file_with_http_info(pet_id, required_file, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PetApi.upload_file_with_required_file ...' + end + # verify the required parameter 'pet_id' is set + if @api_client.config.client_side_validation && pet_id.nil? + fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file_with_required_file" + end + # verify the required parameter 'required_file' is set + if @api_client.config.client_side_validation && required_file.nil? + fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file" + end + # resource path + local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', pet_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) + + # form parameters + form_params = {} + form_params['requiredFile'] = required_file + form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil? + + # http body (model) + post_body = nil + auth_names = ['petstore_auth'] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'ApiResponse') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PetApi#upload_file_with_required_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/store_api.rb new file mode 100644 index 000000000000..63c02b8e2640 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -0,0 +1,234 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class StoreApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_order(order_id, opts = {}) + delete_order_with_http_info(order_id, opts) + nil + end + + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_order_with_http_info(order_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StoreApi.delete_order ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order" + end + # resource path + local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @param [Hash] opts the optional parameters + # @return [Hash] + def get_inventory(opts = {}) + data, _status_code, _headers = get_inventory_with_http_info(opts) + data + end + + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @param [Hash] opts the optional parameters + # @return [Array<(Hash, Fixnum, Hash)>] Hash data, response status code and response headers + def get_inventory_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StoreApi.get_inventory ...' + end + # resource path + local_var_path = '/store/inventory' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = ['api_key'] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Hash') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StoreApi#get_inventory\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Order] + def get_order_by_id(order_id, opts = {}) + data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts) + data + end + + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers + def get_order_by_id_with_http_info(order_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StoreApi.get_order_by_id ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.get_order_by_id" + end + if @api_client.config.client_side_validation && order_id > 5 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.' + end + + if @api_client.config.client_side_validation && order_id < 1 + fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Order') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StoreApi#get_order_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Place an order for a pet + # @param order order placed for purchasing the pet + # @param [Hash] opts the optional parameters + # @return [Order] + def place_order(order, opts = {}) + data, _status_code, _headers = place_order_with_http_info(order, opts) + data + end + + # Place an order for a pet + # @param order order placed for purchasing the pet + # @param [Hash] opts the optional parameters + # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers + def place_order_with_http_info(order, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StoreApi.place_order ...' + end + # verify the required parameter 'order' is set + if @api_client.config.client_side_validation && order.nil? + fail ArgumentError, "Missing the required parameter 'order' when calling StoreApi.place_order" + end + # resource path + local_var_path = '/store/order' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(order) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'Order') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api/user_api.rb new file mode 100644 index 000000000000..665064293480 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -0,0 +1,435 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class UserApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create user + # This can only be done by the logged in user. + # @param user Created user object + # @param [Hash] opts the optional parameters + # @return [nil] + def create_user(user, opts = {}) + create_user_with_http_info(user, opts) + nil + end + + # Create user + # This can only be done by the logged in user. + # @param user Created user object + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def create_user_with_http_info(user, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.create_user ...' + end + # verify the required parameter 'user' is set + if @api_client.config.client_side_validation && user.nil? + fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_user" + end + # resource path + local_var_path = '/user' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(user) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Creates list of users with given input array + # @param user List of user object + # @param [Hash] opts the optional parameters + # @return [nil] + def create_users_with_array_input(user, opts = {}) + create_users_with_array_input_with_http_info(user, opts) + nil + end + + # Creates list of users with given input array + # @param user List of user object + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def create_users_with_array_input_with_http_info(user, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.create_users_with_array_input ...' + end + # verify the required parameter 'user' is set + if @api_client.config.client_side_validation && user.nil? + fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_users_with_array_input" + end + # resource path + local_var_path = '/user/createWithArray' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(user) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#create_users_with_array_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Creates list of users with given input array + # @param user List of user object + # @param [Hash] opts the optional parameters + # @return [nil] + def create_users_with_list_input(user, opts = {}) + create_users_with_list_input_with_http_info(user, opts) + nil + end + + # Creates list of users with given input array + # @param user List of user object + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def create_users_with_list_input_with_http_info(user, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.create_users_with_list_input ...' + end + # verify the required parameter 'user' is set + if @api_client.config.client_side_validation && user.nil? + fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_users_with_list_input" + end + # resource path + local_var_path = '/user/createWithList' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(user) + auth_names = [] + data, status_code, headers = @api_client.call_api(:POST, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#create_users_with_list_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_user(username, opts = {}) + delete_user_with_http_info(username, opts) + nil + end + + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def delete_user_with_http_info(username, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.delete_user ...' + end + # verify the required parameter 'username' is set + if @api_client.config.client_side_validation && username.nil? + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user" + end + # resource path + local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get user by user name + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [User] + def get_user_by_name(username, opts = {}) + data, _status_code, _headers = get_user_by_name_with_http_info(username, opts) + data + end + + # Get user by user name + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers + def get_user_by_name_with_http_info(username, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.get_user_by_name ...' + end + # verify the required parameter 'username' is set + if @api_client.config.client_side_validation && username.nil? + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name" + end + # resource path + local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'User') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Logs user into the system + # @param username The user name for login + # @param password The password for login in clear text + # @param [Hash] opts the optional parameters + # @return [String] + def login_user(username, password, opts = {}) + data, _status_code, _headers = login_user_with_http_info(username, password, opts) + data + end + + # Logs user into the system + # @param username The user name for login + # @param password The password for login in clear text + # @param [Hash] opts the optional parameters + # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers + def login_user_with_http_info(username, password, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.login_user ...' + end + # verify the required parameter 'username' is set + if @api_client.config.client_side_validation && username.nil? + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.login_user" + end + # verify the required parameter 'password' is set + if @api_client.config.client_side_validation && password.nil? + fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user" + end + # resource path + local_var_path = '/user/login' + + # query parameters + query_params = {} + query_params[:'username'] = username + query_params[:'password'] = password + + # header parameters + header_params = {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => 'String') + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#login_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Logs out current logged in user session + # @param [Hash] opts the optional parameters + # @return [nil] + def logout_user(opts = {}) + logout_user_with_http_info(opts) + nil + end + + # Logs out current logged in user session + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def logout_user_with_http_info(opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.logout_user ...' + end + # resource path + local_var_path = '/user/logout' + + # query parameters + query_params = {} + + # header parameters + header_params = {} + + # form parameters + form_params = {} + + # http body (model) + post_body = nil + auth_names = [] + data, status_code, headers = @api_client.call_api(:GET, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#logout_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Updated user + # This can only be done by the logged in user. + # @param username name that need to be deleted + # @param user Updated user object + # @param [Hash] opts the optional parameters + # @return [nil] + def update_user(username, user, opts = {}) + update_user_with_http_info(username, user, opts) + nil + end + + # Updated user + # This can only be done by the logged in user. + # @param username name that need to be deleted + # @param user Updated user object + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers + def update_user_with_http_info(username, user, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UserApi.update_user ...' + end + # verify the required parameter 'username' is set + if @api_client.config.client_side_validation && username.nil? + fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.update_user" + end + # verify the required parameter 'user' is set + if @api_client.config.client_side_validation && user.nil? + fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.update_user" + end + # resource path + local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s) + + # query parameters + query_params = {} + + # header parameters + header_params = {} + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = {} + + # http body (model) + post_body = @api_client.object_to_http_body(user) + auth_names = [] + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UserApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb new file mode 100644 index 000000000000..4626441c6ea0 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api_client.rb @@ -0,0 +1,389 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' +require 'json' +require 'logger' +require 'tempfile' +require 'typhoeus' +require 'uri' + +module Petstore + class ApiClient + # The Configuration object holding settings to be used in the API client. + attr_accessor :config + + # Defines the headers to be used in HTTP requests of all API calls by default. + # + # @return [Hash] + attr_accessor :default_headers + + # Initializes the ApiClient + # @option config [Configuration] Configuration for initializing the object, default to Configuration.default + def initialize(config = Configuration.default) + @config = config + @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" + @default_headers = { + 'Content-Type' => 'application/json', + 'User-Agent' => @user_agent + } + end + + def self.default + @@default ||= ApiClient.new + end + + # Call an API with given options. + # + # @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. + def call_api(http_method, path, opts = {}) + request = build_request(http_method, path, opts) + response = request.run + + if @config.debugging + @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" + end + + unless response.success? + if response.timed_out? + fail ApiError.new('Connection timed out') + elsif response.code == 0 + # Errors from libcurl will be made visible here + fail ApiError.new(:code => 0, + :message => response.return_message) + else + fail ApiError.new(:code => response.code, + :response_headers => response.headers, + :response_body => response.body), + response.status_message + end + end + + if opts[:return_type] + data = deserialize(response, opts[:return_type]) + else + data = nil + end + return data, response.code, response.headers + end + + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Typhoeus::Request] A Typhoeus Request + def build_request(http_method, path, opts = {}) + url = build_request_url(path) + http_method = http_method.to_sym.downcase + + header_params = @default_headers.merge(opts[:header_params] || {}) + query_params = opts[:query_params] || {} + form_params = opts[:form_params] || {} + + update_params_for_auth! header_params, query_params, opts[:auth_names] + + # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false) + _verify_ssl_host = @config.verify_ssl_host ? 2 : 0 + + req_opts = { + :method => http_method, + :headers => header_params, + :params => query_params, + :params_encoding => @config.params_encoding, + :timeout => @config.timeout, + :ssl_verifypeer => @config.verify_ssl, + :ssl_verifyhost => _verify_ssl_host, + :sslcert => @config.cert_file, + :sslkey => @config.key_file, + :verbose => @config.debugging + } + + # 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) + req_body = build_request_body(header_params, form_params, opts[:body]) + req_opts.update :body => req_body + if @config.debugging + @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" + end + end + + request = Typhoeus::Request.new(url, req_opts) + download_file(request) if opts[:return_type] == 'File' + request + end + + # Check if the given MIME is a JSON MIME. + # JSON MIME examples: + # application/json + # application/json; charset=UTF8 + # APPLICATION/JSON + # */* + # @param [String] mime MIME + # @return [Boolean] True if the MIME is application/json + def json_mime?(mime) + (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? + end + + # Deserialize the response to the given return type. + # + # @param [Response] response HTTP response + # @param [String] return_type some examples: "User", "Array", "Hash" + def deserialize(response, return_type) + body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + return @tempfile if return_type == 'File' + + return nil if body.nil? || body.empty? + + # return response body directly for String return type + return body if return_type == 'String' + + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' + + fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + + begin + data = JSON.parse("[#{body}]", :symbolize_names => true)[0] + rescue JSON::ParserError => e + if %w(String Date DateTime).include?(return_type) + data = body + else + raise e + end + end + + convert_to_type data, return_type + end + + # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type + def convert_to_type(data, return_type) + return nil if data.nil? + case return_type + when 'String' + data.to_s + when 'Integer' + data.to_i + when 'Float' + data.to_f + when 'BOOLEAN' + data == true + when 'DateTime' + # parse date time (expecting ISO 8601 format) + DateTime.parse data + when 'Date' + # parse date time (expecting ISO 8601 format) + Date.parse data + when 'Object' + # generic object (usually a Hash), return directly + data + when /\AArray<(.+)>\z/ + # e.g. Array + sub_type = $1 + data.map { |item| convert_to_type(item, sub_type) } + when /\AHash\\z/ + # e.g. Hash + sub_type = $1 + {}.tap do |hash| + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } + end + else + # models, e.g. Pet + Petstore.const_get(return_type).new.tap do |model| + model.build_from_hash data + end + end + end + + # Save response body into a file in (the defined) temporary folder, using the filename + # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. + # + # @see Configuration#temp_folder_path + def download_file(request) + tempfile = nil + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |response| + tempfile.close if tempfile + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" + end + end + + # Sanitize filename by removing path. + # e.g. ../../sun.gif becomes sun.gif + # + # @param [String] filename the filename to be sanitized + # @return [String] the sanitized filename + def sanitize_filename(filename) + filename.gsub(/.*[\/\\]/, '') + end + + def build_request_url(path) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(/\/+/, '/') + URI.encode(@config.base_url + path) + end + + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string + def build_request_body(header_params, form_params, body) + # http form + if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || + header_params['Content-Type'] == 'multipart/form-data' + data = {} + form_params.each do |key, value| + case value + when ::File, ::Array, nil + # let typhoeus handle File, Array and nil parameters + data[key] = value + else + data[key] = value.to_s + end + end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil + end + data + end + + # Update hearder and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] query_params Query parameters + # @param [String] auth_names Authentication scheme name + def update_params_for_auth!(header_params, query_params, auth_names) + Array(auth_names).each do |auth_name| + auth_setting = @config.auth_settings[auth_name] + next unless auth_setting + case auth_setting[:in] + when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] + when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] + else fail ArgumentError, 'Authentication token must be in `query` of `header`' + end + end + end + + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) + def user_agent=(user_agent) + @user_agent = user_agent + @default_headers['User-Agent'] = @user_agent + end + + # Return Accept header based on an array of accepts provided. + # @param [Array] accepts array for Accept + # @return [String] the Accept header (e.g. application/json) + def select_header_accept(accepts) + return nil if accepts.nil? || accepts.empty? + # use JSON when present, otherwise use all of the provided + json_accept = accepts.find { |s| json_mime?(s) } + json_accept || accepts.join(',') + end + + # Return Content-Type header based on an array of content types provided. + # @param [Array] content_types array for Content-Type + # @return [String] the Content-Type header (e.g. application/json) + def select_header_content_type(content_types) + # use application/json by default + return 'application/json' if content_types.nil? || content_types.empty? + # use JSON when present, otherwise use the first one + json_content_type = content_types.find { |s| json_mime?(s) } + json_content_type || content_types.first + end + + # Convert object (array, hash, object, etc) to JSON string. + # @param [Object] model object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_http_body(model) + return model if model.nil? || model.is_a?(String) + local_body = nil + if model.is_a?(Array) + local_body = model.map { |m| object_to_hash(m) } + else + local_body = object_to_hash(model) + end + local_body.to_json + end + + # Convert object(non-array) to hash. + # @param [Object] obj object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_hash(obj) + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj + end + end + + # Build parameter value according to the given collection format. + # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi + def build_collection_param(param, collection_format) + case collection_format + when :csv + param.join(',') + when :ssv + param.join(' ') + when :tsv + param.join("\t") + when :pipes + param.join('|') + when :multi + # return the array directly as typhoeus will handle it as expected + param + else + fail "unknown collection format: #{collection_format.inspect}" + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb new file mode 100644 index 000000000000..3b462a22142e --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/api_error.rb @@ -0,0 +1,38 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +module Petstore + class ApiError < StandardError + attr_reader :code, :response_headers, :response_body + + # Usage examples: + # ApiError.new + # ApiError.new("message") + # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") + # ApiError.new(:code => 404, :message => "Not Found") + def initialize(arg = nil) + if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) + else + super arg + end + + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb new file mode 100644 index 000000000000..20bfc4d720f8 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/configuration.rb @@ -0,0 +1,305 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'uri' + +module Petstore + class Configuration + # Defines url scheme + attr_accessor :scheme + + # Defines url host + attr_accessor :host + + # Defines url base path + attr_accessor :base_path + + # Defines API keys used with API Key authentications. + # + # @return [Hash] key: parameter name, value: parameter value (API key) + # + # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string) + # config.api_key['api_key'] = 'xxx' + attr_accessor :api_key + + # Defines API key prefixes used with API Key authentications. + # + # @return [Hash] key: parameter name, value: API key prefix + # + # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers) + # config.api_key_prefix['api_key'] = 'Token' + attr_accessor :api_key_prefix + + # Defines the username used with HTTP basic authentication. + # + # @return [String] + attr_accessor :username + + # Defines the password used with HTTP basic authentication. + # + # @return [String] + attr_accessor :password + + # Defines the access token (Bearer) used with OAuth2. + attr_accessor :access_token + + # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response + # details will be logged with `logger.debug` (see the `logger` attribute). + # Default to false. + # + # @return [true, false] + attr_accessor :debugging + + # Defines the logger used for debugging. + # Default to `Rails.logger` (when in Rails) or logging to STDOUT. + # + # @return [#debug] + attr_accessor :logger + + # Defines the temporary folder to store downloaded files + # (for API endpoints that have file response). + # Default to use `Tempfile`. + # + # @return [String] + attr_accessor :temp_folder_path + + # The time limit for HTTP request in seconds. + # Default to 0 (never times out). + attr_accessor :timeout + + # Set this to false to skip client side validation in the operation. + # Default to true. + # @return [true, false] + attr_accessor :client_side_validation + + ### TLS/SSL setting + # Set this to false to skip verifying SSL certificate when calling API from https server. + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl + + ### TLS/SSL setting + # Set this to false to skip verifying SSL host name + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :verify_ssl_host + + ### TLS/SSL setting + # Set this to customize the certificate file to verify the peer. + # + # @return [String] the path to the certificate file + # + # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code: + # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145 + attr_accessor :ssl_ca_cert + + ### TLS/SSL setting + # Client certificate file (for client certificate) + attr_accessor :cert_file + + ### TLS/SSL setting + # Client private key file (for client certificate) + attr_accessor :key_file + + # Set this to customize parameters encoding of array parameter with multi collectionFormat. + # Default to nil. + # + # @see The params_encoding option of Ethon. Related source code: + # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96 + attr_accessor :params_encoding + + attr_accessor :inject_format + + attr_accessor :force_ending_format + + def initialize + @scheme = 'http' + @host = 'petstore.swagger.io' + @base_path = '/v2' + @api_key = {} + @api_key_prefix = {} + @timeout = 0 + @client_side_validation = true + @verify_ssl = true + @verify_ssl_host = true + @params_encoding = nil + @cert_file = nil + @key_file = nil + @debugging = false + @inject_format = false + @force_ending_format = false + @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) + + yield(self) if block_given? + end + + # The default Configuration object. + def self.default + @@default ||= Configuration.new + end + + def configure + yield(self) if block_given? + end + + def scheme=(scheme) + # remove :// from scheme + @scheme = scheme.sub(/:\/\//, '') + end + + def host=(host) + # remove http(s):// and anything after a slash + @host = host.sub(/https?:\/\//, '').split('/').first + end + + def base_path=(base_path) + # Add leading and trailing slashes to base_path + @base_path = "/#{base_path}".gsub(/\/+/, '/') + @base_path = '' if @base_path == '/' + end + + def base_url + url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') + URI.encode(url) + end + + # Gets API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def api_key_with_prefix(param_name) + if @api_key_prefix[param_name] + "#{@api_key_prefix[param_name]} #{@api_key[param_name]}" + else + @api_key[param_name] + end + end + + # Gets Basic Auth token string + def basic_auth_token + 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") + end + + # Returns Auth Settings hash for api client. + def auth_settings + { + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key', + value: api_key_with_prefix('api_key') + }, + 'api_key_query' => + { + type: 'api_key', + in: 'query', + key: 'api_key_query', + value: api_key_with_prefix('api_key_query') + }, + 'http_basic_test' => + { + type: 'basic', + in: 'header', + key: 'Authorization', + value: basic_auth_token + }, + 'petstore_auth' => + { + type: 'oauth2', + in: 'header', + key: 'Authorization', + value: "Bearer #{access_token}" + }, + } + end + + # Returns an array of Server setting + def server_settings + [ + { + url: "http://{server}.swagger.io:{port}/v2", + description: "petstore server", + variables: { + server: { + description: "No descriptoin provided", + default_value: "petstore", + enum_values: [ + "petstore", + "qa-petstore", + "dev-petstore" + ] + }, + port: { + description: "No descriptoin provided", + default_value: "80", + enum_values: [ + "80", + "8080" + ] + } + } + }, + { + url: "https://localhost:8080/{version}", + description: "The local server", + variables: { + version: { + description: "No descriptoin provided", + default_value: "v2", + enum_values: [ + "v1", + "v2" + ] + } + } + } + ] + end + + # Returns URL based on server settings + # + # @param index array index of the server settings + # @param variables hash of variable and the corresponding value + def server_url(index, variables = {}) + servers = server_settings + + # check array index out of bound + if (index < 0 || index > servers.size) + fail ArgumentError "Invalid index #{index} when selecting the server. Must be less than #{servers.size}" + end + + server = servers[index] + url = server[:url] + + # go through variable and assign a value + server[:variables].each do |name, variable| + if variables.key?(name) + if (server[:variables][name][:enum_values].include? variables[name]) + url.gsub! "{" + name.to_s + "}", variables[name] + else + fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." + end + else + # use default value + url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value] + end + end + + url + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb new file mode 100644 index 000000000000..05a29dc1e894 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/additional_properties_class.rb @@ -0,0 +1,196 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class AdditionalPropertiesClass + attr_accessor :map_property + + attr_accessor :map_of_map_property + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'map_property' => :'map_property', + :'map_of_map_property' => :'map_of_map_property' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'map_property' => :'Hash', + :'map_of_map_property' => :'Hash>' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'map_property') + if (value = attributes[:'map_property']).is_a?(Hash) + self.map_property = value + end + end + + if attributes.has_key?(:'map_of_map_property') + if (value = attributes[:'map_of_map_property']).is_a?(Hash) + self.map_of_map_property = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + map_property == o.map_property && + map_of_map_property == o.map_of_map_property + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [map_property, map_of_map_property].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb new file mode 100644 index 000000000000..e0886f81c3d6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal.rb @@ -0,0 +1,199 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Animal + attr_accessor :class_name + + attr_accessor :color + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'class_name' => :'className', + :'color' => :'color' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'class_name' => :'String', + :'color' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'className') + self.class_name = attributes[:'className'] + end + + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = 'red' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push('invalid value for "class_name", class_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @class_name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name && + color == o.color + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [class_name, color].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal_farm.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal_farm.rb new file mode 100644 index 000000000000..00e5f58a7a61 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/animal_farm.rb @@ -0,0 +1,174 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class AnimalFarm + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + } + end + + # Attribute type mapping. + def self.openapi_types + { + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb new file mode 100644 index 000000000000..0535042e220a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/api_response.rb @@ -0,0 +1,201 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class ApiResponse + attr_accessor :code + + attr_accessor :type + + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'type' => :'type', + :'message' => :'message' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'Integer', + :'type' => :'String', + :'message' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.has_key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.has_key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + code == o.code && + type == o.type && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [code, type, message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb new file mode 100644 index 000000000000..a32087c52954 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_array_of_number_only.rb @@ -0,0 +1,185 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class ArrayOfArrayOfNumberOnly + attr_accessor :array_array_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'array_array_number' => :'ArrayArrayNumber' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'array_array_number' => :'Array>' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'ArrayArrayNumber') + if (value = attributes[:'ArrayArrayNumber']).is_a?(Array) + self.array_array_number = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + array_array_number == o.array_array_number + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [array_array_number].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb new file mode 100644 index 000000000000..4049a385302e --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_of_number_only.rb @@ -0,0 +1,185 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class ArrayOfNumberOnly + attr_accessor :array_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'array_number' => :'ArrayNumber' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'array_number' => :'Array' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'ArrayNumber') + if (value = attributes[:'ArrayNumber']).is_a?(Array) + self.array_number = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + array_number == o.array_number + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [array_number].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb new file mode 100644 index 000000000000..6c8385a1d9ec --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/array_test.rb @@ -0,0 +1,207 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class ArrayTest + attr_accessor :array_of_string + + attr_accessor :array_array_of_integer + + attr_accessor :array_array_of_model + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'array_of_string' => :'array_of_string', + :'array_array_of_integer' => :'array_array_of_integer', + :'array_array_of_model' => :'array_array_of_model' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'array_of_string' => :'Array', + :'array_array_of_integer' => :'Array>', + :'array_array_of_model' => :'Array>' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'array_of_string') + if (value = attributes[:'array_of_string']).is_a?(Array) + self.array_of_string = value + end + end + + if attributes.has_key?(:'array_array_of_integer') + if (value = attributes[:'array_array_of_integer']).is_a?(Array) + self.array_array_of_integer = value + end + end + + if attributes.has_key?(:'array_array_of_model') + if (value = attributes[:'array_array_of_model']).is_a?(Array) + self.array_array_of_model = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + array_of_string == o.array_of_string && + array_array_of_integer == o.array_array_of_integer && + array_array_of_model == o.array_array_of_model + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [array_of_string, array_array_of_integer, array_array_of_model].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/body4.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/body4.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/body4.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/body4.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb new file mode 100644 index 000000000000..e16b47a688fb --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/capitalization.rb @@ -0,0 +1,229 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Capitalization + attr_accessor :small_camel + + attr_accessor :capital_camel + + attr_accessor :small_snake + + attr_accessor :capital_snake + + attr_accessor :sca_eth_flow_points + + # Name of the pet + attr_accessor :att_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'small_camel' => :'smallCamel', + :'capital_camel' => :'CapitalCamel', + :'small_snake' => :'small_Snake', + :'capital_snake' => :'Capital_Snake', + :'sca_eth_flow_points' => :'SCA_ETH_Flow_Points', + :'att_name' => :'ATT_NAME' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'small_camel' => :'String', + :'capital_camel' => :'String', + :'small_snake' => :'String', + :'capital_snake' => :'String', + :'sca_eth_flow_points' => :'String', + :'att_name' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'smallCamel') + self.small_camel = attributes[:'smallCamel'] + end + + if attributes.has_key?(:'CapitalCamel') + self.capital_camel = attributes[:'CapitalCamel'] + end + + if attributes.has_key?(:'small_Snake') + self.small_snake = attributes[:'small_Snake'] + end + + if attributes.has_key?(:'Capital_Snake') + self.capital_snake = attributes[:'Capital_Snake'] + end + + if attributes.has_key?(:'SCA_ETH_Flow_Points') + self.sca_eth_flow_points = attributes[:'SCA_ETH_Flow_Points'] + end + + if attributes.has_key?(:'ATT_NAME') + self.att_name = attributes[:'ATT_NAME'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + small_camel == o.small_camel && + capital_camel == o.capital_camel && + small_snake == o.small_snake && + capital_snake == o.capital_snake && + sca_eth_flow_points == o.sca_eth_flow_points && + att_name == o.att_name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [small_camel, capital_camel, small_snake, capital_snake, sca_eth_flow_points, att_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb new file mode 100644 index 000000000000..5fbf20468bc6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/cat.rb @@ -0,0 +1,208 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Cat + attr_accessor :class_name + + attr_accessor :color + + attr_accessor :declawed + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'class_name' => :'className', + :'color' => :'color', + :'declawed' => :'declawed' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'class_name' => :'String', + :'color' => :'String', + :'declawed' => :'BOOLEAN' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'className') + self.class_name = attributes[:'className'] + end + + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = 'red' + end + + if attributes.has_key?(:'declawed') + self.declawed = attributes[:'declawed'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push('invalid value for "class_name", class_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @class_name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name && + color == o.color && + declawed == o.declawed + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [class_name, color, declawed].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb new file mode 100644 index 000000000000..881623cbe0ed --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/category.rb @@ -0,0 +1,199 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Category + attr_accessor :id + + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'Integer', + :'name' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.has_key?(:'name') + self.name = attributes[:'name'] + else + self.name = 'default-name' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb new file mode 100644 index 000000000000..d326e8b5f1a1 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/class_model.rb @@ -0,0 +1,184 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + # Model for testing model with \"_class\" property + class ClassModel + attr_accessor :_class + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_class' => :'_class' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'_class' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'_class') + self._class = attributes[:'_class'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _class == o._class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [_class].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb new file mode 100644 index 000000000000..d33a0f3d7a3e --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/client.rb @@ -0,0 +1,183 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Client + attr_accessor :client + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'client' => :'client' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'client' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'client') + self.client = attributes[:'client'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + client == o.client + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [client].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb new file mode 100644 index 000000000000..45736e22486a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/dog.rb @@ -0,0 +1,208 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Dog + attr_accessor :class_name + + attr_accessor :color + + attr_accessor :breed + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'class_name' => :'className', + :'color' => :'color', + :'breed' => :'breed' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'class_name' => :'String', + :'color' => :'String', + :'breed' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'className') + self.class_name = attributes[:'className'] + end + + if attributes.has_key?(:'color') + self.color = attributes[:'color'] + else + self.color = 'red' + end + + if attributes.has_key?(:'breed') + self.breed = attributes[:'breed'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push('invalid value for "class_name", class_name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @class_name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + class_name == o.class_name && + color == o.color && + breed == o.breed + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [class_name, color, breed].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb new file mode 100644 index 000000000000..8cdc70993792 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_arrays.rb @@ -0,0 +1,228 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class EnumArrays + attr_accessor :just_symbol + + attr_accessor :array_enum + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'just_symbol' => :'just_symbol', + :'array_enum' => :'array_enum' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'just_symbol' => :'String', + :'array_enum' => :'Array' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'just_symbol') + self.just_symbol = attributes[:'just_symbol'] + end + + if attributes.has_key?(:'array_enum') + if (value = attributes[:'array_enum']).is_a?(Array) + self.array_enum = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + just_symbol_validator = EnumAttributeValidator.new('String', ['>=', '$']) + return false unless just_symbol_validator.valid?(@just_symbol) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] just_symbol Object to be assigned + def just_symbol=(just_symbol) + validator = EnumAttributeValidator.new('String', ['>=', '$']) + unless validator.valid?(just_symbol) + fail ArgumentError, 'invalid value for "just_symbol", must be one of #{validator.allowable_values}.' + end + @just_symbol = just_symbol + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + just_symbol == o.just_symbol && + array_enum == o.array_enum + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [just_symbol, array_enum].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb new file mode 100644 index 000000000000..95e58d897c45 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_class.rb @@ -0,0 +1,31 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class EnumClass + + ABC = '_abc'.freeze + EFG = '-efg'.freeze + XYZ = '(xyz)'.freeze + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + constantValues = EnumClass.constants.select { |c| EnumClass::const_get(c) == value } + raise "Invalid ENUM value #{value} for class #EnumClass" if constantValues.empty? + value + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb new file mode 100644 index 000000000000..f389136d168f --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/enum_test.rb @@ -0,0 +1,294 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class EnumTest + attr_accessor :enum_string + + attr_accessor :enum_string_required + + attr_accessor :enum_integer + + attr_accessor :enum_number + + attr_accessor :outer_enum + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'enum_string' => :'enum_string', + :'enum_string_required' => :'enum_string_required', + :'enum_integer' => :'enum_integer', + :'enum_number' => :'enum_number', + :'outer_enum' => :'outerEnum' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'enum_string' => :'String', + :'enum_string_required' => :'String', + :'enum_integer' => :'Integer', + :'enum_number' => :'Float', + :'outer_enum' => :'OuterEnum' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'enum_string') + self.enum_string = attributes[:'enum_string'] + end + + if attributes.has_key?(:'enum_string_required') + self.enum_string_required = attributes[:'enum_string_required'] + end + + if attributes.has_key?(:'enum_integer') + self.enum_integer = attributes[:'enum_integer'] + end + + if attributes.has_key?(:'enum_number') + self.enum_number = attributes[:'enum_number'] + end + + if attributes.has_key?(:'outerEnum') + self.outer_enum = attributes[:'outerEnum'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @enum_string_required.nil? + invalid_properties.push('invalid value for "enum_string_required", enum_string_required cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + enum_string_validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', '']) + return false unless enum_string_validator.valid?(@enum_string) + return false if @enum_string_required.nil? + enum_string_required_validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', '']) + return false unless enum_string_required_validator.valid?(@enum_string_required) + enum_integer_validator = EnumAttributeValidator.new('Integer', ['1', '-1']) + return false unless enum_integer_validator.valid?(@enum_integer) + enum_number_validator = EnumAttributeValidator.new('Float', ['1.1', '-1.2']) + return false unless enum_number_validator.valid?(@enum_number) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] enum_string Object to be assigned + def enum_string=(enum_string) + validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', '']) + unless validator.valid?(enum_string) + fail ArgumentError, 'invalid value for "enum_string", must be one of #{validator.allowable_values}.' + end + @enum_string = enum_string + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] enum_string_required Object to be assigned + def enum_string_required=(enum_string_required) + validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', '']) + unless validator.valid?(enum_string_required) + fail ArgumentError, 'invalid value for "enum_string_required", must be one of #{validator.allowable_values}.' + end + @enum_string_required = enum_string_required + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] enum_integer Object to be assigned + def enum_integer=(enum_integer) + validator = EnumAttributeValidator.new('Integer', ['1', '-1']) + unless validator.valid?(enum_integer) + fail ArgumentError, 'invalid value for "enum_integer", must be one of #{validator.allowable_values}.' + end + @enum_integer = enum_integer + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] enum_number Object to be assigned + def enum_number=(enum_number) + validator = EnumAttributeValidator.new('Float', ['1.1', '-1.2']) + unless validator.valid?(enum_number) + fail ArgumentError, 'invalid value for "enum_number", must be one of #{validator.allowable_values}.' + end + @enum_number = enum_number + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + enum_string == o.enum_string && + enum_string_required == o.enum_string_required && + enum_integer == o.enum_integer && + enum_number == o.enum_number && + outer_enum == o.outer_enum + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [enum_string, enum_string_required, enum_integer, enum_number, outer_enum].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb new file mode 100644 index 000000000000..fddf06f63865 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file.rb @@ -0,0 +1,185 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + # Must be named `File` for test. + class File + # Test capitalization + attr_accessor :source_uri + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'source_uri' => :'sourceURI' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'source_uri' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'sourceURI') + self.source_uri = attributes[:'sourceURI'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + source_uri == o.source_uri + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [source_uri].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb new file mode 100644 index 000000000000..3c8a2f0bf15a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/file_schema_test_class.rb @@ -0,0 +1,194 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class FileSchemaTestClass + attr_accessor :file + + attr_accessor :files + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'file' => :'file', + :'files' => :'files' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'file' => :'File', + :'files' => :'Array' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'file') + self.file = attributes[:'file'] + end + + if attributes.has_key?(:'files') + if (value = attributes[:'files']).is_a?(Array) + self.files = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + file == o.file && + files == o.files + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [file, files].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/foo.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/foo.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/foo.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb new file mode 100644 index 000000000000..be1927e8e7f7 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -0,0 +1,528 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class FormatTest + attr_accessor :integer + + attr_accessor :int32 + + attr_accessor :int64 + + attr_accessor :number + + attr_accessor :float + + attr_accessor :double + + attr_accessor :string + + attr_accessor :byte + + attr_accessor :binary + + attr_accessor :date + + attr_accessor :date_time + + attr_accessor :uuid + + attr_accessor :password + + # A string that is a 10 digit number. Can have leading zeros. + attr_accessor :pattern_with_digits + + # A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. + attr_accessor :pattern_with_digits_and_delimiter + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'integer' => :'integer', + :'int32' => :'int32', + :'int64' => :'int64', + :'number' => :'number', + :'float' => :'float', + :'double' => :'double', + :'string' => :'string', + :'byte' => :'byte', + :'binary' => :'binary', + :'date' => :'date', + :'date_time' => :'dateTime', + :'uuid' => :'uuid', + :'password' => :'password', + :'pattern_with_digits' => :'pattern_with_digits', + :'pattern_with_digits_and_delimiter' => :'pattern_with_digits_and_delimiter' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'integer' => :'Integer', + :'int32' => :'Integer', + :'int64' => :'Integer', + :'number' => :'Float', + :'float' => :'Float', + :'double' => :'Float', + :'string' => :'String', + :'byte' => :'String', + :'binary' => :'File', + :'date' => :'Date', + :'date_time' => :'DateTime', + :'uuid' => :'String', + :'password' => :'String', + :'pattern_with_digits' => :'String', + :'pattern_with_digits_and_delimiter' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'integer') + self.integer = attributes[:'integer'] + end + + if attributes.has_key?(:'int32') + self.int32 = attributes[:'int32'] + end + + if attributes.has_key?(:'int64') + self.int64 = attributes[:'int64'] + end + + if attributes.has_key?(:'number') + self.number = attributes[:'number'] + end + + if attributes.has_key?(:'float') + self.float = attributes[:'float'] + end + + if attributes.has_key?(:'double') + self.double = attributes[:'double'] + end + + if attributes.has_key?(:'string') + self.string = attributes[:'string'] + end + + if attributes.has_key?(:'byte') + self.byte = attributes[:'byte'] + end + + if attributes.has_key?(:'binary') + self.binary = attributes[:'binary'] + end + + if attributes.has_key?(:'date') + self.date = attributes[:'date'] + end + + if attributes.has_key?(:'dateTime') + self.date_time = attributes[:'dateTime'] + end + + if attributes.has_key?(:'uuid') + self.uuid = attributes[:'uuid'] + end + + if attributes.has_key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.has_key?(:'pattern_with_digits') + self.pattern_with_digits = attributes[:'pattern_with_digits'] + end + + if attributes.has_key?(:'pattern_with_digits_and_delimiter') + self.pattern_with_digits_and_delimiter = attributes[:'pattern_with_digits_and_delimiter'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if !@integer.nil? && @integer > 100 + invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.') + end + + if !@integer.nil? && @integer < 10 + invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.') + end + + if !@int32.nil? && @int32 > 200 + invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.') + end + + if !@int32.nil? && @int32 < 20 + invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.') + end + + if @number.nil? + invalid_properties.push('invalid value for "number", number cannot be nil.') + end + + if @number > 543.2 + invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.') + end + + if @number < 32.1 + invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.') + end + + if !@float.nil? && @float > 987.6 + invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.') + end + + if !@float.nil? && @float < 54.3 + invalid_properties.push('invalid value for "float", must be greater than or equal to 54.3.') + end + + if !@double.nil? && @double > 123.4 + invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.') + end + + if !@double.nil? && @double < 67.8 + invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.') + end + + if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) + invalid_properties.push('invalid value for "string", must conform to the pattern /[a-z]/i.') + end + + if @byte.nil? + invalid_properties.push('invalid value for "byte", byte cannot be nil.') + end + + if @date.nil? + invalid_properties.push('invalid value for "date", date cannot be nil.') + end + + if @password.nil? + invalid_properties.push('invalid value for "password", password cannot be nil.') + end + + if @password.to_s.length > 64 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.') + end + + if @password.to_s.length < 10 + invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.') + end + + if !@pattern_with_digits.nil? && @pattern_with_digits !~ Regexp.new(/^\d{10}$/) + invalid_properties.push('invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.') + end + + if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) + invalid_properties.push('invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if !@integer.nil? && @integer > 100 + return false if !@integer.nil? && @integer < 10 + return false if !@int32.nil? && @int32 > 200 + return false if !@int32.nil? && @int32 < 20 + return false if @number.nil? + return false if @number > 543.2 + return false if @number < 32.1 + return false if !@float.nil? && @float > 987.6 + return false if !@float.nil? && @float < 54.3 + return false if !@double.nil? && @double > 123.4 + return false if !@double.nil? && @double < 67.8 + return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) + return false if @byte.nil? + return false if @date.nil? + return false if @password.nil? + return false if @password.to_s.length > 64 + return false if @password.to_s.length < 10 + return false if !@pattern_with_digits.nil? && @pattern_with_digits !~ Regexp.new(/^\d{10}$/) + return false if !@pattern_with_digits_and_delimiter.nil? && @pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) + true + end + + # Custom attribute writer method with validation + # @param [Object] integer Value to be assigned + def integer=(integer) + if !integer.nil? && integer > 100 + fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.' + end + + if !integer.nil? && integer < 10 + fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.' + end + + @integer = integer + end + + # Custom attribute writer method with validation + # @param [Object] int32 Value to be assigned + def int32=(int32) + if !int32.nil? && int32 > 200 + fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.' + end + + if !int32.nil? && int32 < 20 + fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.' + end + + @int32 = int32 + end + + # Custom attribute writer method with validation + # @param [Object] number Value to be assigned + def number=(number) + if number.nil? + fail ArgumentError, 'number cannot be nil' + end + + if number > 543.2 + fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.' + end + + if number < 32.1 + fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.' + end + + @number = number + end + + # Custom attribute writer method with validation + # @param [Object] float Value to be assigned + def float=(float) + if !float.nil? && float > 987.6 + fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.' + end + + if !float.nil? && float < 54.3 + fail ArgumentError, 'invalid value for "float", must be greater than or equal to 54.3.' + end + + @float = float + end + + # Custom attribute writer method with validation + # @param [Object] double Value to be assigned + def double=(double) + if !double.nil? && double > 123.4 + fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.' + end + + if !double.nil? && double < 67.8 + fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.' + end + + @double = double + end + + # Custom attribute writer method with validation + # @param [Object] string Value to be assigned + def string=(string) + if !string.nil? && string !~ Regexp.new(/[a-z]/i) + fail ArgumentError, 'invalid value for "string", must conform to the pattern /[a-z]/i.' + end + + @string = string + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if password.nil? + fail ArgumentError, 'password cannot be nil' + end + + if password.to_s.length > 64 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.' + end + + if password.to_s.length < 10 + fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] pattern_with_digits Value to be assigned + def pattern_with_digits=(pattern_with_digits) + if !pattern_with_digits.nil? && pattern_with_digits !~ Regexp.new(/^\d{10}$/) + fail ArgumentError, 'invalid value for "pattern_with_digits", must conform to the pattern /^\d{10}$/.' + end + + @pattern_with_digits = pattern_with_digits + end + + # Custom attribute writer method with validation + # @param [Object] pattern_with_digits_and_delimiter Value to be assigned + def pattern_with_digits_and_delimiter=(pattern_with_digits_and_delimiter) + if !pattern_with_digits_and_delimiter.nil? && pattern_with_digits_and_delimiter !~ Regexp.new(/^image_\d{1,3}$/i) + fail ArgumentError, 'invalid value for "pattern_with_digits_and_delimiter", must conform to the pattern /^image_\d{1,3}$/i.' + end + + @pattern_with_digits_and_delimiter = pattern_with_digits_and_delimiter + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + integer == o.integer && + int32 == o.int32 && + int64 == o.int64 && + number == o.number && + float == o.float && + double == o.double && + string == o.string && + byte == o.byte && + binary == o.binary && + date == o.date && + date_time == o.date_time && + uuid == o.uuid && + password == o.password && + pattern_with_digits == o.pattern_with_digits && + pattern_with_digits_and_delimiter == o.pattern_with_digits_and_delimiter + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password, pattern_with_digits, pattern_with_digits_and_delimiter].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb new file mode 100644 index 000000000000..1bdb32d00173 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/has_only_read_only.rb @@ -0,0 +1,192 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class HasOnlyReadOnly + attr_accessor :bar + + attr_accessor :foo + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'bar' => :'bar', + :'foo' => :'foo' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'bar' => :'String', + :'foo' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'bar') + self.bar = attributes[:'bar'] + end + + if attributes.has_key?(:'foo') + self.foo = attributes[:'foo'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bar == o.bar && + foo == o.foo + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [bar, foo].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_default.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/inline_response_default.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/inline_response_default.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb new file mode 100644 index 000000000000..2b9e4e522381 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/list.rb @@ -0,0 +1,183 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class List + attr_accessor :_123_list + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_123_list' => :'123-list' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'_123_list' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'123-list') + self._123_list = attributes[:'123-list'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _123_list == o._123_list + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [_123_list].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb new file mode 100644 index 000000000000..3cee0eb699e2 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/map_test.rb @@ -0,0 +1,240 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class MapTest + attr_accessor :map_map_of_string + + attr_accessor :map_of_enum_string + + attr_accessor :direct_map + + attr_accessor :indirect_map + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'map_map_of_string' => :'map_map_of_string', + :'map_of_enum_string' => :'map_of_enum_string', + :'direct_map' => :'direct_map', + :'indirect_map' => :'indirect_map' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'map_map_of_string' => :'Hash>', + :'map_of_enum_string' => :'Hash', + :'direct_map' => :'Hash', + :'indirect_map' => :'Hash' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'map_map_of_string') + if (value = attributes[:'map_map_of_string']).is_a?(Hash) + self.map_map_of_string = value + end + end + + if attributes.has_key?(:'map_of_enum_string') + if (value = attributes[:'map_of_enum_string']).is_a?(Hash) + self.map_of_enum_string = value + end + end + + if attributes.has_key?(:'direct_map') + if (value = attributes[:'direct_map']).is_a?(Hash) + self.direct_map = value + end + end + + if attributes.has_key?(:'indirect_map') + if (value = attributes[:'indirect_map']).is_a?(Hash) + self.indirect_map = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + map_map_of_string == o.map_map_of_string && + map_of_enum_string == o.map_of_enum_string && + direct_map == o.direct_map && + indirect_map == o.indirect_map + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [map_map_of_string, map_of_enum_string, direct_map, indirect_map].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb new file mode 100644 index 000000000000..7fe02e0ba3dc --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/mixed_properties_and_additional_properties_class.rb @@ -0,0 +1,203 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class MixedPropertiesAndAdditionalPropertiesClass + attr_accessor :uuid + + attr_accessor :date_time + + attr_accessor :map + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'uuid' => :'uuid', + :'date_time' => :'dateTime', + :'map' => :'map' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'uuid' => :'String', + :'date_time' => :'DateTime', + :'map' => :'Hash' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'uuid') + self.uuid = attributes[:'uuid'] + end + + if attributes.has_key?(:'dateTime') + self.date_time = attributes[:'dateTime'] + end + + if attributes.has_key?(:'map') + if (value = attributes[:'map']).is_a?(Hash) + self.map = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + uuid == o.uuid && + date_time == o.date_time && + map == o.map + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [uuid, date_time, map].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb new file mode 100644 index 000000000000..1f911b688283 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model200_response.rb @@ -0,0 +1,193 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + # Model for testing model name starting with number + class Model200Response + attr_accessor :name + + attr_accessor :_class + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'_class' => :'class' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'Integer', + :'_class' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.has_key?(:'class') + self._class = attributes[:'class'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + _class == o._class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [name, _class].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb new file mode 100644 index 000000000000..131ca9fa2305 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -0,0 +1,184 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + # Model for testing reserved words + class ModelReturn + attr_accessor :_return + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'_return' => :'return' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'_return' => :'Integer' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'return') + self._return = attributes[:'return'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + _return == o._return + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [_return].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb new file mode 100644 index 000000000000..3a35660bde84 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/name.rb @@ -0,0 +1,216 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + # Model for testing model name same as property name + class Name + attr_accessor :name + + attr_accessor :snake_case + + attr_accessor :property + + attr_accessor :_123_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'snake_case' => :'snake_case', + :'property' => :'property', + :'_123_number' => :'123Number' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'Integer', + :'snake_case' => :'Integer', + :'property' => :'String', + :'_123_number' => :'Integer' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.has_key?(:'snake_case') + self.snake_case = attributes[:'snake_case'] + end + + if attributes.has_key?(:'property') + self.property = attributes[:'property'] + end + + if attributes.has_key?(:'123Number') + self._123_number = attributes[:'123Number'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @name.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + snake_case == o.snake_case && + property == o.property && + _123_number == o._123_number + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [name, snake_case, property, _123_number].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb new file mode 100644 index 000000000000..01f7c59da3b6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/number_only.rb @@ -0,0 +1,183 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class NumberOnly + attr_accessor :just_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'just_number' => :'JustNumber' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'just_number' => :'Float' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'JustNumber') + self.just_number = attributes[:'JustNumber'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + just_number == o.just_number + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [just_number].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb new file mode 100644 index 000000000000..13d62352de0f --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/order.rb @@ -0,0 +1,265 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Order + attr_accessor :id + + attr_accessor :pet_id + + attr_accessor :quantity + + attr_accessor :ship_date + + # Order Status + attr_accessor :status + + attr_accessor :complete + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'pet_id' => :'petId', + :'quantity' => :'quantity', + :'ship_date' => :'shipDate', + :'status' => :'status', + :'complete' => :'complete' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'Integer', + :'pet_id' => :'Integer', + :'quantity' => :'Integer', + :'ship_date' => :'DateTime', + :'status' => :'String', + :'complete' => :'BOOLEAN' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.has_key?(:'petId') + self.pet_id = attributes[:'petId'] + end + + if attributes.has_key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + + if attributes.has_key?(:'shipDate') + self.ship_date = attributes[:'shipDate'] + end + + if attributes.has_key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.has_key?(:'complete') + self.complete = attributes[:'complete'] + else + self.complete = false + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + status_validator = EnumAttributeValidator.new('String', ['placed', 'approved', 'delivered']) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ['placed', 'approved', 'delivered']) + unless validator.valid?(status) + fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.' + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + pet_id == o.pet_id && + quantity == o.quantity && + ship_date == o.ship_date && + status == o.status && + complete == o.complete + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [id, pet_id, quantity, ship_date, status, complete].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_boolean.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_boolean.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb new file mode 100644 index 000000000000..50a5ac92d027 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -0,0 +1,201 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class OuterComposite + attr_accessor :my_number + + attr_accessor :my_string + + attr_accessor :my_boolean + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'my_number' => :'my_number', + :'my_string' => :'my_string', + :'my_boolean' => :'my_boolean' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'my_number' => :'Float', + :'my_string' => :'String', + :'my_boolean' => :'BOOLEAN' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'my_number') + self.my_number = attributes[:'my_number'] + end + + if attributes.has_key?(:'my_string') + self.my_string = attributes[:'my_string'] + end + + if attributes.has_key?(:'my_boolean') + self.my_boolean = attributes[:'my_boolean'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + my_number == o.my_number && + my_string == o.my_string && + my_boolean == o.my_boolean + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [my_number, my_string, my_boolean].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb new file mode 100644 index 000000000000..a97b2107538d --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_enum.rb @@ -0,0 +1,31 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class OuterEnum + + PLACED = 'placed'.freeze + APPROVED = 'approved'.freeze + DELIVERED = 'delivered'.freeze + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + constantValues = OuterEnum.constants.select { |c| OuterEnum::const_get(c) == value } + raise "Invalid ENUM value #{value} for class #OuterEnum" if constantValues.empty? + value + end + end +end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_number.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_number.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/outer_number.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_number.rb diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_string.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_string.rb similarity index 100% rename from samples/client/petstore/ruby/lib/petstore/models/outer_string.rb rename to samples/openapi3/client/petstore/ruby/lib/petstore/models/outer_string.rb diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb new file mode 100644 index 000000000000..ea8d7ed6549c --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/pet.rb @@ -0,0 +1,277 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Pet + attr_accessor :id + + attr_accessor :category + + attr_accessor :name + + attr_accessor :photo_urls + + attr_accessor :tags + + # pet status in the store + attr_accessor :status + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'category' => :'category', + :'name' => :'name', + :'photo_urls' => :'photoUrls', + :'tags' => :'tags', + :'status' => :'status' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'Integer', + :'category' => :'Category', + :'name' => :'String', + :'photo_urls' => :'Array', + :'tags' => :'Array', + :'status' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.has_key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.has_key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.has_key?(:'photoUrls') + if (value = attributes[:'photoUrls']).is_a?(Array) + self.photo_urls = value + end + end + + if attributes.has_key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.has_key?(:'status') + self.status = attributes[:'status'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @photo_urls.nil? + invalid_properties.push('invalid value for "photo_urls", photo_urls cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @name.nil? + return false if @photo_urls.nil? + status_validator = EnumAttributeValidator.new('String', ['available', 'pending', 'sold']) + return false unless status_validator.valid?(@status) + true + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned + def status=(status) + validator = EnumAttributeValidator.new('String', ['available', 'pending', 'sold']) + unless validator.valid?(status) + fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.' + end + @status = status + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + category == o.category && + name == o.name && + photo_urls == o.photo_urls && + tags == o.tags && + status == o.status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [id, category, name, photo_urls, tags, status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb new file mode 100644 index 000000000000..2e3cba6fd069 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/read_only_first.rb @@ -0,0 +1,192 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class ReadOnlyFirst + attr_accessor :bar + + attr_accessor :baz + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'bar' => :'bar', + :'baz' => :'baz' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'bar' => :'String', + :'baz' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'bar') + self.bar = attributes[:'bar'] + end + + if attributes.has_key?(:'baz') + self.baz = attributes[:'baz'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bar == o.bar && + baz == o.baz + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [bar, baz].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb new file mode 100644 index 000000000000..d8cdfdafec70 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -0,0 +1,183 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class SpecialModelName + attr_accessor :special_property_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'special_property_name' => :'$special[property.name]' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'special_property_name' => :'Integer' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'$special[property.name]') + self.special_property_name = attributes[:'$special[property.name]'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + special_property_name == o.special_property_name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [special_property_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/string_boolean_map.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/string_boolean_map.rb new file mode 100644 index 000000000000..692d306720de --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/string_boolean_map.rb @@ -0,0 +1,174 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class StringBooleanMap + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + } + end + + # Attribute type mapping. + def self.openapi_types + { + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb new file mode 100644 index 000000000000..d419df35bd78 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/tag.rb @@ -0,0 +1,192 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class Tag + attr_accessor :id + + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'Integer', + :'name' => :'String' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.has_key?(:'name') + self.name = attributes[:'name'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [id, name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb new file mode 100644 index 000000000000..6a621582b32a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/models/user.rb @@ -0,0 +1,247 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +require 'date' + +module Petstore + class User + attr_accessor :id + + attr_accessor :username + + attr_accessor :first_name + + attr_accessor :last_name + + attr_accessor :email + + attr_accessor :password + + attr_accessor :phone + + # User Status + attr_accessor :user_status + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'username' => :'username', + :'first_name' => :'firstName', + :'last_name' => :'lastName', + :'email' => :'email', + :'password' => :'password', + :'phone' => :'phone', + :'user_status' => :'userStatus' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'Integer', + :'username' => :'String', + :'first_name' => :'String', + :'last_name' => :'String', + :'email' => :'String', + :'password' => :'String', + :'phone' => :'String', + :'user_status' => :'Integer' + } + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + return unless attributes.is_a?(Hash) + + # convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } + + if attributes.has_key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.has_key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.has_key?(:'firstName') + self.first_name = attributes[:'firstName'] + end + + if attributes.has_key?(:'lastName') + self.last_name = attributes[:'lastName'] + end + + if attributes.has_key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.has_key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.has_key?(:'phone') + self.phone = attributes[:'phone'] + end + + if attributes.has_key?(:'userStatus') + self.user_status = attributes[:'userStatus'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + username == o.username && + first_name == o.first_name && + last_name == o.last_name && + email == o.email && + password == o.password && + phone == o.phone && + user_status == o.user_status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code + def hash + [id, username, first_name, last_name, email, password, phone, user_status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :BOOLEAN + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + next if value.nil? + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/lib/petstore/version.rb b/samples/openapi3/client/petstore/ruby/lib/petstore/version.rb new file mode 100644 index 000000000000..170eb25c672c --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/lib/petstore/version.rb @@ -0,0 +1,15 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +module Petstore + VERSION = '1.0.0' +end diff --git a/samples/openapi3/client/petstore/ruby/petstore.gemspec b/samples/openapi3/client/petstore/ruby/petstore.gemspec new file mode 100644 index 000000000000..6f2cc350b429 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/petstore.gemspec @@ -0,0 +1,45 @@ +# -*- encoding: utf-8 -*- + +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.3.4-SNAPSHOT + +=end + +$:.push File.expand_path("../lib", __FILE__) +require "petstore/version" + +Gem::Specification.new do |s| + s.name = "petstore" + s.version = Petstore::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["OpenAPI-Generator"] + s.email = [""] + s.homepage = "https://openapi-generator.tech" + s.summary = "OpenAPI Petstore Ruby Gem" + s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\" + s.license = "Unlicense" + s.required_ruby_version = ">= 1.9" + + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' + + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1' + s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3' + s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6' + s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2' + s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' + s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12' + + s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } + s.test_files = `find spec/*`.split("\n") + s.executables = [] + s.require_paths = ["lib"] +end diff --git a/samples/client/petstore/ruby/petstore_profiling.output b/samples/openapi3/client/petstore/ruby/petstore_profiling.output similarity index 100% rename from samples/client/petstore/ruby/petstore_profiling.output rename to samples/openapi3/client/petstore/ruby/petstore_profiling.output diff --git a/samples/client/petstore/ruby/petstore_profiling.rb b/samples/openapi3/client/petstore/ruby/petstore_profiling.rb similarity index 100% rename from samples/client/petstore/ruby/petstore_profiling.rb rename to samples/openapi3/client/petstore/ruby/petstore_profiling.rb diff --git a/samples/client/petstore/ruby/pom.xml b/samples/openapi3/client/petstore/ruby/pom.xml similarity index 100% rename from samples/client/petstore/ruby/pom.xml rename to samples/openapi3/client/petstore/ruby/pom.xml diff --git a/samples/client/petstore/ruby/press_anykey_to_continue.sh b/samples/openapi3/client/petstore/ruby/press_anykey_to_continue.sh similarity index 100% rename from samples/client/petstore/ruby/press_anykey_to_continue.sh rename to samples/openapi3/client/petstore/ruby/press_anykey_to_continue.sh diff --git a/samples/client/petstore/ruby/spec/.spec_helper.rb b/samples/openapi3/client/petstore/ruby/spec/.spec_helper.rb similarity index 100% rename from samples/client/petstore/ruby/spec/.spec_helper.rb rename to samples/openapi3/client/petstore/ruby/spec/.spec_helper.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/api/another_fake_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/another_fake_api_spec.rb new file mode 100644 index 000000000000..269359233163 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/another_fake_api_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.3.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::AnotherFakeApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'AnotherFakeApi' do + before do + # run before each test + @instance = Petstore::AnotherFakeApi.new + end + + after do + # run after each test + end + + describe 'test an instance of AnotherFakeApi' do + it 'should create an instance of AnotherFakeApi' do + expect(@instance).to be_instance_of(Petstore::AnotherFakeApi) + end + end + + # unit tests for test_special_tags + # To test special tags + # To test special tags + # @param body client model + # @param [Hash] opts the optional parameters + # @return [Client] + describe 'test_special_tags test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/client/petstore/ruby/spec/api/default_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/default_api_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/api/default_api_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/api/default_api_spec.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/api/fake_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/fake_api_spec.rb new file mode 100644 index 000000000000..1d6acc72bfa7 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/fake_api_spec.rb @@ -0,0 +1,62 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::FakeApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'FakeApi' do + before do + # run before each test + @instance = Petstore::FakeApi.new + end + + after do + # run after each test + end + + describe 'test an instance of FakeApi' do + it 'should create an instance of FakeApi' do + expect(@instance).to be_instance_of(Petstore::FakeApi) + end + end + + # unit tests for test_endpoint_parameters + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + # @param number None + # @param double None + # @param string None + # @param byte None + # @param [Hash] opts the optional parameters + # @option opts [Integer] :integer None + # @option opts [Integer] :int32 None + # @option opts [Integer] :int64 None + # @option opts [Float] :float None + # @option opts [String] :binary None + # @option opts [Date] :date None + # @option opts [DateTime] :date_time None + # @option opts [String] :password None + # @return [nil] + describe 'test_endpoint_parameters test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb new file mode 100644 index 000000000000..581f228fb663 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/fake_classname_tags123_api_spec.rb @@ -0,0 +1,46 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::FakeClassnameTags123Api +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'FakeClassnameTags123Api' do + before do + # run before each test + @instance = Petstore::FakeClassnameTags123Api.new + end + + after do + # run after each test + end + + describe 'test an instance of FakeClassnameTags123Api' do + it 'should create an instact of FakeClassnameTags123Api' do + expect(@instance).to be_instance_of(Petstore::FakeClassnameTags123Api) + end + end + + # unit tests for test_classname + # To test class name in snake case + # + # @param body client model + # @param [Hash] opts the optional parameters + # @return [Client] + describe 'test_classname test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/api/pet_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/pet_api_spec.rb new file mode 100644 index 000000000000..75fcc384bd3a --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/pet_api_spec.rb @@ -0,0 +1,140 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::PetApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'PetApi' do + before do + # run before each test + @instance = Petstore::PetApi.new + end + + after do + # run after each test + end + + describe 'test an instance of PetApi' do + it 'should create an instance of PetApi' do + expect(@instance).to be_instance_of(Petstore::PetApi) + end + end + + # unit tests for add_pet + # Add a new pet to the store + # + # @param body Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'add_pet test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for delete_pet + # Deletes a pet + # + # @param pet_id Pet id to delete + # @param [Hash] opts the optional parameters + # @option opts [String] :api_key + # @return [nil] + describe 'delete_pet test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for find_pets_by_status + # Finds Pets by status + # Multiple status values can be provided with comma separated strings + # @param status Status values that need to be considered for filter + # @param [Hash] opts the optional parameters + # @return [Array] + describe 'find_pets_by_status test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for find_pets_by_tags + # Finds Pets by tags + # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + # @param tags Tags to filter by + # @param [Hash] opts the optional parameters + # @return [Array] + describe 'find_pets_by_tags test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for get_pet_by_id + # Find pet by ID + # Returns a single pet + # @param pet_id ID of pet to return + # @param [Hash] opts the optional parameters + # @return [Pet] + describe 'get_pet_by_id test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for update_pet + # Update an existing pet + # + # @param body Pet object that needs to be added to the store + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'update_pet test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for update_pet_with_form + # Updates a pet in the store with form data + # + # @param pet_id ID of pet that needs to be updated + # @param [Hash] opts the optional parameters + # @option opts [String] :name Updated name of the pet + # @option opts [String] :status Updated status of the pet + # @return [nil] + describe 'update_pet_with_form test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for upload_file + # uploads an image + # + # @param pet_id ID of pet to update + # @param [Hash] opts the optional parameters + # @option opts [String] :additional_metadata Additional data to pass to server + # @option opts [File] :file file to upload + # @return [ApiResponse] + describe 'upload_file test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/api/store_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/store_api_spec.rb new file mode 100644 index 000000000000..c75373a9ad62 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/store_api_spec.rb @@ -0,0 +1,86 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::StoreApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'StoreApi' do + before do + # run before each test + @instance = Petstore::StoreApi.new + end + + after do + # run after each test + end + + describe 'test an instance of StoreApi' do + it 'should create an instance of StoreApi' do + expect(@instance).to be_instance_of(Petstore::StoreApi) + end + end + + # unit tests for delete_order + # Delete purchase order by ID + # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + # @param order_id ID of the order that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'delete_order test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for get_inventory + # Returns pet inventories by status + # Returns a map of status codes to quantities + # @param [Hash] opts the optional parameters + # @return [Hash] + describe 'get_inventory test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for get_order_by_id + # Find purchase order by ID + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # @param order_id ID of pet that needs to be fetched + # @param [Hash] opts the optional parameters + # @return [Order] + describe 'get_order_by_id test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for place_order + # Place an order for a pet + # + # @param body order placed for purchasing the pet + # @param [Hash] opts the optional parameters + # @return [Order] + describe 'place_order test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/api/user_api_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api/user_api_spec.rb new file mode 100644 index 000000000000..bacd7c90c9d0 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api/user_api_spec.rb @@ -0,0 +1,136 @@ +=begin +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +License: Apache 2.0 +http://www.apache.org/licenses/LICENSE-2.0.html + +Terms of Service: http://swagger.io/terms/ + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Petstore::UserApi +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'UserApi' do + before do + # run before each test + @instance = Petstore::UserApi.new + end + + after do + # run after each test + end + + describe 'test an instance of UserApi' do + it 'should create an instance of UserApi' do + expect(@instance).to be_instance_of(Petstore::UserApi) + end + end + + # unit tests for create_user + # Create user + # This can only be done by the logged in user. + # @param body Created user object + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'create_user test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for create_users_with_array_input + # Creates list of users with given input array + # + # @param body List of user object + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'create_users_with_array_input test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for create_users_with_list_input + # Creates list of users with given input array + # + # @param body List of user object + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'create_users_with_list_input test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for delete_user + # Delete user + # This can only be done by the logged in user. + # @param username The name that needs to be deleted + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'delete_user test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for get_user_by_name + # Get user by user name + # + # @param username The name that needs to be fetched. Use user1 for testing. + # @param [Hash] opts the optional parameters + # @return [User] + describe 'get_user_by_name test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for login_user + # Logs user into the system + # + # @param username The user name for login + # @param password The password for login in clear text + # @param [Hash] opts the optional parameters + # @return [String] + describe 'login_user test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for logout_user + # Logs out current logged in user session + # + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'logout_user test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for update_user + # Updated user + # This can only be done by the logged in user. + # @param username name that need to be deleted + # @param body Updated user object + # @param [Hash] opts the optional parameters + # @return [nil] + describe 'update_user test' do + it "should work" do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/api_client_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api_client_spec.rb new file mode 100644 index 000000000000..ec2939f83933 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/api_client_spec.rb @@ -0,0 +1,277 @@ +# require 'spec_helper' +require File.dirname(__FILE__) + '/spec_helper' + +describe Petstore::ApiClient do + + context 'initialization' do + + context 'URL stuff' do + + context 'host' do + it 'removes http from host' do + Petstore.configure { |c| c.host = 'http://example.com' } + expect(Petstore::Configuration.default.host).to eq('example.com') + end + + it 'removes https from host' do + Petstore.configure { |c| c.host = 'https://wookiee.com' } + expect(Petstore::ApiClient.default.config.host).to eq('wookiee.com') + end + + it 'removes trailing path from host' do + Petstore.configure { |c| c.host = 'hobo.com/v4' } + expect(Petstore::Configuration.default.host).to eq('hobo.com') + end + end + + context 'base_path' do + it "prepends a slash to base_path" do + Petstore.configure { |c| c.base_path = 'v4/dog' } + expect(Petstore::Configuration.default.base_path).to eq('/v4/dog') + end + + it "doesn't prepend a slash if one is already there" do + Petstore.configure { |c| c.base_path = '/v4/dog' } + expect(Petstore::Configuration.default.base_path).to eq('/v4/dog') + end + + it "ends up as a blank string if nil" do + Petstore.configure { |c| c.base_path = nil } + expect(Petstore::Configuration.default.base_path).to eq('') + end + end + + end + + end + + describe "#update_params_for_auth!" do + it "sets header api-key parameter with prefix" do + Petstore.configure do |c| + c.api_key_prefix['api_key'] = 'PREFIX' + c.api_key['api_key'] = 'special-key' + end + + api_client = Petstore::ApiClient.new + + config2 = Petstore::Configuration.new do |c| + c.api_key_prefix['api_key'] = 'PREFIX2' + c.api_key['api_key'] = 'special-key2' + end + api_client2 = Petstore::ApiClient.new(config2) + + auth_names = ['api_key', 'unknown'] + + header_params = {} + query_params = {} + api_client.update_params_for_auth! header_params, query_params, auth_names + expect(header_params).to eq('api_key' => 'PREFIX special-key') + expect(query_params).to eq({}) + + header_params = {} + query_params = {} + api_client2.update_params_for_auth! header_params, query_params, auth_names + expect(header_params).to eq('api_key' => 'PREFIX2 special-key2') + expect(query_params).to eq({}) + end + + it "sets header api-key parameter without prefix" do + Petstore.configure do |c| + c.api_key_prefix['api_key'] = nil + c.api_key['api_key'] = 'special-key' + end + + api_client = Petstore::ApiClient.new + + header_params = {} + query_params = {} + auth_names = ['api_key', 'unknown'] + api_client.update_params_for_auth! header_params, query_params, auth_names + expect(header_params).to eq('api_key' => 'special-key') + expect(query_params).to eq({}) + end + end + + describe "timeout in #build_request" do + let(:config) { Petstore::Configuration.new } + let(:api_client) { Petstore::ApiClient.new(config) } + + it "defaults to 0" do + expect(Petstore::Configuration.default.timeout).to eq(0) + expect(config.timeout).to eq(0) + + request = api_client.build_request(:get, '/test') + expect(request.options[:timeout]).to eq(0) + end + + it "can be customized" do + config.timeout = 100 + request = api_client.build_request(:get, '/test') + expect(request.options[:timeout]).to eq(100) + end + end + + describe "#deserialize" do + it "handles Array" do + api_client = Petstore::ApiClient.new + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '[12, 34]') + data = api_client.deserialize(response, 'Array') + expect(data).to be_a(Array) + expect(data).to eq([12, 34]) + end + + it "handles Array>" do + api_client = Petstore::ApiClient.new + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '[[12, 34], [56]]') + data = api_client.deserialize(response, 'Array>') + expect(data).to be_a(Array) + expect(data).to eq([[12, 34], [56]]) + end + + it "handles Hash" do + api_client = Petstore::ApiClient.new + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '{"message": "Hello"}') + data = api_client.deserialize(response, 'Hash') + expect(data).to be_a(Hash) + expect(data).to eq(:message => 'Hello') + end + + it "handles Hash" do + api_client = Petstore::ApiClient.new + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '{"pet": {"id": 1}}') + data = api_client.deserialize(response, 'Hash') + expect(data).to be_a(Hash) + expect(data.keys).to eq([:pet]) + pet = data[:pet] + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(1) + end + + it "handles Hash>" do + api_client = Petstore::ApiClient.new + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}') + result = api_client.deserialize(response, 'Hash>') + expect(result).to be_a(Hash) + expect(result.keys).to eq([:data]) + data = result[:data] + expect(data).to be_a(Hash) + expect(data.keys).to eq([:pet]) + pet = data[:pet] + expect(pet).to be_a(Petstore::Pet) + expect(pet.id).to eq(1) + end + end + + describe "#object_to_hash" do + it "ignores nils and includes empty arrays" do + api_client = Petstore::ApiClient.new + pet = Petstore::Pet.new + pet.id = 1 + pet.name = '' + pet.status = nil + pet.photo_urls = nil + pet.tags = [] + expected = { id: 1, name: '', tags: [] } + expect(api_client.object_to_hash(pet)).to eq(expected) + end + end + + describe "#build_collection_param" do + let(:param) { ['aa', 'bb', 'cc'] } + let(:api_client) { Petstore::ApiClient.new } + + it "works for csv" do + expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc') + end + + it "works for ssv" do + expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc') + end + + it "works for tsv" do + expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") + end + + it "works for pipes" do + expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc') + end + + it "works for multi" do + expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) + end + + it "fails for invalid collection format" do + expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID') + end + end + + describe "#json_mime?" do + let(:api_client) { Petstore::ApiClient.new } + + it "works" do + expect(api_client.json_mime?(nil)).to eq(false) + expect(api_client.json_mime?('')).to eq(false) + + expect(api_client.json_mime?('application/json')).to eq(true) + expect(api_client.json_mime?('application/json; charset=UTF8')).to eq(true) + expect(api_client.json_mime?('APPLICATION/JSON')).to eq(true) + + expect(api_client.json_mime?('application/xml')).to eq(false) + expect(api_client.json_mime?('text/plain')).to eq(false) + expect(api_client.json_mime?('application/jsonp')).to eq(false) + end + end + + describe "#select_header_accept" do + let(:api_client) { Petstore::ApiClient.new } + + it "works" do + expect(api_client.select_header_accept(nil)).to eq(nil) + expect(api_client.select_header_accept([])).to eq(nil) + + expect(api_client.select_header_accept(['application/json'])).to eq('application/json') + expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') + expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') + + expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml') + expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml') + end + end + + describe "#select_header_content_type" do + let(:api_client) { Petstore::ApiClient.new } + + it "works" do + expect(api_client.select_header_content_type(nil)).to eq('application/json') + expect(api_client.select_header_content_type([])).to eq('application/json') + + expect(api_client.select_header_content_type(['application/json'])).to eq('application/json') + expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') + expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') + expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml') + expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain') + end + end + + describe "#sanitize_filename" do + let(:api_client) { Petstore::ApiClient.new } + + it "works" do + expect(api_client.sanitize_filename('sun')).to eq('sun') + expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif') + expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif') + end + end + +end diff --git a/samples/client/petstore/ruby/spec/api_error_spec.rb b/samples/openapi3/client/petstore/ruby/spec/api_error_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/api_error_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/api_error_spec.rb diff --git a/samples/client/petstore/ruby/spec/base_object_spec.rb b/samples/openapi3/client/petstore/ruby/spec/base_object_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/base_object_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/base_object_spec.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/configuration_spec.rb b/samples/openapi3/client/petstore/ruby/spec/configuration_spec.rb new file mode 100644 index 000000000000..e666b7bc0043 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/configuration_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe Petstore::Configuration do + let(:config) { Petstore::Configuration.default } + + before(:each) do + Petstore.configure do |c| + c.host = 'petstore.swagger.io' + c.base_path = 'v2' + end + end + + describe '#base_url' do + it 'should have the default value' do + expect(config.base_url).to eq('http://petstore.swagger.io/v2') + end + + it 'should remove trailing slashes' do + [nil, '', '/', '//'].each do |base_path| + config.base_path = base_path + expect(config.base_url).to eq('http://petstore.swagger.io') + end + end + end + + describe 'server settings' do + it 'should return an array of server settings' do + expect(config.auth_settings).not_to be_empty + end + + it 'should get the first url' do + url = config.server_url(0, server: "dev-petstore", port: "8080") + expect(url).to eq("http://dev-petstore.swagger.io:8080/v2") + end + + it 'should get the first url with default values' do + url = config.server_url(0) + expect(url).to eq("http://petstore.swagger.io:80/v2") + end + + it 'should get the second url with default values' do + url = config.server_url(1) + expect(url).to eq("https://localhost:8080/v2") + end + + it 'should get the second url' do + url = config.server_url(1, version: "v1") + expect(url).to eq("https://localhost:8080/v1") + end + + it 'should raise error due to invalid enum value' do + expect{config.server_url(1, version: "v6")}.to raise_error(ArgumentError) + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/additional_properties_class_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/additional_properties_class_spec.rb new file mode 100644 index 000000000000..0e4c8bec34b4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/additional_properties_class_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::AdditionalPropertiesClass +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'AdditionalPropertiesClass' do + before do + # run before each test + @instance = Petstore::AdditionalPropertiesClass.new + end + + after do + # run after each test + end + + describe 'test an instance of AdditionalPropertiesClass' do + it 'should create an instance of AdditionalPropertiesClass' do + expect(@instance).to be_instance_of(Petstore::AdditionalPropertiesClass) + end + end + describe 'test attribute "map_property"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "map_of_map_property"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/animal_farm_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/animal_farm_spec.rb new file mode 100644 index 000000000000..895781828d2f --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/animal_farm_spec.rb @@ -0,0 +1,35 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::AnimalFarm +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'AnimalFarm' do + before do + # run before each test + @instance = Petstore::AnimalFarm.new + end + + after do + # run after each test + end + + describe 'test an instance of AnimalFarm' do + it 'should create an instance of AnimalFarm' do + expect(@instance).to be_instance_of(Petstore::AnimalFarm) + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/animal_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/animal_spec.rb new file mode 100644 index 000000000000..6b77f9af7286 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/animal_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Animal +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Animal' do + before do + # run before each test + @instance = Petstore::Animal.new + end + + after do + # run after each test + end + + describe 'test an instance of Animal' do + it 'should create an instance of Animal' do + expect(@instance).to be_instance_of(Petstore::Animal) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/api_response_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/api_response_spec.rb new file mode 100644 index 000000000000..52b8420ad71b --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/api_response_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ApiResponse +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ApiResponse' do + before do + # run before each test + @instance = Petstore::ApiResponse.new + end + + after do + # run after each test + end + + describe 'test an instance of ApiResponse' do + it 'should create an instance of ApiResponse' do + expect(@instance).to be_instance_of(Petstore::ApiResponse) + end + end + describe 'test attribute "code"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "type"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "message"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb new file mode 100644 index 000000000000..35bad7d85970 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/array_of_array_of_number_only_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ArrayOfArrayOfNumberOnly +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ArrayOfArrayOfNumberOnly' do + before do + # run before each test + @instance = Petstore::ArrayOfArrayOfNumberOnly.new + end + + after do + # run after each test + end + + describe 'test an instance of ArrayOfArrayOfNumberOnly' do + it 'should create an instance of ArrayOfArrayOfNumberOnly' do + expect(@instance).to be_instance_of(Petstore::ArrayOfArrayOfNumberOnly) + end + end + describe 'test attribute "array_array_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/array_of_number_only_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/array_of_number_only_spec.rb new file mode 100644 index 000000000000..84d4104b8006 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/array_of_number_only_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ArrayOfNumberOnly +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ArrayOfNumberOnly' do + before do + # run before each test + @instance = Petstore::ArrayOfNumberOnly.new + end + + after do + # run after each test + end + + describe 'test an instance of ArrayOfNumberOnly' do + it 'should create an instance of ArrayOfNumberOnly' do + expect(@instance).to be_instance_of(Petstore::ArrayOfNumberOnly) + end + end + describe 'test attribute "array_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/array_test_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/array_test_spec.rb new file mode 100644 index 000000000000..a6a5fb998a9b --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/array_test_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ArrayTest +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ArrayTest' do + before do + # run before each test + @instance = Petstore::ArrayTest.new + end + + after do + # run after each test + end + + describe 'test an instance of ArrayTest' do + it 'should create an instance of ArrayTest' do + expect(@instance).to be_instance_of(Petstore::ArrayTest) + end + end + describe 'test attribute "array_of_string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "array_array_of_integer"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "array_array_of_model"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/capitalization_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/capitalization_spec.rb new file mode 100644 index 000000000000..bcaa85523bc6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/capitalization_spec.rb @@ -0,0 +1,71 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Capitalization +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Capitalization' do + before do + # run before each test + @instance = Petstore::Capitalization.new + end + + after do + # run after each test + end + + describe 'test an instance of Capitalization' do + it 'should create an instance of Capitalization' do + expect(@instance).to be_instance_of(Petstore::Capitalization) + end + end + describe 'test attribute "small_camel"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "capital_camel"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "small_snake"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "capital_snake"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "sca_eth_flow_points"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "att_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/cat_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/cat_spec.rb new file mode 100644 index 000000000000..d01ff50499ad --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/cat_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Cat +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Cat' do + before do + # run before each test + @instance = Petstore::Cat.new + end + + after do + # run after each test + end + + describe 'test an instance of Cat' do + it 'should create an instance of Cat' do + expect(@instance).to be_instance_of(Petstore::Cat) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "declawed"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/category_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/category_spec.rb new file mode 100644 index 000000000000..ab8adb3fdae6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/category_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Category +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Category' do + before do + # run before each test + @instance = Petstore::Category.new + end + + after do + # run after each test + end + + describe 'test an instance of Category' do + it 'should create an instance of Category' do + expect(@instance).to be_instance_of(Petstore::Category) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/class_model_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/class_model_spec.rb new file mode 100644 index 000000000000..6e5998b54c23 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/class_model_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ClassModel +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ClassModel' do + before do + # run before each test + @instance = Petstore::ClassModel.new + end + + after do + # run after each test + end + + describe 'test an instance of ClassModel' do + it 'should create an instance of ClassModel' do + expect(@instance).to be_instance_of(Petstore::ClassModel) + end + end + describe 'test attribute "_class"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/client_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/client_spec.rb new file mode 100644 index 000000000000..5d5766906338 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/client_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Client +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Client' do + before do + # run before each test + @instance = Petstore::Client.new + end + + after do + # run after each test + end + + describe 'test an instance of Client' do + it 'should create an instance of Client' do + expect(@instance).to be_instance_of(Petstore::Client) + end + end + describe 'test attribute "client"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/dog_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/dog_spec.rb new file mode 100644 index 000000000000..32acf1084db4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/dog_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Dog +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Dog' do + before do + # run before each test + @instance = Petstore::Dog.new + end + + after do + # run after each test + end + + describe 'test an instance of Dog' do + it 'should create an instance of Dog' do + expect(@instance).to be_instance_of(Petstore::Dog) + end + end + describe 'test attribute "class_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "color"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "breed"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/enum_arrays_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/enum_arrays_spec.rb new file mode 100644 index 000000000000..17ac2e5e37f5 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/enum_arrays_spec.rb @@ -0,0 +1,55 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::EnumArrays +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'EnumArrays' do + before do + # run before each test + @instance = Petstore::EnumArrays.new + end + + after do + # run after each test + end + + describe 'test an instance of EnumArrays' do + it 'should create an instance of EnumArrays' do + expect(@instance).to be_instance_of(Petstore::EnumArrays) + end + end + describe 'test attribute "just_symbol"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', [">=", "$"]) + # validator.allowable_values.each do |value| + # expect { @instance.just_symbol = value }.not_to raise_error + # end + end + end + + describe 'test attribute "array_enum"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('Array', ["fish", "crab"]) + # validator.allowable_values.each do |value| + # expect { @instance.array_enum = value }.not_to raise_error + # end + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/enum_class_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/enum_class_spec.rb new file mode 100644 index 000000000000..3c4caca91762 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/enum_class_spec.rb @@ -0,0 +1,35 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::EnumClass +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'EnumClass' do + before do + # run before each test + @instance = Petstore::EnumClass.new + end + + after do + # run after each test + end + + describe 'test an instance of EnumClass' do + it 'should create an instance of EnumClass' do + expect(@instance).to be_instance_of(Petstore::EnumClass) + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/enum_test_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/enum_test_spec.rb new file mode 100644 index 000000000000..6b4b966a6a53 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/enum_test_spec.rb @@ -0,0 +1,81 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::EnumTest +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'EnumTest' do + before do + # run before each test + @instance = Petstore::EnumTest.new + end + + after do + # run after each test + end + + describe 'test an instance of EnumTest' do + it 'should create an instance of EnumTest' do + expect(@instance).to be_instance_of(Petstore::EnumTest) + end + end + describe 'test attribute "enum_string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["UPPER", "lower", ""]) + # validator.allowable_values.each do |value| + # expect { @instance.enum_string = value }.not_to raise_error + # end + end + end + + describe 'test attribute "enum_string_required"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["UPPER", "lower", ""]) + # validator.allowable_values.each do |value| + # expect { @instance.enum_string_required = value }.not_to raise_error + # end + end + end + + describe 'test attribute "enum_integer"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('Integer', ["1", "-1"]) + # validator.allowable_values.each do |value| + # expect { @instance.enum_integer = value }.not_to raise_error + # end + end + end + + describe 'test attribute "enum_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) + # validator.allowable_values.each do |value| + # expect { @instance.enum_number = value }.not_to raise_error + # end + end + end + + describe 'test attribute "outer_enum"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb new file mode 100644 index 000000000000..4b6fad6e76ee --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/file_schema_test_class_spec.rb @@ -0,0 +1,47 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.1.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::FileSchemaTestClass +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'FileSchemaTestClass' do + before do + # run before each test + @instance = Petstore::FileSchemaTestClass.new + end + + after do + # run after each test + end + + describe 'test an instance of FileSchemaTestClass' do + it 'should create an instance of FileSchemaTestClass' do + expect(@instance).to be_instance_of(Petstore::FileSchemaTestClass) + end + end + describe 'test attribute "file"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "files"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/file_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/file_spec.rb new file mode 100644 index 000000000000..50a9f28078f4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/file_spec.rb @@ -0,0 +1,41 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.1.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::File +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'File' do + before do + # run before each test + @instance = Petstore::File.new + end + + after do + # run after each test + end + + describe 'test an instance of File' do + it 'should create an instance of File' do + expect(@instance).to be_instance_of(Petstore::File) + end + end + describe 'test attribute "source_uri"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/client/petstore/ruby/spec/models/foo_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/foo_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/foo_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/models/foo_spec.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/models/format_test_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/format_test_spec.rb new file mode 100644 index 000000000000..74f4fe9bedd7 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/format_test_spec.rb @@ -0,0 +1,140 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::FormatTest +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'FormatTest' do + before do + # run before each test + @instance = Petstore::FormatTest.new + end + + after do + # run after each test + end + + describe 'test an instance of FormatTest' do + it 'should create an instance of FormatTest' do + expect(@instance).to be_instance_of(Petstore::FormatTest) + end + end + describe 'test attribute "integer"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "int32"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "int64"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "float"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "double"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "byte"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "binary"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "date"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "date_time"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "uuid"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "password"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "pattern_with_digits"' do + it 'should accept string "1234567890"' do + @instance.pattern_with_digits = '1234567890' + end + + it 'should accept string with leading zero "0123456789"' do + @instance.pattern_with_digits = '0123456789' + end + + it 'should reject string with non digits "ABC3456789"' do + expect {@instance.pattern_with_digits = 'ABC3456789'}.to raise_error(ArgumentError) + end + + it 'should reject string less than 10 in length "123456789"' do + expect {@instance.pattern_with_digits = '123456789'}.to raise_error(ArgumentError) + end + + it 'should reject string more than 10 in length "0123456789123"' do + expect {@instance.pattern_with_digits = '0123456789123'}.to raise_error(ArgumentError) + end + end + + describe 'test attribute "pattern_with_digits_and_delimiter"' do + it 'should accept string "Image_01"' do + @instance.pattern_with_digits_and_delimiter = 'Image_01' + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/has_only_read_only_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/has_only_read_only_spec.rb new file mode 100644 index 000000000000..9d84c9a07cd0 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/has_only_read_only_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::HasOnlyReadOnly +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'HasOnlyReadOnly' do + before do + # run before each test + @instance = Petstore::HasOnlyReadOnly.new + end + + after do + # run after each test + end + + describe 'test an instance of HasOnlyReadOnly' do + it 'should create an instance of HasOnlyReadOnly' do + expect(@instance).to be_instance_of(Petstore::HasOnlyReadOnly) + end + end + describe 'test attribute "bar"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "foo"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/client/petstore/ruby/spec/models/inline_response_default_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/inline_response_default_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/models/inline_response_default_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/models/inline_response_default_spec.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/models/list_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/list_spec.rb new file mode 100644 index 000000000000..68bb5ae294d6 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/list_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::List +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'List' do + before do + # run before each test + @instance = Petstore::List.new + end + + after do + # run after each test + end + + describe 'test an instance of List' do + it 'should create an instance of List' do + expect(@instance).to be_instance_of(Petstore::List) + end + end + describe 'test attribute "_123_list"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/map_test_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/map_test_spec.rb new file mode 100644 index 000000000000..1735496e090f --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/map_test_spec.rb @@ -0,0 +1,51 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::MapTest +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'MapTest' do + before do + # run before each test + @instance = Petstore::MapTest.new + end + + after do + # run after each test + end + + describe 'test an instance of MapTest' do + it 'should create an instance of MapTest' do + expect(@instance).to be_instance_of(Petstore::MapTest) + end + end + describe 'test attribute "map_map_of_string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "map_of_enum_string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('Hash', ["UPPER", "lower"]) + # validator.allowable_values.each do |value| + # expect { @instance.map_of_enum_string = value }.not_to raise_error + # end + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb new file mode 100644 index 000000000000..510fc0825fac --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/mixed_properties_and_additional_properties_class_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::MixedPropertiesAndAdditionalPropertiesClass +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'MixedPropertiesAndAdditionalPropertiesClass' do + before do + # run before each test + @instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new + end + + after do + # run after each test + end + + describe 'test an instance of MixedPropertiesAndAdditionalPropertiesClass' do + it 'should create an instance of MixedPropertiesAndAdditionalPropertiesClass' do + expect(@instance).to be_instance_of(Petstore::MixedPropertiesAndAdditionalPropertiesClass) + end + end + describe 'test attribute "uuid"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "date_time"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "map"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/model200_response_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/model200_response_spec.rb new file mode 100644 index 000000000000..0a72f1cd7a51 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/model200_response_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Model200Response +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Model200Response' do + before do + # run before each test + @instance = Petstore::Model200Response.new + end + + after do + # run after each test + end + + describe 'test an instance of Model200Response' do + it 'should create an instance of Model200Response' do + expect(@instance).to be_instance_of(Petstore::Model200Response) + end + end + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "_class"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/model_return_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/model_return_spec.rb new file mode 100644 index 000000000000..9f0cce65e397 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/model_return_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ModelReturn +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ModelReturn' do + before do + # run before each test + @instance = Petstore::ModelReturn.new + end + + after do + # run after each test + end + + describe 'test an instance of ModelReturn' do + it 'should create an instance of ModelReturn' do + expect(@instance).to be_instance_of(Petstore::ModelReturn) + end + end + describe 'test attribute "_return"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/name_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/name_spec.rb new file mode 100644 index 000000000000..c39527e14b26 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/name_spec.rb @@ -0,0 +1,59 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Name +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Name' do + before do + # run before each test + @instance = Petstore::Name.new + end + + after do + # run after each test + end + + describe 'test an instance of Name' do + it 'should create an instance of Name' do + expect(@instance).to be_instance_of(Petstore::Name) + end + end + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "snake_case"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "property"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "_123_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/number_only_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/number_only_spec.rb new file mode 100644 index 000000000000..6aeeb6ca3271 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/number_only_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::NumberOnly +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'NumberOnly' do + before do + # run before each test + @instance = Petstore::NumberOnly.new + end + + after do + # run after each test + end + + describe 'test an instance of NumberOnly' do + it 'should create an instance of NumberOnly' do + expect(@instance).to be_instance_of(Petstore::NumberOnly) + end + end + describe 'test attribute "just_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/order_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/order_spec.rb new file mode 100644 index 000000000000..8f81f7a766e5 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/order_spec.rb @@ -0,0 +1,75 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Order +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Order' do + before do + # run before each test + @instance = Petstore::Order.new + end + + after do + # run after each test + end + + describe 'test an instance of Order' do + it 'should create an instance of Order' do + expect(@instance).to be_instance_of(Petstore::Order) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "pet_id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "quantity"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "ship_date"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "status"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) + # validator.allowable_values.each do |value| + # expect { @instance.status = value }.not_to raise_error + # end + end + end + + describe 'test attribute "complete"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/outer_composite_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/outer_composite_spec.rb new file mode 100644 index 000000000000..d5dce679bcf4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/outer_composite_spec.rb @@ -0,0 +1,53 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::OuterComposite +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'OuterComposite' do + before do + # run before each test + @instance = Petstore::OuterComposite.new + end + + after do + # run after each test + end + + describe 'test an instance of OuterComposite' do + it 'should create an instance of OuterComposite' do + expect(@instance).to be_instance_of(Petstore::OuterComposite) + end + end + describe 'test attribute "my_number"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "my_string"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "my_boolean"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/outer_enum_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/outer_enum_spec.rb new file mode 100644 index 000000000000..08f34bc4080c --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/outer_enum_spec.rb @@ -0,0 +1,35 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::OuterEnum +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'OuterEnum' do + before do + # run before each test + @instance = Petstore::OuterEnum.new + end + + after do + # run after each test + end + + describe 'test an instance of OuterEnum' do + it 'should create an instance of OuterEnum' do + expect(@instance).to be_instance_of(Petstore::OuterEnum) + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/pet_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/pet_spec.rb new file mode 100644 index 000000000000..9f7beebffe64 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/pet_spec.rb @@ -0,0 +1,75 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Pet +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Pet' do + before do + # run before each test + @instance = Petstore::Pet.new + end + + after do + # run after each test + end + + describe 'test an instance of Pet' do + it 'should create an instance of Pet' do + expect(@instance).to be_instance_of(Petstore::Pet) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "category"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "photo_urls"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "tags"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "status"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["available", "pending", "sold"]) + # validator.allowable_values.each do |value| + # expect { @instance.status = value }.not_to raise_error + # end + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/read_only_first_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/read_only_first_spec.rb new file mode 100644 index 000000000000..d3c18880b6fc --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/read_only_first_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::ReadOnlyFirst +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'ReadOnlyFirst' do + before do + # run before each test + @instance = Petstore::ReadOnlyFirst.new + end + + after do + # run after each test + end + + describe 'test an instance of ReadOnlyFirst' do + it 'should create an instance of ReadOnlyFirst' do + expect(@instance).to be_instance_of(Petstore::ReadOnlyFirst) + end + end + describe 'test attribute "bar"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "baz"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/special_model_name_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/special_model_name_spec.rb new file mode 100644 index 000000000000..10ae62410016 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/special_model_name_spec.rb @@ -0,0 +1,41 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::SpecialModelName +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'SpecialModelName' do + before do + # run before each test + @instance = Petstore::SpecialModelName.new + end + + after do + # run after each test + end + + describe 'test an instance of SpecialModelName' do + it 'should create an instance of SpecialModelName' do + expect(@instance).to be_instance_of(Petstore::SpecialModelName) + end + end + describe 'test attribute "special_property_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/string_boolean_map_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/string_boolean_map_spec.rb new file mode 100644 index 000000000000..3f54837a62a4 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/string_boolean_map_spec.rb @@ -0,0 +1,35 @@ +=begin +#OpenAPI Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 + +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 3.0.3-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::StringBooleanMap +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'StringBooleanMap' do + before do + # run before each test + @instance = Petstore::StringBooleanMap.new + end + + after do + # run after each test + end + + describe 'test an instance of StringBooleanMap' do + it 'should create an instance of StringBooleanMap' do + expect(@instance).to be_instance_of(Petstore::StringBooleanMap) + end + end +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/tag_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/tag_spec.rb new file mode 100644 index 000000000000..f8f824471ff9 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/tag_spec.rb @@ -0,0 +1,47 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::Tag +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'Tag' do + before do + # run before each test + @instance = Petstore::Tag.new + end + + after do + # run after each test + end + + describe 'test an instance of Tag' do + it 'should create an instance of Tag' do + expect(@instance).to be_instance_of(Petstore::Tag) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/openapi3/client/petstore/ruby/spec/models/user_spec.rb b/samples/openapi3/client/petstore/ruby/spec/models/user_spec.rb new file mode 100644 index 000000000000..c47ad3967d51 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/models/user_spec.rb @@ -0,0 +1,83 @@ +=begin +#Swagger Petstore + +#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 3.0.0-SNAPSHOT + +=end + +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Petstore::User +# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) +# Please update as you see appropriate +describe 'User' do + before do + # run before each test + @instance = Petstore::User.new + end + + after do + # run after each test + end + + describe 'test an instance of User' do + it 'should create an instance of User' do + expect(@instance).to be_instance_of(Petstore::User) + end + end + describe 'test attribute "id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "username"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "first_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "last_name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "email"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "password"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "phone"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "user_status"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/samples/client/petstore/ruby/spec/pet_spec.rb b/samples/openapi3/client/petstore/ruby/spec/pet_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/pet_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/pet_spec.rb diff --git a/samples/openapi3/client/petstore/ruby/spec/spec_helper.rb b/samples/openapi3/client/petstore/ruby/spec/spec_helper.rb new file mode 100644 index 000000000000..953ff788a870 --- /dev/null +++ b/samples/openapi3/client/petstore/ruby/spec/spec_helper.rb @@ -0,0 +1,147 @@ +# load the gem +require 'petstore' + +# The following was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end + +# API client (shared between all the test cases) +API_CLIENT = Petstore::ApiClient.new(Petstore::Configuration.new) + +# randomly generate an ID +def random_id + rand(1000000) + 20000 +end + +# create a random pet, return its id +def prepare_pet(pet_api) + pet_id = random_id + category = Petstore::Category.new('id' => 20002, 'name' => 'category test') + tag = Petstore::Tag.new('id' => 30002, 'name' => 'tag test') + pet = Petstore::Pet.new('id' => pet_id, 'name' => "RUBY UNIT TESTING", 'photo_urls' => 'photo url', + 'category' => category, 'tags' => [tag], 'status' => 'pending') + pet_api.add_pet(pet) + pet_id +end + +# create a random order, return its id +def prepare_store(store_api) + order_id = 5 + order = Petstore::Order.new("id" => order_id, + "petId" => 123, + "quantity" => 789, + "shipDate" => "2015-04-06T23:42:01.678Z", + "status" => "placed", + "complete" => false) + store_api.place_order(order) + order_id +end + +# A random string to tack onto stuff to ensure we're not seeing +# data from a previous test run +RAND = ("a".."z").to_a.sample(8).join + +# helper method to serialize object to json string +def serialize_json(o) + API_CLIENT.object_to_http_body(o) +end + +# helper method to deserialize json string back to object +def deserialize_json(s, type) + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: s) + API_CLIENT.deserialize(response, type) +end diff --git a/samples/client/petstore/ruby/spec/store_spec.rb b/samples/openapi3/client/petstore/ruby/spec/store_spec.rb similarity index 100% rename from samples/client/petstore/ruby/spec/store_spec.rb rename to samples/openapi3/client/petstore/ruby/spec/store_spec.rb From 363b095721bd5a4744d6201e5d5bf81780d265d0 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 19 Nov 2018 20:55:29 +0800 Subject: [PATCH 04/14] better warning, default value (#1492) --- .../languages/JavascriptClientCodegen.java | 27 ++++++++++++------- .../codegen/utils/URLPathUtils.java | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java index 4f85b35eeaa2..e83f651ac03f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java @@ -297,7 +297,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo } if (projectDescription == null) { // when projectDescription is not specified, use info.description - projectDescription = sanitizeName(info.getDescription()); + if (StringUtils.isEmpty(info.getDescription())) { + projectDescription = "JS API client generated by OpenAPI Generator"; + } else { + projectDescription = sanitizeName(info.getDescription()); + } } // when licenceName is not specified, use info.license @@ -506,13 +510,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo private String getNameUsingModelPropertyNaming(String name) { switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) { - case original: return name; - case camelCase: return org.openapitools.codegen.utils.StringUtils.camelize(name, true); - case PascalCase: return org.openapitools.codegen.utils.StringUtils.camelize(name); - case snake_case: return org.openapitools.codegen.utils.StringUtils.underscore(name); - default: throw new IllegalArgumentException("Invalid model property naming '" + - name + "'. Must be 'original', 'camelCase', " + - "'PascalCase' or 'snake_case'"); + case original: + return name; + case camelCase: + return org.openapitools.codegen.utils.StringUtils.camelize(name, true); + case PascalCase: + return org.openapitools.codegen.utils.StringUtils.camelize(name); + case snake_case: + return org.openapitools.codegen.utils.StringUtils.underscore(name); + default: + throw new IllegalArgumentException("Invalid model property naming '" + + name + "'. Must be 'original', 'camelCase', " + + "'PascalCase' or 'snake_case'"); } } @@ -871,7 +880,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo codegenModel.getVendorExtensions().put("x-itemType", getSchemaType(ModelUtils.getAdditionalProperties(model))); } else { String type = model.getType(); - if (isPrimitiveType(type)){ + if (isPrimitiveType(type)) { codegenModel.vendorExtensions.put("x-isPrimitive", true); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java index 26030abbe1b2..53a14a07c9f9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java @@ -179,7 +179,7 @@ public class URLPathUtils { LOGGER.warn("'scheme' not defined in the spec (2.0). Default to [http] for server URL [{}]", url); } else if (url.startsWith("/")) { url = LOCAL_HOST + url; - LOGGER.warn("'host' not defined in the spec (2.0). Default to [{}] for server URL [{}]", LOCAL_HOST, url); + LOGGER.warn("'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [{}] for server URL [{}]", LOCAL_HOST, url); } else if (!url.matches("[a-zA-Z][0-9a-zA-Z.+\\-]+://.+")) { // Add http scheme for urls without a scheme. // 2.0 spec is restricted to the following schemes: "http", "https", "ws", "wss" From 2b58f6737a558403e2e527eac7dd813e41022af1 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 19 Nov 2018 21:14:03 +0800 Subject: [PATCH 05/14] fix typo in java client docstring (#1494) --- .../resources/Java/libraries/okhttp-gson/ApiClient.mustache | 2 +- .../src/main/java/org/openapitools/client/ApiClient.java | 2 +- .../src/main/java/org/openapitools/client/ApiClient.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index f3639393cc2d..d2d99dd4477f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -145,7 +145,7 @@ public class ApiClient { /** * Get base path * - * @return Baes path + * @return Base path */ public String getBasePath() { return basePath; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java index 12630634b3fc..34eddcf2f997 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java @@ -141,7 +141,7 @@ public class ApiClient { /** * Get base path * - * @return Baes path + * @return Base path */ public String getBasePath() { return basePath; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index 12630634b3fc..34eddcf2f997 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -141,7 +141,7 @@ public class ApiClient { /** * Get base path * - * @return Baes path + * @return Base path */ public String getBasePath() { return basePath; From 792f95eb09760a696d7490405fdc4ff33162069e Mon Sep 17 00:00:00 2001 From: Alwin Garside Date: Tue, 20 Nov 2018 02:30:14 +0100 Subject: [PATCH 06/14] [PHP] Use appDescription in composer.mustache (#1485) * Use appDescription in composer.mustache * Update petstore files * More updated php petstore files * Yet another updated php petstore file * Use "{{{appDescription}}}" instead of "{{appDescription}}" --- .../src/main/resources/php/composer.mustache | 2 +- .../.openapi-generator/VERSION | 2 +- .../php/OpenAPIClient-php/composer.json | 2 +- .../php/OpenAPIClient-php/lib/Api/FakeApi.php | 10 +++--- .../OpenAPIClient-php/lib/ApiException.php | 2 +- .../OpenAPIClient-php/lib/Configuration.php | 2 +- .../OpenAPIClient-php/lib/HeaderSelector.php | 2 +- .../lib/Model/ModelInterface.php | 2 +- .../lib/Model/ModelReturn.php | 2 +- .../lib/ObjectSerializer.php | 34 ++++++++++++------- .../php/OpenAPIClient-php/composer.json | 2 +- .../php/OpenAPIClient-php/composer.json | 2 +- 12 files changed, 36 insertions(+), 28 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php/composer.mustache b/modules/openapi-generator/src/main/resources/php/composer.mustache index e4860c99bf18..6d50eb9718c1 100644 --- a/modules/openapi-generator/src/main/resources/php/composer.mustache +++ b/modules/openapi-generator/src/main/resources/php/composer.mustache @@ -3,7 +3,7 @@ {{#artifactVersion}} "version": "{{artifactVersion}}", {{/artifactVersion}} - "description": "{{description}}", + "description": "{{{appDescription}}}", "keywords": [ "openapitools", "openapi-generator", diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION b/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION index 6d94c9c2e12a..d077ffb477a4 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.0-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json b/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json index 45b3c6972619..88a8bcd6ed9a 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/composer.json @@ -1,6 +1,6 @@ { "name": "GIT_USER_ID/GIT_REPO_ID", - "description": "", + "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --", "keywords": [ "openapitools", "openapi-generator", diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php index b8df0f363deb..d210ab40797d 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** @@ -253,10 +253,10 @@ class FakeApi // for model (json/xml) if (isset($_tempBody)) { // $_tempBody is the method argument, if present - $httpBody = $_tempBody; - // \stdClass has no __toString(), so we should encode it manually - if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') { - $httpBody = \GuzzleHttp\json_encode($httpBody); + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; } } elseif (count($formParams) > 0) { if ($multipart) { diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php index 516981727ba1..85d35f836307 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ApiException.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php index 38464086bf4e..efcacba885d0 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Configuration.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php index 0a183e1a9ceb..a08d9d4a0e5e 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/HeaderSelector.php @@ -17,7 +17,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php index 2970c2b72c03..4b4c74497065 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelInterface.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php index 97a18252d864..ada5d2e21549 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/Model/ModelReturn.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** diff --git a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php index f2142a2e86e5..c7da9e2f345b 100644 --- a/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore-security-test/php/OpenAPIClient-php/lib/ObjectSerializer.php @@ -18,7 +18,7 @@ * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r * Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 3.3.0-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT */ /** @@ -29,6 +29,8 @@ namespace OpenAPI\Client; +use OpenAPI\Client\Model\ModelInterface; + /** * ObjectSerializer Class Doc Comment * @@ -61,19 +63,25 @@ class ObjectSerializer return $data; } elseif (is_object($data)) { $values = []; - $formats = $data::openAPIFormats(); - foreach ($data::openAPITypes() as $property => $openAPIType) { - $getter = $data::getters()[$property]; - $value = $data->$getter(); - if ($value !== null - && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) - && method_exists($openAPIType, 'getAllowableEnumValues') - && !in_array($value, $openAPIType::getAllowableEnumValues(), true)) { - $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); - throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + if ($data instanceof ModelInterface) { + $formats = $data::openAPIFormats(); + foreach ($data::openAPITypes() as $property => $openAPIType) { + $getter = $data::getters()[$property]; + $value = $data->$getter(); + if ($value !== null + && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true) + && method_exists($openAPIType, 'getAllowableEnumValues') + && !in_array($value, $openAPIType::getAllowableEnumValues(), true)) { + $imploded = implode("', '", $openAPIType::getAllowableEnumValues()); + throw new \InvalidArgumentException("Invalid value for enum '$openAPIType', must be one of: '$imploded'"); + } + if ($value !== null) { + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } } - if ($value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + } else { + foreach($data as $property => $value) { + $values[$property] = self::sanitizeForSerialization($value); } } return (object)$values; diff --git a/samples/client/petstore/php/OpenAPIClient-php/composer.json b/samples/client/petstore/php/OpenAPIClient-php/composer.json index 45b3c6972619..7b70070c5560 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/composer.json +++ b/samples/client/petstore/php/OpenAPIClient-php/composer.json @@ -1,6 +1,6 @@ { "name": "GIT_USER_ID/GIT_REPO_ID", - "description": "", + "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\", "keywords": [ "openapitools", "openapi-generator", diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json b/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json index 45b3c6972619..7b70070c5560 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/composer.json @@ -1,6 +1,6 @@ { "name": "GIT_USER_ID/GIT_REPO_ID", - "description": "", + "description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\", "keywords": [ "openapitools", "openapi-generator", From 9be5b9926694f929c450040312d7b90fde625b0d Mon Sep 17 00:00:00 2001 From: Jon Schoning Date: Thu, 8 Nov 2018 15:47:47 -0600 Subject: [PATCH 07/14] [haskell-http-client] fix typename generation bug for array params; update deps - fix build for example-app + tests-integration in Samples (due to change in Category) - upgrade stack to 12.18 - fix typename generation bug for array params --- .../codegen/languages/HaskellHttpClientCodegen.java | 2 +- .../src/main/resources/haskell-http-client/stack.mustache | 4 ++-- .../client/petstore/haskell-http-client/example-app/Main.hs | 2 +- samples/client/petstore/haskell-http-client/stack.yaml | 4 ++-- .../haskell-http-client/tests-integration/tests/Test.hs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 07fc3c52e00f..ed410e8ddf53 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -891,7 +891,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC if (appendDataType && uniqueParamNameTypes.containsKey(paramNameType) && !isDuplicate(paramNameType, dataType)) { - paramNameType = paramNameType + dataType; + paramNameType = toTypeName("", paramNameType + dataType); } while (typeNames.contains(paramNameType)) { diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/stack.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/stack.mustache index f396d4a2a89a..c5f97455ec7f 100644 --- a/modules/openapi-generator/src/main/resources/haskell-http-client/stack.mustache +++ b/modules/openapi-generator/src/main/resources/haskell-http-client/stack.mustache @@ -1,8 +1,8 @@ -resolver: lts-10.10 +resolver: lts-12.18 build: haddock-arguments: haddock-args: - "--odir=./docs" -extra-deps: [] +extra-deps: [ {{^x-useMonadLogger}}katip-0.5.5.1{{/x-useMonadLogger}} ] packages: - '.' diff --git a/samples/client/petstore/haskell-http-client/example-app/Main.hs b/samples/client/petstore/haskell-http-client/example-app/Main.hs index fa86cbbbe173..55b068c2b483 100644 --- a/samples/client/petstore/haskell-http-client/example-app/Main.hs +++ b/samples/client/petstore/haskell-http-client/example-app/Main.hs @@ -118,7 +118,7 @@ runPet mgr config = do -- updatePet let updatePetRequest = S.updatePet (S.ContentType S.MimeJSON) $ pet { S.petStatus = Just S.E'Status2'Available - , S.petCategory = Just (S.Category (Just 3) (Just "catname")) + , S.petCategory = Just (S.Category (Just 3) "catname") } _ <- S.dispatchLbs mgr config updatePetRequest diff --git a/samples/client/petstore/haskell-http-client/stack.yaml b/samples/client/petstore/haskell-http-client/stack.yaml index f396d4a2a89a..d115cc3c3c2c 100644 --- a/samples/client/petstore/haskell-http-client/stack.yaml +++ b/samples/client/petstore/haskell-http-client/stack.yaml @@ -1,8 +1,8 @@ -resolver: lts-10.10 +resolver: lts-12.18 build: haddock-arguments: haddock-args: - "--odir=./docs" -extra-deps: [] +extra-deps: [ katip-0.5.5.1 ] packages: - '.' diff --git a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs index fa8a2bf8ddc2..b4fed8353646 100644 --- a/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests-integration/tests/Test.hs @@ -122,7 +122,7 @@ testPetOps mgr config = let updatePetRequest = S.updatePet (S.ContentType S.MimeJSON) (pet { S.petStatus = Just S.E'Status2'Available - , S.petCategory = Just (S.Category (Just 3) (Just "catname")) + , S.petCategory = Just (S.Category (Just 3) "catname") }) updatePetResponse <- S.dispatchLbs mgr config updatePetRequest NH.responseStatus updatePetResponse `shouldBe` NH.status200 From 5aa1da7c2edb5d0a9552b95fd0f2598a538ea3f6 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 22 Nov 2018 18:46:09 +0800 Subject: [PATCH 08/14] Add utility methods for free-form objects (isFreeFormObject) (#1338) * add utility methods for models * add isFreeFormObject tag * add object mapping for elixir client * minor fix to free form object check --- .../codegen/CodegenParameter.java | 84 +++++----- .../openapitools/codegen/CodegenProperty.java | 93 ++++++------ .../openapitools/codegen/CodegenResponse.java | 143 ++++++++++-------- .../openapitools/codegen/DefaultCodegen.java | 44 ++++-- .../languages/ElixirClientCodegen.java | 2 +- .../codegen/utils/ModelUtils.java | 78 +++++++++- .../kotlin/KotlinClientCodegenModelTest.java | 2 +- 7 files changed, 281 insertions(+), 165 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java index 62aa1f22b8bb..7624815b9489 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java @@ -27,11 +27,12 @@ public class CodegenParameter { isCookieParam, isBodyParam, hasMore, isContainer, secondaryParam, isCollectionFormatMulti, isPrimitiveType, isModel; public String baseName, paramName, dataType, datatypeWithEnum, dataFormat, - collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName; + collectionFormat, description, unescapedDescription, baseType, defaultValue, enumName; public String example; // example value (x-example) public String jsonSchema; - public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid, isEmail; + public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, + isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject; public boolean isListContainer, isMapContainer; public boolean isFile; public boolean isEnum; @@ -94,7 +95,7 @@ public class CodegenParameter { * See http://json-schema.org/latest/json-schema-validation.html#anchor14 */ public Number multipleOf; - + public CodegenParameter copy() { CodegenParameter output = new CodegenParameter(); output.isFile = this.isFile; @@ -148,7 +149,7 @@ public class CodegenParameter { if (this.mostInnerItems != null) { output.mostInnerItems = this.mostInnerItems; } - if(this.vendorExtensions != null){ + if (this.vendorExtensions != null) { output.vendorExtensions = new HashMap(this.vendorExtensions); } output.hasValidation = this.hasValidation; @@ -167,6 +168,7 @@ public class CodegenParameter { output.isDateTime = this.isDateTime; output.isUuid = this.isUuid; output.isEmail = this.isEmail; + output.isFreeFormObject = this.isFreeFormObject; output.isListContainer = this.isListContainer; output.isMapContainer = this.isMapContainer; @@ -259,6 +261,8 @@ public class CodegenParameter { return false; if (isEmail != that.isEmail) return false; + if (isFreeFormObject != that.isFreeFormObject) + return false; if (isListContainer != that.isListContainer) return false; if (isMapContainer != that.isMapContainer) @@ -307,18 +311,18 @@ public class CodegenParameter { @Override public int hashCode() { - int result = isFormParam ? 13:31; - result = 31 * result + (isQueryParam ? 13:31); - result = 31 * result + (isPathParam ? 13:31); - result = 31 * result + (isHeaderParam ? 13:31); - result = 31 * result + (isCookieParam ? 13:31); - result = 31 * result + (isBodyParam ? 13:31); - result = 31 * result + (hasMore ? 13:31); - result = 31 * result + (isContainer ? 13:31); - result = 31 * result + (secondaryParam ? 13:31); - result = 31 * result + (isCollectionFormatMulti ? 13:31); - result = 31 * result + (isPrimitiveType ? 13:31); - result = 31 * result + (isModel ? 13:31); + int result = isFormParam ? 13 : 31; + result = 31 * result + (isQueryParam ? 13 : 31); + result = 31 * result + (isPathParam ? 13 : 31); + result = 31 * result + (isHeaderParam ? 13 : 31); + result = 31 * result + (isCookieParam ? 13 : 31); + result = 31 * result + (isBodyParam ? 13 : 31); + result = 31 * result + (hasMore ? 13 : 31); + result = 31 * result + (isContainer ? 13 : 31); + result = 31 * result + (secondaryParam ? 13 : 31); + result = 31 * result + (isCollectionFormatMulti ? 13 : 31); + result = 31 * result + (isPrimitiveType ? 13 : 31); + result = 31 * result + (isModel ? 13 : 31); result = 31 * result + (baseName != null ? baseName.hashCode() : 0); result = 31 * result + (paramName != null ? paramName.hashCode() : 0); result = 31 * result + (dataType != null ? dataType.hashCode() : 0); @@ -332,42 +336,43 @@ public class CodegenParameter { result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); result = 31 * result + (example != null ? example.hashCode() : 0); result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0); - result = 31 * result + (isString ? 13:31); - result = 31 * result + (isNumeric ? 13:31); - result = 31 * result + (isInteger ? 13:31); - result = 31 * result + (isLong ? 13:31); - result = 31 * result + (isFloat ? 13:31); - result = 31 * result + (isNumber ? 13:31); - result = 31 * result + (isDouble ? 13:31); - result = 31 * result + (isByteArray ? 13:31); - result = 31 * result + (isBinary ? 13:31); - result = 31 * result + (isBoolean ? 13:31); - result = 31 * result + (isDate ? 13:31); - result = 31 * result + (isDateTime ? 13:31); - result = 31 * result + (isUuid ? 13:31); - result = 31 * result + (isEmail ? 13:31); - result = 31 * result + (isListContainer ? 13:31); - result = 31 * result + (isMapContainer ? 13:31); - result = 31 * result + (isFile ? 13:31); + result = 31 * result + (isString ? 13 : 31); + result = 31 * result + (isNumeric ? 13 : 31); + result = 31 * result + (isInteger ? 13 : 31); + result = 31 * result + (isLong ? 13 : 31); + result = 31 * result + (isFloat ? 13 : 31); + result = 31 * result + (isNumber ? 13 : 31); + result = 31 * result + (isDouble ? 13 : 31); + result = 31 * result + (isByteArray ? 13 : 31); + result = 31 * result + (isBinary ? 13 : 31); + result = 31 * result + (isBoolean ? 13 : 31); + result = 31 * result + (isDate ? 13 : 31); + result = 31 * result + (isDateTime ? 13 : 31); + result = 31 * result + (isUuid ? 13 : 31); + result = 31 * result + (isEmail ? 13 : 31); + result = 31 * result + (isFreeFormObject ? 13 : 31); + result = 31 * result + (isListContainer ? 13 : 31); + result = 31 * result + (isMapContainer ? 13 : 31); + result = 31 * result + (isFile ? 13 : 31); result = 31 * result + (isEnum ? 1 : 0); result = 31 * result + (_enum != null ? _enum.hashCode() : 0); result = 31 * result + (allowableValues != null ? allowableValues.hashCode() : 0); result = 31 * result + (items != null ? items.hashCode() : 0); result = 31 * result + (mostInnerItems != null ? mostInnerItems.hashCode() : 0); result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); - result = 31 * result + (hasValidation ? 13:31); - result = 31 * result + (isNullable ? 13:31); - result = 31 * result + (required ? 13:31); + result = 31 * result + (hasValidation ? 13 : 31); + result = 31 * result + (isNullable ? 13 : 31); + result = 31 * result + (required ? 13 : 31); result = 31 * result + (maximum != null ? maximum.hashCode() : 0); - result = 31 * result + (exclusiveMaximum ? 13:31); + result = 31 * result + (exclusiveMaximum ? 13 : 31); result = 31 * result + (minimum != null ? minimum.hashCode() : 0); - result = 31 * result + (exclusiveMinimum ? 13:31); + result = 31 * result + (exclusiveMinimum ? 13 : 31); result = 31 * result + (maxLength != null ? maxLength.hashCode() : 0); result = 31 * result + (minLength != null ? minLength.hashCode() : 0); result = 31 * result + (pattern != null ? pattern.hashCode() : 0); result = 31 * result + (maxItems != null ? maxItems.hashCode() : 0); result = 31 * result + (minItems != null ? minItems.hashCode() : 0); - result = 31 * result + (uniqueItems ? 13:31); + result = 31 * result + (uniqueItems ? 13 : 31); result = 31 * result + (multipleOf != null ? multipleOf.hashCode() : 0); return result; } @@ -414,6 +419,7 @@ public class CodegenParameter { ", isDateTime=" + isDateTime + ", isUuid=" + isUuid + ", isEmail=" + isEmail + + ", isFreeFormObject=" + isFreeFormObject + ", isListContainer=" + isListContainer + ", isMapContainer=" + isMapContainer + ", isFile=" + isFile + diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java index 3fa796d45f28..7f6688c134ed 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java @@ -25,10 +25,12 @@ import java.util.Objects; public class CodegenProperty implements Cloneable { public String baseName, complexType, getter, setter, description, dataType, - datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam, - baseType, containerType, title; + datatypeWithEnum, dataFormat, name, min, max, defaultValue, defaultValueWithParam, + baseType, containerType, title; - /** The 'description' string without escape charcters needed by some programming languages/targets */ + /** + * The 'description' string without escape charcters needed by some programming languages/targets + */ public String unescapedDescription; /** @@ -56,7 +58,8 @@ public class CodegenProperty implements Cloneable { public boolean hasMore, required, secondaryParam; public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly public boolean isPrimitiveType, isModel, isContainer, isNotContainer; - public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid, isEmail; + public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, + isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject; public boolean isListContainer, isMapContainer; public boolean isEnum; public boolean isReadOnly; @@ -84,7 +87,7 @@ public class CodegenProperty implements Cloneable { public String xmlNamespace; public boolean isXmlWrapped = false; - public String getBaseName() { + public String getBaseName() { return baseName; } @@ -125,9 +128,9 @@ public class CodegenProperty implements Cloneable { } /** + * @return dataType * @deprecated since version 3.0.0, use {@link #getDataType()} instead.
* May be removed with the next major release (4.0) - * @return dataType */ @Deprecated public String getDatatype() { @@ -411,8 +414,7 @@ public class CodegenProperty implements Cloneable { } @Override - public int hashCode() - { + public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_enum == null) ? 0 : _enum.hashCode()); @@ -429,19 +431,19 @@ public class CodegenProperty implements Cloneable { result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((example == null) ? 0 : example.hashCode()); - result = prime * result + (exclusiveMaximum ? 13:31); - result = prime * result + (exclusiveMinimum ? 13:31); + result = prime * result + (exclusiveMaximum ? 13 : 31); + result = prime * result + (exclusiveMinimum ? 13 : 31); result = prime * result + ((getter == null) ? 0 : getter.hashCode()); - result = prime * result + (hasMore ? 13:31); - result = prime * result + ((hasMoreNonReadOnly ? 13:31)); - result = prime * result + ((isContainer ? 13:31)); + result = prime * result + (hasMore ? 13 : 31); + result = prime * result + ((hasMoreNonReadOnly ? 13 : 31)); + result = prime * result + ((isContainer ? 13 : 31)); result = prime * result + (isEnum ? 1231 : 1237); - result = prime * result + ((isNotContainer ? 13:31)); - result = prime * result + ((isPrimitiveType ? 13:31)); - result = prime * result + ((isModel ? 13:31)); - result = prime * result + ((isReadOnly ? 13:31)); - result = prime * result + ((isWriteOnly ? 13:31)); - result = prime * result + ((isNullable ? 13:31)); + result = prime * result + ((isNotContainer ? 13 : 31)); + result = prime * result + ((isPrimitiveType ? 13 : 31)); + result = prime * result + ((isModel ? 13 : 31)); + result = prime * result + ((isReadOnly ? 13 : 31)); + result = prime * result + ((isWriteOnly ? 13 : 31)); + result = prime * result + ((isNullable ? 13 : 31)); result = prime * result + ((items == null) ? 0 : items.hashCode()); result = prime * result + ((mostInnerItems == null) ? 0 : mostInnerItems.hashCode()); result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode()); @@ -453,29 +455,30 @@ public class CodegenProperty implements Cloneable { result = prime * result + ((minimum == null) ? 0 : minimum.hashCode()); result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((pattern == null) ? 0 : pattern.hashCode()); - result = prime * result + ((required ? 13:31)); - result = prime * result + ((secondaryParam ? 13:31)); + result = prime * result + ((required ? 13 : 31)); + result = prime * result + ((secondaryParam ? 13 : 31)); result = prime * result + ((setter == null) ? 0 : setter.hashCode()); result = prime * result + ((unescapedDescription == null) ? 0 : unescapedDescription.hashCode()); result = prime * result + ((vendorExtensions == null) ? 0 : vendorExtensions.hashCode()); - result = prime * result + ((hasValidation ? 13:31)); - result = prime * result + ((isString ? 13:31)); - result = prime * result + ((isNumeric ? 13:31)); - result = prime * result + ((isInteger ? 13:31)); - result = prime * result + ((isLong ?13:31)); - result = prime * result + ((isNumber ? 13:31)); - result = prime * result + ((isFloat ? 13:31)); - result = prime * result + ((isDouble ? 13:31)); - result = prime * result + ((isByteArray ? 13:31)); - result = prime * result + ((isBinary ? 13:31)); - result = prime * result + ((isFile ? 13:31)); - result = prime * result + ((isBoolean ? 13:31)); - result = prime * result + ((isDate ? 13:31)); - result = prime * result + ((isDateTime ? 13:31)); - result = prime * result + ((isUuid ? 13:31)); - result = prime * result + ((isEmail ? 13:31)); - result = prime * result + ((isMapContainer ? 13:31)); - result = prime * result + ((isListContainer ? 13:31)); + result = prime * result + ((hasValidation ? 13 : 31)); + result = prime * result + ((isString ? 13 : 31)); + result = prime * result + ((isNumeric ? 13 : 31)); + result = prime * result + ((isInteger ? 13 : 31)); + result = prime * result + ((isLong ? 13 : 31)); + result = prime * result + ((isNumber ? 13 : 31)); + result = prime * result + ((isFloat ? 13 : 31)); + result = prime * result + ((isDouble ? 13 : 31)); + result = prime * result + ((isByteArray ? 13 : 31)); + result = prime * result + ((isBinary ? 13 : 31)); + result = prime * result + ((isFile ? 13 : 31)); + result = prime * result + ((isBoolean ? 13 : 31)); + result = prime * result + ((isDate ? 13 : 31)); + result = prime * result + ((isDateTime ? 13 : 31)); + result = prime * result + ((isUuid ? 13 : 31)); + result = prime * result + ((isEmail ? 13 : 31)); + result = prime * result + ((isFreeFormObject ? 13 : 31)); + result = prime * result + ((isMapContainer ? 13 : 31)); + result = prime * result + ((isListContainer ? 13 : 31)); result = prime * result + Objects.hashCode(isInherited); result = prime * result + Objects.hashCode(discriminatorValue); result = prime * result + Objects.hashCode(nameInCamelCase); @@ -483,11 +486,11 @@ public class CodegenProperty implements Cloneable { result = prime * result + Objects.hashCode(enumName); result = prime * result + ((maxItems == null) ? 0 : maxItems.hashCode()); result = prime * result + ((minItems == null) ? 0 : minItems.hashCode()); - result = prime * result + ((isXmlAttribute ? 13:31)); + result = prime * result + ((isXmlAttribute ? 13 : 31)); result = prime * result + ((xmlPrefix == null) ? 0 : xmlPrefix.hashCode()); result = prime * result + ((xmlName == null) ? 0 : xmlName.hashCode()); result = prime * result + ((xmlNamespace == null) ? 0 : xmlNamespace.hashCode()); - result = prime * result + ((isXmlWrapped ? 13:31)); + result = prime * result + ((isXmlWrapped ? 13 : 31)); return result; } @@ -657,6 +660,9 @@ public class CodegenProperty implements Cloneable { if (this.isEmail != other.isEmail) { return false; } + if (this.isFreeFormObject != other.isFreeFormObject) { + return false; + } if (this.isBinary != other.isBinary) { return false; } @@ -724,7 +730,7 @@ public class CodegenProperty implements Cloneable { if (this.mostInnerItems != null) { cp.mostInnerItems = this.mostInnerItems; } - if(this.vendorExtensions != null){ + if (this.vendorExtensions != null) { cp.vendorExtensions = new HashMap(this.vendorExtensions); } return cp; @@ -785,11 +791,12 @@ public class CodegenProperty implements Cloneable { ", isDateTime=" + isDateTime + ", isUuid=" + isUuid + ", isEmail=" + isEmail + + ", isFreeFormObject=" + isFreeFormObject + ", isListContainer=" + isListContainer + ", isMapContainer=" + isMapContainer + ", isEnum=" + isEnum + ", isReadOnly=" + isReadOnly + - ", isWriteOnly=" + isWriteOnly+ + ", isWriteOnly=" + isWriteOnly + ", isNullable=" + isNullable + ", _enum=" + _enum + ", allowableValues=" + allowableValues + diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java index 642e44a810f6..e4241ee00eb9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java @@ -17,11 +17,7 @@ package org.openapitools.codegen; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; public class CodegenResponse { public final List headers = new ArrayList(); @@ -30,7 +26,8 @@ public class CodegenResponse { public List> examples; public String dataType, baseType, containerType; public boolean hasHeaders; - public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBoolean, isDate, isDateTime, isUuid, isEmail; + public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBoolean, isDate, + isDateTime, isUuid, isEmail, isModel, isFreeFormObject; public boolean isDefault; public boolean simpleType; public boolean primitiveType; @@ -48,76 +45,90 @@ public class CodegenResponse { @Override public String toString() { - return String.format(Locale.ROOT, "%s(%s)", code, containerType); + return "CodegenResponse{" + + "headers=" + headers + + ", code='" + code + '\'' + + ", message='" + message + '\'' + + ", hasMore=" + hasMore + + ", examples=" + examples + + ", dataType='" + dataType + '\'' + + ", baseType='" + baseType + '\'' + + ", containerType='" + containerType + '\'' + + ", hasHeaders=" + hasHeaders + + ", isString=" + isString + + ", isNumeric=" + isNumeric + + ", isInteger=" + isInteger + + ", isLong=" + isLong + + ", isNumber=" + isNumber + + ", isFloat=" + isFloat + + ", isDouble=" + isDouble + + ", isByteArray=" + isByteArray + + ", isBoolean=" + isBoolean + + ", isDate=" + isDate + + ", isDateTime=" + isDateTime + + ", isUuid=" + isUuid + + ", isEmail=" + isEmail + + ", isFreeFormObject=" + isFreeFormObject + + ", isModel=" + isModel + + ", isDefault=" + isDefault + + ", simpleType=" + simpleType + + ", primitiveType=" + primitiveType + + ", isMapContainer=" + isMapContainer + + ", isListContainer=" + isListContainer + + ", isBinary=" + isBinary + + ", isFile=" + isFile + + ", schema=" + schema + + ", jsonSchema='" + jsonSchema + '\'' + + ", vendorExtensions=" + vendorExtensions + + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - CodegenResponse that = (CodegenResponse) o; - - if (!headers.equals(that.headers)) - return false; - if (code != null ? !code.equals(that.code) : that.code != null) - return false; - if (message != null ? !message.equals(that.message) : that.message != null) - return false; - if (hasMore != that.hasMore) - return false; - if (examples != null ? !examples.equals(that.examples) : that.examples != null) - return false; - if (dataType != null ? !dataType.equals(that.dataType) : that.dataType != null) - return false; - if (baseType != null ? !baseType.equals(that.baseType) : that.baseType != null) - return false; - if (containerType != null ? !containerType.equals(that.containerType) : that.containerType != null) - return false; - if (isDefault != that.isDefault) - return false; - if (simpleType != that.simpleType) - return false; - if (primitiveType != that.primitiveType) - return false; - if (isMapContainer != that.isMapContainer) - return false; - if (isListContainer != that.isListContainer) - return false; - if (isBinary != that.isBinary) - return false; - if (isFile != that.isFile) - return false; - if (isNumeric != that.isNumeric) - return false; - if (schema != null ? !schema.equals(that.schema) : that.schema != null) - return false; - if (vendorExtensions != null ? !vendorExtensions.equals(that.vendorExtensions) : that.vendorExtensions != null) - return false; - return jsonSchema != null ? jsonSchema.equals(that.jsonSchema) : that.jsonSchema == null; + return hasMore == that.hasMore && + hasHeaders == that.hasHeaders && + isString == that.isString && + isNumeric == that.isNumeric && + isInteger == that.isInteger && + isLong == that.isLong && + isNumber == that.isNumber && + isFloat == that.isFloat && + isDouble == that.isDouble && + isByteArray == that.isByteArray && + isBoolean == that.isBoolean && + isDate == that.isDate && + isDateTime == that.isDateTime && + isUuid == that.isUuid && + isEmail == that.isEmail && + isFreeFormObject == that.isFreeFormObject && + isModel == that.isModel && + isDefault == that.isDefault && + simpleType == that.simpleType && + primitiveType == that.primitiveType && + isMapContainer == that.isMapContainer && + isListContainer == that.isListContainer && + isBinary == that.isBinary && + isFile == that.isFile && + Objects.equals(headers, that.headers) && + Objects.equals(code, that.code) && + Objects.equals(message, that.message) && + Objects.equals(examples, that.examples) && + Objects.equals(dataType, that.dataType) && + Objects.equals(baseType, that.baseType) && + Objects.equals(containerType, that.containerType) && + Objects.equals(schema, that.schema) && + Objects.equals(jsonSchema, that.jsonSchema) && + Objects.equals(vendorExtensions, that.vendorExtensions); } @Override public int hashCode() { - int result = headers.hashCode(); - result = 31 * result + (code != null ? code.hashCode() : 0); - result = 31 * result + (message != null ? message.hashCode() : 0); - result = 31 * result + (hasMore ? 13:31); - result = 31 * result + (examples != null ? examples.hashCode() : 0); - result = 31 * result + (dataType != null ? dataType.hashCode() : 0); - result = 31 * result + (baseType != null ? baseType.hashCode() : 0); - result = 31 * result + (containerType != null ? containerType.hashCode() : 0); - result = 31 * result + (isDefault ? 13:31); - result = 31 * result + (isNumeric ? 13:31); - result = 31 * result + (simpleType ? 13:31); - result = 31 * result + (primitiveType ? 13:31); - result = 31 * result + (isMapContainer ? 13:31); - result = 31 * result + (isListContainer ? 13:31); - result = 31 * result + (isBinary ? 13:31); - result = 31 * result + (isFile ? 13:31); - result = 31 * result + (schema != null ? schema.hashCode() : 0); - result = 31 * result + (jsonSchema != null ? jsonSchema.hashCode() : 0); - result = 31 * result + (vendorExtensions != null ? vendorExtensions.hashCode() : 0); - return result; + return Objects.hash(headers, code, message, hasMore, examples, dataType, baseType, containerType, hasHeaders, + isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBoolean, isDate, + isDateTime, isUuid, isEmail, isFreeFormObject, isModel, isDefault, simpleType, primitiveType, isMapContainer, + isListContainer, isBinary, isFile, schema, jsonSchema, vendorExtensions); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index dd47986cec1a..e8a4cc5f9bb4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1152,6 +1152,8 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.example = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; } else if (Boolean.TRUE.equals(codegenParameter.isString)) { codegenParameter.example = codegenParameter.paramName + "_example"; + } else if (Boolean.TRUE.equals(codegenParameter.isFreeFormObject)) { + codegenParameter.example = "Object"; } } @@ -1375,6 +1377,8 @@ public class DefaultCodegen implements CodegenConfig { return "UUID"; } else if (ModelUtils.isStringSchema(schema)) { return "string"; + } else if (ModelUtils.isFreeFormObject(schema)) { + return "object"; } else if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { // having property implies it's a model return "object"; } else if (StringUtils.isNotEmpty(schema.getType())) { @@ -1685,7 +1689,8 @@ public class DefaultCodegen implements CodegenConfig { return m; } - private CodegenDiscriminator createDiscriminator(String schemaName, Schema schema, Map allDefinitions) { + private CodegenDiscriminator createDiscriminator(String schemaName, Schema + schema, Map allDefinitions) { if (schema.getDiscriminator() == null) { return null; } @@ -1717,7 +1722,8 @@ public class DefaultCodegen implements CodegenConfig { addParentContainer(codegenModel, codegenModel.name, schema); } - protected void addProperties(Map properties, List required, Schema schema, Map allSchemas) { + protected void addProperties(Map properties, List required, Schema + schema, Map allSchemas) { if (schema instanceof ComposedSchema) { ComposedSchema composedSchema = (ComposedSchema) schema; if (composedSchema.getAllOf() == null) { @@ -2010,6 +2016,9 @@ public class DefaultCodegen implements CodegenConfig { // handle inner property CodegenProperty cp = fromProperty("inner", ModelUtils.getAdditionalProperties(p)); updatePropertyForMap(property, cp); + } else if (ModelUtils.isFreeFormObject(p)) { + property.isFreeFormObject = true; + property.baseType = getSchemaType(p); } else { // model // TODO revise the logic below //if (StringUtils.isNotBlank(p.get$ref())) { @@ -2212,7 +2221,8 @@ public class DefaultCodegen implements CodegenConfig { * @param schemas a map of OAS models * @return Codegen Operation object */ - public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map schemas) { + public CodegenOperation fromOperation(String path, String httpMethod, Operation + operation, Map schemas) { return fromOperation(path, httpMethod, operation, schemas, null); } @@ -2576,6 +2586,7 @@ public class DefaultCodegen implements CodegenConfig { } else { if (cp.complexType != null) { r.baseType = cp.complexType; + r.isModel = true; } else { r.baseType = cp.baseType; } @@ -2616,6 +2627,8 @@ public class DefaultCodegen implements CodegenConfig { r.isDate = true; } else if (Boolean.TRUE.equals(cp.isDateTime)) { r.isDateTime = true; + } else if (Boolean.TRUE.equals(cp.isFreeFormObject)) { + r.isFreeFormObject = true; } else { LOGGER.debug("Property type is not primitive: " + cp.dataType); } @@ -2651,7 +2664,8 @@ public class DefaultCodegen implements CodegenConfig { * @param openAPI a OAS object representing the spec * @return Codegen Response object */ - public CodegenCallback fromCallback(String name, Callback callback, Map schemas, OpenAPI openAPI) { + public CodegenCallback fromCallback(String name, Callback callback, Map schemas, OpenAPI + openAPI) { CodegenCallback c = new CodegenCallback(); c.name = name; @@ -3227,7 +3241,8 @@ public class DefaultCodegen implements CodegenConfig { * @param operations map of Codegen operations */ @SuppressWarnings("static-method") - public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { + public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation + co, Map> operations) { List opList = operations.get(tag); if (opList == null) { opList = new ArrayList(); @@ -3334,7 +3349,8 @@ public class DefaultCodegen implements CodegenConfig { * @param properties model properties (schemas) * @return model properties with direct reference to schemas */ - private Map unaliasPropertySchema(Map allSchemas, Map properties) { + private Map unaliasPropertySchema + (Map allSchemas, Map properties) { if (properties != null) { for (String key : properties.keySet()) { properties.put(key, ModelUtils.unaliasSchema(allSchemas, properties.get(key))); @@ -3375,7 +3391,8 @@ public class DefaultCodegen implements CodegenConfig { } } - private void addVars(CodegenModel m, List vars, Map properties, Set mandatory) { + private void addVars(CodegenModel + m, List vars, Map properties, Set mandatory) { // convert set to list so that we can access the next entry in the loop List> propertyList = new ArrayList>(properties.entrySet()); final int totalCount = propertyList.size(); @@ -3888,6 +3905,8 @@ public class DefaultCodegen implements CodegenConfig { } else if (Boolean.TRUE.equals(property.isDateTime)) { parameter.isDateTime = true; parameter.isPrimitiveType = true; + } else if (Boolean.TRUE.equals(property.isFreeFormObject)) { + parameter.isFreeFormObject = true; } else { LOGGER.debug("Property type is not primitive: " + property.dataType); } @@ -3961,7 +3980,8 @@ public class DefaultCodegen implements CodegenConfig { } } - private void updateEnumVarsWithExtensions(List> enumVars, Map vendorExtensions) { + private void updateEnumVarsWithExtensions + (List> enumVars, Map vendorExtensions) { if (vendorExtensions != null && vendorExtensions.containsKey("x-enum-varnames")) { List alias = (List) vendorExtensions.get("x-enum-varnames"); int size = Math.min(enumVars.size(), alias.size()); @@ -4272,7 +4292,8 @@ public class DefaultCodegen implements CodegenConfig { return null; } - public List fromRequestBodyToFormParameters(RequestBody body, Map schemas, Set imports) { + public List fromRequestBodyToFormParameters(RequestBody + body, Map schemas, Set imports) { List parameters = new ArrayList(); LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body); Schema schema = ModelUtils.getSchemaFromRequestBody(body); @@ -4428,7 +4449,8 @@ public class DefaultCodegen implements CodegenConfig { return codegenParameter; } - public CodegenParameter fromRequestBody(RequestBody body, Map schemas, Set imports, String bodyParameterName) { + public CodegenParameter fromRequestBody(RequestBody + body, Map schemas, Set imports, String bodyParameterName) { if (body == null) { LOGGER.error("body in fromRequestBody cannot be null!"); } @@ -4735,7 +4757,7 @@ public class DefaultCodegen implements CodegenConfig { /** * Set the boolean value indicating the state of the option for post-processing file using envirionment variables. * - * @param enablePostProcessFile true to enable post-processing file + * @param enablePostProcessFile true to enable post-processing file */ public void setEnablePostProcessFile(boolean enablePostProcessFile) { this.enablePostProcessFile = enablePostProcessFile; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java index 230100673c7c..aa5bccbab4ae 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java @@ -169,7 +169,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("map", "Map"); typeMapping.put("array", "List"); typeMapping.put("list", "List"); - // typeMapping.put("object", "Map"); + typeMapping.put("object", "Map"); typeMapping.put("binary", "String"); typeMapping.put("ByteArray", "String"); typeMapping.put("UUID", "String"); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index 4a1dd19ee602..6f495304fcc2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -302,9 +302,13 @@ public class ModelUtils { if (schema instanceof ObjectSchema) { return true; } + + // must not be a map if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && !(schema instanceof MapSchema)) { return true; } + + // must have at least one property if (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty()) { return true; } @@ -501,7 +505,70 @@ public class ModelUtils { } /** - * If a Schema contains a reference to an other Schema with '$ref', returns the referenced Schema if it is found or the actual Schema in the other cases. + * Check to see if the schema is a model with at least one properties + * + * @param schema potentially containing a '$ref' + * @return true if it's a model with at least one properties + */ + public static boolean isModel(Schema schema) { + if (schema == null) { + LOGGER.error("Schema cannot be null in isModel check"); + return false; + } + + // has at least one property + if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { + return true; + } + + // composed schema is a model + if (schema instanceof ComposedSchema) { + return true; + } + + return false; + } + + /** + * Check to see if the schema is a free form object + * + * @param schema potentially containing a '$ref' + * @return true if it's a free-form object + */ + public static boolean isFreeFormObject(Schema schema) { + if (schema == null) { + LOGGER.error("Schema cannot be null in isFreeFormObject check"); + return false; + } + + // has at least one property + if ("object".equals(schema.getType())) { + // no properties + if ((schema.getProperties() == null || schema.getProperties().isEmpty())) { + if (schema.getAdditionalProperties() == null) { + return true; + } else { + // additionalProperties set to true + if (schema.getAdditionalProperties() instanceof Boolean + && (Boolean) schema.getAdditionalProperties()) { + return true; + } + + // additionalProperties is set to {} + if (schema.getAdditionalProperties() instanceof Schema && schema.getAdditionalProperties() != null + && schema.getAdditionalProperties() instanceof ObjectSchema + && ((Schema) schema.getAdditionalProperties()).getProperties().isEmpty()) { + return true; + } + } + } + } + + return false; + } + + /** + * If a Schema contains a reference to another Schema with '$ref', returns the referenced Schema if it is found or the actual Schema in the other cases. * * @param openAPI specification being checked * @param schema potentially containing a '$ref' @@ -623,7 +690,7 @@ public class ModelUtils { /** * If a Callback contains a reference to an other Callback with '$ref', returns the referenced Callback if it is found or the actual Callback in the other cases. * - * @param openAPI specification being checked + * @param openAPI specification being checked * @param callback potentially containing a '$ref' * @return callback without '$ref' */ @@ -642,7 +709,7 @@ public class ModelUtils { if (name == null) { return null; } - + if (openAPI != null && openAPI.getComponents() != null && openAPI.getComponents().getCallbacks() != null) { return openAPI.getComponents().getCallbacks().get(name); } @@ -689,7 +756,8 @@ public class ModelUtils { */ public static Schema unaliasSchema(Map allSchemas, Schema schema) { if (allSchemas == null || allSchemas.isEmpty()) { - LOGGER.warn("allSchemas cann't be null/empty in unaliasSchema. Returned 'schema'"); + // skip the warning as the spec can have no model defined + //LOGGER.warn("allSchemas cannot be null/empty in unaliasSchema. Returned 'schema'"); return schema; } @@ -701,6 +769,8 @@ public class ModelUtils { } else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) { // top-level enum class return schema; + } else if (isFreeFormObject(ref)) { + return schema; } else if (isArraySchema(ref) || isComposedSchema(ref)) { // array def should be created as models return schema; } else if (isMapSchema(ref)) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java index 312a2fa32e3e..4c6894c17d48 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinClientCodegenModelTest.java @@ -238,7 +238,7 @@ public class KotlinClientCodegenModelTest { Assert.assertEquals(property1.name, "child"); Assert.assertEquals(property1.baseType, "Child"); Assert.assertFalse(property1.required); - Assert.assertTrue(property1.isNotContainer); + Assert.assertFalse(property1.isContainer); } @DataProvider(name = "modelNames") From cf04ba30dbf085bd8401e13ec884ed36ec3ea8bc Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 23 Nov 2018 17:32:51 +0800 Subject: [PATCH 09/14] Fix the function name starting with numbers (#1513) * update elixir samples * fix function name starting with numbers * add new files --- .../languages/ElixirClientCodegen.java | 14 +++- .../src/main/resources/elixir/api.mustache | 2 +- .../petstore/elixir/.openapi-generator-ignore | 23 ++++++ .../elixir/.openapi-generator/VERSION | 2 +- .../client/petstore/elixir/config/config.exs | 4 +- .../lib/openapi_petstore/api/another_fake.ex | 6 +- .../elixir/lib/openapi_petstore/api/fake.ex | 70 +++++++++++++++++-- .../elixir/lib/openapi_petstore/api/pet.ex | 30 ++++++++ .../elixir/lib/openapi_petstore/connection.ex | 2 +- .../model/file_schema_test_class.ex | 30 ++++++++ .../lib/openapi_petstore/model/map_test.ex | 8 ++- .../openapi_petstore/model/outer_composite.ex | 6 +- .../model/string_boolean_map.ex | 25 +++++++ 13 files changed, 204 insertions(+), 18 deletions(-) create mode 100644 samples/client/petstore/elixir/.openapi-generator-ignore create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex create mode 100644 samples/client/petstore/elixir/lib/openapi_petstore/model/string_boolean_map.ex diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java index aa5bccbab4ae..e9b8783f0726 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElixirClientCodegen.java @@ -431,7 +431,19 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig throw new RuntimeException("Empty method name (operationId) not allowed"); } - return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId)); + // method name cannot use reserved keyword, e.g. return + if (isReservedWord(operationId)) { + LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId))); + return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)); + } + + // operationId starts with a number + if (operationId.matches("^\\d.*")) { + LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId))); + operationId = "call_" + operationId; + } + + return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId)); } /** diff --git a/modules/openapi-generator/src/main/resources/elixir/api.mustache b/modules/openapi-generator/src/main/resources/elixir/api.mustache index 90ffb40f756b..48bb292aae16 100644 --- a/modules/openapi-generator/src/main/resources/elixir/api.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/api.mustache @@ -34,7 +34,7 @@ defmodule {{moduleName}}.Api.{{classname}} do {:error, info} on failure """ {{{typespec}}} - def {{#underscored}}{{{operationId}}}{{/underscored}}(connection, {{#requiredParams}}{{#underscored}}{{{paramName}}}{{/underscored}}, {{/requiredParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do + def {{{operationId}}}(connection, {{#requiredParams}}{{#underscored}}{{{paramName}}}{{/underscored}}, {{/requiredParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do {{#optionalParams}} {{#-first}} optional_params = %{ diff --git a/samples/client/petstore/elixir/.openapi-generator-ignore b/samples/client/petstore/elixir/.openapi-generator-ignore new file mode 100644 index 000000000000..7484ee590a38 --- /dev/null +++ b/samples/client/petstore/elixir/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/elixir/.openapi-generator/VERSION b/samples/client/petstore/elixir/.openapi-generator/VERSION index 096bf47efe31..d077ffb477a4 100644 --- a/samples/client/petstore/elixir/.openapi-generator/VERSION +++ b/samples/client/petstore/elixir/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/elixir/config/config.exs b/samples/client/petstore/elixir/config/config.exs index 7ce1553ff17a..72508194de35 100644 --- a/samples/client/petstore/elixir/config/config.exs +++ b/samples/client/petstore/elixir/config/config.exs @@ -10,11 +10,11 @@ use Mix.Config # You can configure for your application as: # -# config :swagger_petstore, key: :value +# config :open_api_petstore, key: :value # # And access this configuration in your application as: # -# Application.get_env(:swagger_petstore, :key) +# Application.get_env(:open_api_petstore, :key) # # Or configure a 3rd-party app: # diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex index fe8ba559f33b..3a20ea4fa7d5 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex @@ -13,7 +13,7 @@ defmodule OpenapiPetstore.Api.AnotherFake do @doc """ To test special tags - To test special tags + To test special tags and operation ID starting with number ## Parameters @@ -25,8 +25,8 @@ defmodule OpenapiPetstore.Api.AnotherFake do {:ok, %OpenapiPetstore.Model.Client{}} on success {:error, info} on failure """ - @spec test_special_tags(Tesla.Env.client, OpenapiPetstore.Model.Client.t, keyword()) :: {:ok, OpenapiPetstore.Model.Client.t} | {:error, Tesla.Env.t} - def test_special_tags(connection, client, _opts \\ []) do + @spec call_123_test_special_tags(Tesla.Env.client, OpenapiPetstore.Model.Client.t, keyword()) :: {:ok, OpenapiPetstore.Model.Client.t} | {:error, Tesla.Env.t} + def call_123_test_special_tags(connection, client, _opts \\ []) do %{} |> method(:patch) |> url("/another-fake/dummy") diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex index 92281bc7f3c1..6e04b9118984 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex @@ -21,7 +21,7 @@ defmodule OpenapiPetstore.Api.Fake do - :body (boolean()): Input boolean as post body ## Returns - {:ok, %OpenapiPetstore.Model.Boolean{}} on success + {:ok, %OpenapiPetstore.Model.boolean(){}} on success {:error, info} on failure """ @spec fake_outer_boolean_serialize(Tesla.Env.client, keyword()) :: {:ok, Boolean.t} | {:error, Tesla.Env.t} @@ -75,7 +75,7 @@ defmodule OpenapiPetstore.Api.Fake do - :body (float()): Input number as post body ## Returns - {:ok, %OpenapiPetstore.Model.Float{}} on success + {:ok, %OpenapiPetstore.Model.float(){}} on success {:error, info} on failure """ @spec fake_outer_number_serialize(Tesla.Env.client, keyword()) :: {:ok, Float.t} | {:error, Tesla.Env.t} @@ -102,7 +102,7 @@ defmodule OpenapiPetstore.Api.Fake do - :body (String.t): Input string as post body ## Returns - {:ok, %OpenapiPetstore.Model.String{}} on success + {:ok, %OpenapiPetstore.Model.String.t{}} on success {:error, info} on failure """ @spec fake_outer_string_serialize(Tesla.Env.client, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t} @@ -119,6 +119,30 @@ defmodule OpenapiPetstore.Api.Fake do |> decode(false) end + @doc """ + For this test, the body for this request much reference a schema named `File`. + + ## Parameters + + - connection (OpenapiPetstore.Connection): Connection to server + - file_schema_test_class (FileSchemaTestClass): + - opts (KeywordList): [optional] Optional parameters + ## Returns + + {:ok, %{}} on success + {:error, info} on failure + """ + @spec test_body_with_file_schema(Tesla.Env.client, OpenapiPetstore.Model.FileSchemaTestClass.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_body_with_file_schema(connection, file_schema_test_class, _opts \\ []) do + %{} + |> method(:put) + |> url("/fake/body-with-file-schema") + |> add_param(:body, :"FileSchemaTestClass", file_schema_test_class) + |> Enum.into([]) + |> (&Connection.request(connection, &1)).() + |> decode(false) + end + @doc """ ## Parameters @@ -265,13 +289,51 @@ defmodule OpenapiPetstore.Api.Fake do |> decode(false) end + @doc """ + Fake endpoint to test group parameters (optional) + Fake endpoint to test group parameters (optional) + + ## Parameters + + - connection (OpenapiPetstore.Connection): Connection to server + - required_string_group (integer()): Required String in group parameters + - required_boolean_group (boolean()): Required Boolean in group parameters + - required_int64_group (integer()): Required Integer in group parameters + - opts (KeywordList): [optional] Optional parameters + - :string_group (integer()): String in group parameters + - :boolean_group (boolean()): Boolean in group parameters + - :int64_group (integer()): Integer in group parameters + ## Returns + + {:ok, %{}} on success + {:error, info} on failure + """ + @spec test_group_parameters(Tesla.Env.client, integer(), boolean(), integer(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} + def test_group_parameters(connection, required_string_group, required_boolean_group, required_int64_group, opts \\ []) do + optional_params = %{ + :"string_group" => :query, + :"boolean_group" => :headers, + :"int64_group" => :query + } + %{} + |> method(:delete) + |> url("/fake") + |> add_param(:query, :"required_string_group", required_string_group) + |> add_param(:headers, :"required_boolean_group", required_boolean_group) + |> add_param(:query, :"required_int64_group", required_int64_group) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + |> (&Connection.request(connection, &1)).() + |> decode(false) + end + @doc """ test inline additionalProperties ## Parameters - connection (OpenapiPetstore.Connection): Connection to server - - request_body (String.t): request body + - request_body (%{optional(String.t) => String.t}): request body - opts (KeywordList): [optional] Optional parameters ## Returns diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex index ba926165d6db..777f3102f8e7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex @@ -220,4 +220,34 @@ defmodule OpenapiPetstore.Api.Pet do |> (&Connection.request(connection, &1)).() |> decode(%OpenapiPetstore.Model.ApiResponse{}) end + + @doc """ + uploads an image (required) + + ## Parameters + + - connection (OpenapiPetstore.Connection): Connection to server + - pet_id (integer()): ID of pet to update + - required_file (String.t): file to upload + - opts (KeywordList): [optional] Optional parameters + - :additional_metadata (String.t): Additional data to pass to server + ## Returns + + {:ok, %OpenapiPetstore.Model.ApiResponse{}} on success + {:error, info} on failure + """ + @spec upload_file_with_required_file(Tesla.Env.client, integer(), String.t, keyword()) :: {:ok, OpenapiPetstore.Model.ApiResponse.t} | {:error, Tesla.Env.t} + def upload_file_with_required_file(connection, pet_id, required_file, opts \\ []) do + optional_params = %{ + :"additionalMetadata" => :form + } + %{} + |> method(:post) + |> url("/fake/#{pet_id}/uploadImageWithRequiredFile") + |> add_param(:file, :"requiredFile", required_file) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + |> (&Connection.request(connection, &1)).() + |> decode(%OpenapiPetstore.Model.ApiResponse{}) + end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex index a26f07618129..834cc003d108 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex @@ -15,7 +15,7 @@ defmodule OpenapiPetstore.Connection do plug Tesla.Middleware.EncodeJson @doc """ - Configure an client connection using Basic authentication. + Configure a client connection using Basic authentication. ## Parameters diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex new file mode 100644 index 000000000000..3a52359a5f00 --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex @@ -0,0 +1,30 @@ +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# https://openapi-generator.tech +# Do not edit the class manually. + +defmodule OpenapiPetstore.Model.FileSchemaTestClass do + @moduledoc """ + + """ + + @derive [Poison.Encoder] + defstruct [ + :"file", + :"files" + ] + + @type t :: %__MODULE__{ + :"file" => File, + :"files" => [File] + } +end + +defimpl Poison.Decoder, for: OpenapiPetstore.Model.FileSchemaTestClass do + import OpenapiPetstore.Deserializer + def decode(value, options) do + value + |> deserialize(:"file", :struct, OpenapiPetstore.Model.File, options) + |> deserialize(:"files", :list, OpenapiPetstore.Model.File, options) + end +end + diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex index a1fac422b3d0..d3870aa0075e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex @@ -10,12 +10,16 @@ defmodule OpenapiPetstore.Model.MapTest do @derive [Poison.Encoder] defstruct [ :"map_map_of_string", - :"map_of_enum_string" + :"map_of_enum_string", + :"direct_map", + :"indirect_map" ] @type t :: %__MODULE__{ :"map_map_of_string" => %{optional(String.t) => %{optional(String.t) => String.t}}, - :"map_of_enum_string" => %{optional(String.t) => String.t} + :"map_of_enum_string" => %{optional(String.t) => String.t}, + :"direct_map" => %{optional(String.t) => boolean()}, + :"indirect_map" => %{optional(String.t) => boolean()} } end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex index a64e58740f61..00c4df9228e3 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex @@ -15,9 +15,9 @@ defmodule OpenapiPetstore.Model.OuterComposite do ] @type t :: %__MODULE__{ - :"my_number" => Float, - :"my_string" => String, - :"my_boolean" => Boolean + :"my_number" => float(), + :"my_string" => String.t, + :"my_boolean" => boolean() } end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/string_boolean_map.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/string_boolean_map.ex new file mode 100644 index 000000000000..68c76b6fe59d --- /dev/null +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/string_boolean_map.ex @@ -0,0 +1,25 @@ +# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). +# https://openapi-generator.tech +# Do not edit the class manually. + +defmodule OpenapiPetstore.Model.StringBooleanMap do + @moduledoc """ + + """ + + @derive [Poison.Encoder] + defstruct [ + + ] + + @type t :: %__MODULE__{ + + } +end + +defimpl Poison.Decoder, for: OpenapiPetstore.Model.StringBooleanMap do + def decode(value, _options) do + value + end +end + From dd33434064f8084e26fe12c664c019fb87b17a08 Mon Sep 17 00:00:00 2001 From: Juan Eugenio Abadie Date: Fri, 23 Nov 2018 07:38:40 -0300 Subject: [PATCH 10/14] [cpp rest-sdk] Reponse headers handler (#1511) * Add support to set a Response headers handler * Update PetStore * Fix missing names * Update PetStore --- .../cpp-rest-sdk-client/api-source.mustache | 5 +++ .../apiclient-header.mustache | 7 ++++ .../apiclient-source.mustache | 8 ++++ .../cpp-restsdk/.openapi-generator/VERSION | 2 +- .../client/petstore/cpp-restsdk/ApiClient.cpp | 10 ++++- .../client/petstore/cpp-restsdk/ApiClient.h | 9 +++- .../petstore/cpp-restsdk/ApiConfiguration.cpp | 2 +- .../petstore/cpp-restsdk/ApiConfiguration.h | 2 +- .../petstore/cpp-restsdk/ApiException.cpp | 2 +- .../petstore/cpp-restsdk/ApiException.h | 2 +- .../petstore/cpp-restsdk/HttpContent.cpp | 2 +- .../client/petstore/cpp-restsdk/HttpContent.h | 2 +- .../client/petstore/cpp-restsdk/IHttpBody.h | 2 +- .../client/petstore/cpp-restsdk/JsonBody.cpp | 2 +- .../client/petstore/cpp-restsdk/JsonBody.h | 2 +- .../client/petstore/cpp-restsdk/ModelBase.cpp | 2 +- .../client/petstore/cpp-restsdk/ModelBase.h | 2 +- .../cpp-restsdk/MultipartFormData.cpp | 2 +- .../petstore/cpp-restsdk/MultipartFormData.h | 2 +- .../client/petstore/cpp-restsdk/Object.cpp | 2 +- samples/client/petstore/cpp-restsdk/Object.h | 2 +- .../petstore/cpp-restsdk/api/PetApi.cpp | 42 ++++++++++++++++++- .../client/petstore/cpp-restsdk/api/PetApi.h | 6 +-- .../petstore/cpp-restsdk/api/StoreApi.cpp | 22 +++++++++- .../petstore/cpp-restsdk/api/StoreApi.h | 4 +- .../petstore/cpp-restsdk/api/UserApi.cpp | 42 ++++++++++++++++++- .../client/petstore/cpp-restsdk/api/UserApi.h | 4 +- .../cpp-restsdk/model/ApiResponse.cpp | 2 +- .../petstore/cpp-restsdk/model/ApiResponse.h | 2 +- .../petstore/cpp-restsdk/model/Category.cpp | 2 +- .../petstore/cpp-restsdk/model/Category.h | 2 +- .../petstore/cpp-restsdk/model/Order.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Order.h | 2 +- .../client/petstore/cpp-restsdk/model/Pet.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Pet.h | 2 +- .../client/petstore/cpp-restsdk/model/Tag.cpp | 2 +- .../client/petstore/cpp-restsdk/model/Tag.h | 2 +- .../petstore/cpp-restsdk/model/User.cpp | 2 +- .../client/petstore/cpp-restsdk/model/User.h | 2 +- 39 files changed, 175 insertions(+), 40 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache index d00fcdeb6e3a..fd0544f89f78 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache @@ -260,6 +260,11 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("{{httpMethod}}"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-header.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-header.mustache index 23bc7633171e..be60eb431e5f 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-header.mustache @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -32,6 +33,11 @@ public: ApiClient( std::shared_ptr configuration = nullptr ); virtual ~ApiClient(); + typedef std::function ResponseHeadersHandlerType; + + const ResponseHeadersHandlerType& getResponseHeadersHandler() const; + void setResponseHeadersHandler(const ResponseHeadersHandlerType& responseHeadersHandler); + std::shared_ptr getConfiguration() const; void setConfiguration(std::shared_ptr configuration); @@ -57,6 +63,7 @@ public: protected: + ResponseHeadersHandlerType m_ResponseHeadersHandler; std::shared_ptr m_Configuration; }; diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-source.mustache index b6f58e86525f..e4e6f004c3dd 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-source.mustache @@ -29,6 +29,14 @@ ApiClient::~ApiClient() { } +const ApiClient::ResponseHeadersHandlerType& ApiClient::getResponseHeadersHandler() const { + return m_ResponseHeadersHandler; +} + +void ApiClient::setResponseHeadersHandler(const ResponseHeadersHandlerType& responseHeadersHandler) { + m_ResponseHeadersHandler = responseHeadersHandler; +} + std::shared_ptr ApiClient::getConfiguration() const { return m_Configuration; diff --git a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION index e24c1f857e01..6d94c9c2e12a 100644 --- a/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION +++ b/samples/client/petstore/cpp-restsdk/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.3-SNAPSHOT \ No newline at end of file +3.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.cpp b/samples/client/petstore/cpp-restsdk/ApiClient.cpp index 5df6b675e361..40243cd83360 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiClient.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -40,6 +40,14 @@ ApiClient::~ApiClient() { } +const ApiClient::ResponseHeadersHandlerType& ApiClient::getResponseHeadersHandler() const { + return m_ResponseHeadersHandler; +} + +void ApiClient::setResponseHeadersHandler(const ResponseHeadersHandlerType& responseHeadersHandler) { + m_ResponseHeadersHandler = responseHeadersHandler; +} + std::shared_ptr ApiClient::getConfiguration() const { return m_Configuration; diff --git a/samples/client/petstore/cpp-restsdk/ApiClient.h b/samples/client/petstore/cpp-restsdk/ApiClient.h index 8aea53688c5d..50b1cbffd942 100644 --- a/samples/client/petstore/cpp-restsdk/ApiClient.h +++ b/samples/client/petstore/cpp-restsdk/ApiClient.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -43,6 +44,11 @@ public: ApiClient( std::shared_ptr configuration = nullptr ); virtual ~ApiClient(); + typedef std::function ResponseHeadersHandlerType; + + const ResponseHeadersHandlerType& getResponseHeadersHandler() const; + void setResponseHeadersHandler(const ResponseHeadersHandlerType& responseHeadersHandler); + std::shared_ptr getConfiguration() const; void setConfiguration(std::shared_ptr configuration); @@ -68,6 +74,7 @@ public: protected: + ResponseHeadersHandlerType m_ResponseHeadersHandler; std::shared_ptr m_Configuration; }; diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp index abc0510b1926..95a6c5fc1b95 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h index 35b7892cbf5c..218c92b403f5 100644 --- a/samples/client/petstore/cpp-restsdk/ApiConfiguration.h +++ b/samples/client/petstore/cpp-restsdk/ApiConfiguration.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.cpp b/samples/client/petstore/cpp-restsdk/ApiException.cpp index f8206bc56c94..f1eb81c21447 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.cpp +++ b/samples/client/petstore/cpp-restsdk/ApiException.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ApiException.h b/samples/client/petstore/cpp-restsdk/ApiException.h index 7de8a64e96de..4958f09ad74f 100644 --- a/samples/client/petstore/cpp-restsdk/ApiException.h +++ b/samples/client/petstore/cpp-restsdk/ApiException.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.cpp b/samples/client/petstore/cpp-restsdk/HttpContent.cpp index c64fc2e26ee0..3f94dd84a97b 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.cpp +++ b/samples/client/petstore/cpp-restsdk/HttpContent.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/HttpContent.h b/samples/client/petstore/cpp-restsdk/HttpContent.h index a5edc34dd2a3..9cc76d8d1144 100644 --- a/samples/client/petstore/cpp-restsdk/HttpContent.h +++ b/samples/client/petstore/cpp-restsdk/HttpContent.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/IHttpBody.h b/samples/client/petstore/cpp-restsdk/IHttpBody.h index 592a3e3bcf7d..c5e173490f7b 100644 --- a/samples/client/petstore/cpp-restsdk/IHttpBody.h +++ b/samples/client/petstore/cpp-restsdk/IHttpBody.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.cpp b/samples/client/petstore/cpp-restsdk/JsonBody.cpp index f058afe6e086..276f83abbb2a 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.cpp +++ b/samples/client/petstore/cpp-restsdk/JsonBody.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/JsonBody.h b/samples/client/petstore/cpp-restsdk/JsonBody.h index 028dd07bfcc1..ada2e9eb11ba 100644 --- a/samples/client/petstore/cpp-restsdk/JsonBody.h +++ b/samples/client/petstore/cpp-restsdk/JsonBody.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.cpp b/samples/client/petstore/cpp-restsdk/ModelBase.cpp index 4abda808cb02..8027f547dea9 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.cpp +++ b/samples/client/petstore/cpp-restsdk/ModelBase.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/ModelBase.h b/samples/client/petstore/cpp-restsdk/ModelBase.h index e35de11673e9..430b2f73621d 100644 --- a/samples/client/petstore/cpp-restsdk/ModelBase.h +++ b/samples/client/petstore/cpp-restsdk/ModelBase.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp index 009c333ff066..af9778625267 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/MultipartFormData.h b/samples/client/petstore/cpp-restsdk/MultipartFormData.h index 50e8216f67a8..3cc52c4990cf 100644 --- a/samples/client/petstore/cpp-restsdk/MultipartFormData.h +++ b/samples/client/petstore/cpp-restsdk/MultipartFormData.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.cpp b/samples/client/petstore/cpp-restsdk/Object.cpp index 4edce53d7912..ad213d11ad48 100644 --- a/samples/client/petstore/cpp-restsdk/Object.cpp +++ b/samples/client/petstore/cpp-restsdk/Object.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/Object.h b/samples/client/petstore/cpp-restsdk/Object.h index 1944f397bdad..fe7c8669d509 100644 --- a/samples/client/petstore/cpp-restsdk/Object.h +++ b/samples/client/petstore/cpp-restsdk/Object.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index 63c11ca9b44b..f160df54db71 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -123,6 +123,11 @@ pplx::task PetApi::addPet(std::shared_ptr pet) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -224,6 +229,11 @@ pplx::task PetApi::deletePet(int64_t petId, boost::optionalcallApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -325,6 +335,11 @@ pplx::task>> PetApi::findPetsByStatus(std::vect return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -451,6 +466,11 @@ pplx::task>> PetApi::findPetsByTags(std::vector return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -581,6 +601,11 @@ pplx::task> PetApi::getPetById(int64_t petId) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -718,6 +743,11 @@ pplx::task PetApi::updatePet(std::shared_ptr pet) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -824,6 +854,11 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optionalcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -931,6 +966,11 @@ pplx::task> PetApi::uploadFile(int64_t petId, boost return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.h b/samples/client/petstore/cpp-restsdk/api/PetApi.h index 81662ef543a2..b6c684e162a1 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.h +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -25,7 +25,7 @@ #include "HttpContent.h" #include "Pet.h" #include - +#include "../ModelBase.h" #include @@ -63,7 +63,7 @@ public: /// /// /// Pet id to delete - /// (optional, default to utility::conversions::to_string_t("")) + /// (optional) pplx::task deletePet( int64_t petId, boost::optional apiKey diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index 36f501f54b66..31bd5ccd88a6 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -99,6 +99,11 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -202,6 +207,11 @@ pplx::task> StoreApi::getInventory() return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -322,6 +332,11 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -457,6 +472,11 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.h b/samples/client/petstore/cpp-restsdk/api/StoreApi.h index 1c609872c389..3fded80876d2 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.h +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -24,7 +24,7 @@ #include "Order.h" #include #include - +#include "../ModelBase.h" #include diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index d62ba1535440..64600cfcaead 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -119,6 +119,11 @@ pplx::task UserApi::createUser(std::shared_ptr user) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -239,6 +244,11 @@ pplx::task UserApi::createUsersWithArrayInput(std::vectorcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -359,6 +369,11 @@ pplx::task UserApi::createUsersWithListInput(std::vectorcallApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -454,6 +469,11 @@ pplx::task UserApi::deleteUser(utility::string_t username) return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -551,6 +571,11 @@ pplx::task> UserApi::getUserByName(utility::string_t usern return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -676,6 +701,11 @@ pplx::task UserApi::loginUser(utility::string_t username, uti return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -793,6 +823,11 @@ pplx::task UserApi::logoutUser() return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK @@ -909,6 +944,11 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) .then([=](web::http::http_response localVarResponse) { + if (m_ApiClient->getResponseHeadersHandler()) + { + m_ApiClient->getResponseHeadersHandler()(localVarResponse.headers()); + } + // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.h b/samples/client/petstore/cpp-restsdk/api/UserApi.h index 3f5ef26bd18c..de94d75ff562 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.h +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ @@ -24,7 +24,7 @@ #include "User.h" #include #include - +#include "../ModelBase.h" #include diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp index 2ed8acfacedf..8160c7dcdc32 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h index a65b2e83fc5f..26aa0ae30b69 100644 --- a/samples/client/petstore/cpp-restsdk/model/ApiResponse.h +++ b/samples/client/petstore/cpp-restsdk/model/ApiResponse.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.cpp b/samples/client/petstore/cpp-restsdk/model/Category.cpp index 68baf3c6bb9a..8b74c5bb5913 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Category.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Category.h b/samples/client/petstore/cpp-restsdk/model/Category.h index 0f3f9d55a325..a6fc63beaec2 100644 --- a/samples/client/petstore/cpp-restsdk/model/Category.h +++ b/samples/client/petstore/cpp-restsdk/model/Category.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.cpp b/samples/client/petstore/cpp-restsdk/model/Order.cpp index 9e4381731357..609527560584 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Order.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Order.h b/samples/client/petstore/cpp-restsdk/model/Order.h index b7ea4c528c19..b679d1eb1276 100644 --- a/samples/client/petstore/cpp-restsdk/model/Order.h +++ b/samples/client/petstore/cpp-restsdk/model/Order.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/model/Pet.cpp index 8b6e77835f7d..47e262d79df6 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Pet.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Pet.h b/samples/client/petstore/cpp-restsdk/model/Pet.h index 55a1b86af411..7a932c2ad915 100644 --- a/samples/client/petstore/cpp-restsdk/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/model/Pet.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.cpp b/samples/client/petstore/cpp-restsdk/model/Tag.cpp index d60ec0ecc428..3e19f14a9e6d 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.cpp +++ b/samples/client/petstore/cpp-restsdk/model/Tag.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/Tag.h b/samples/client/petstore/cpp-restsdk/model/Tag.h index 6ac7947b63c7..e290b90b94b9 100644 --- a/samples/client/petstore/cpp-restsdk/model/Tag.h +++ b/samples/client/petstore/cpp-restsdk/model/Tag.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.cpp b/samples/client/petstore/cpp-restsdk/model/User.cpp index ced6a96347db..72e65d89fe33 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.cpp +++ b/samples/client/petstore/cpp-restsdk/model/User.cpp @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/client/petstore/cpp-restsdk/model/User.h b/samples/client/petstore/cpp-restsdk/model/User.h index 1a177f06832c..30f78e134a42 100644 --- a/samples/client/petstore/cpp-restsdk/model/User.h +++ b/samples/client/petstore/cpp-restsdk/model/User.h @@ -4,7 +4,7 @@ * * OpenAPI spec version: 1.0.0 * - * NOTE: This class is auto generated by OpenAPI-Generator 3.3.3-SNAPSHOT. + * NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT. * https://openapi-generator.tech * Do not edit the class manually. */ From e91d6d735dc02bc0e7c260cc570210c3b153e709 Mon Sep 17 00:00:00 2001 From: Erik Timmers Date: Fri, 23 Nov 2018 16:03:07 +0100 Subject: [PATCH 11/14] [elm] Add support for nested Lists & Dicts (#1528) And rename Union Types to Custom Types and Aliases to Records. --- .../codegen/languages/ElmClientCodegen.java | 7 ++--- .../{union.mustache => customType.mustache} | 2 +- ...er.mustache => customTypeDecoder.mustache} | 2 +- ...er.mustache => customTypeEncoder.mustache} | 2 +- .../main/resources/elm/fieldDecoder.mustache | 1 - .../main/resources/elm/fieldEncoder.mustache | 1 - .../src/main/resources/elm/model.mustache | 4 +-- .../resources/elm/modelTypeAlias.mustache | 26 ------------------- .../resources/elm/modelTypeCustom.mustache | 7 +++++ .../resources/elm/modelTypeRecord.mustache | 26 +++++++++++++++++++ .../resources/elm/modelTypeUnion.mustache | 7 ----- ...ecoder.mustache => recordDecoder.mustache} | 2 +- ...ncoder.mustache => recordEncoder.mustache} | 2 +- .../resources/elm/recordFieldDecoder.mustache | 1 + .../resources/elm/recordFieldEncoder.mustache | 1 + .../resources/elm/recordFieldType.mustache | 1 + .../elm/recordFieldValueDecoder.mustache | 1 + .../elm/recordFieldValueEncoder.mustache | 1 + .../elm-0.18/.openapi-generator/VERSION | 2 +- .../petstore/elm/.openapi-generator/VERSION | 2 +- 20 files changed, 51 insertions(+), 47 deletions(-) rename modules/openapi-generator/src/main/resources/elm/{union.mustache => customType.mustache} (67%) rename modules/openapi-generator/src/main/resources/elm/{unionDecoder.mustache => customTypeDecoder.mustache} (97%) rename modules/openapi-generator/src/main/resources/elm/{unionEncoder.mustache => customTypeEncoder.mustache} (68%) delete mode 100644 modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache delete mode 100644 modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache delete mode 100644 modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/modelTypeCustom.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/modelTypeRecord.mustache delete mode 100644 modules/openapi-generator/src/main/resources/elm/modelTypeUnion.mustache rename modules/openapi-generator/src/main/resources/elm/{aliasDecoder.mustache => recordDecoder.mustache} (81%) rename modules/openapi-generator/src/main/resources/elm/{aliasEncoder.mustache => recordEncoder.mustache} (84%) create mode 100644 modules/openapi-generator/src/main/resources/elm/recordFieldDecoder.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/recordFieldEncoder.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/recordFieldType.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/recordFieldValueDecoder.mustache create mode 100644 modules/openapi-generator/src/main/resources/elm/recordFieldValueEncoder.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java index 54be2fc33b11..53da359a3b84 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ElmClientCodegen.java @@ -66,7 +66,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { private static final String ENCODER = "elmEncoder"; private static final String DECODER = "elmDecoder"; private static final String DISCRIMINATOR_NAME = "discriminatorName"; - private static final String UNION_TYPE = "elmUnionType"; + private static final String CUSTOM_TYPE = "elmCustomType"; protected String packageName = "openapi"; protected String packageVersion = "1.0.0"; @@ -123,6 +123,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { "Dict", "Float", "Int", + "List", "String") ); @@ -352,7 +353,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { CodegenModel cm = (CodegenModel) mo.get("model"); if (cm.isEnum) { addEncoderAndDecoder(cm.vendorExtensions, cm.classname, DataTypeExposure.EXPOSED); - cm.vendorExtensions.put(UNION_TYPE, cm.classname); + cm.vendorExtensions.put(CUSTOM_TYPE, cm.classname); } else if (cm.isAlias) { addEncoderAndDecoder(cm.vendorExtensions, cm.dataType, DataTypeExposure.EXPOSED); } @@ -578,7 +579,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig { if (property.isEnum) { addEncoderAndDecoder(property.vendorExtensions, property.baseName, DataTypeExposure.INTERNAL); - property.vendorExtensions.put(UNION_TYPE, property.datatypeWithEnum); + property.vendorExtensions.put(CUSTOM_TYPE, property.datatypeWithEnum); } else { final boolean isPrimitiveType = property.isMapContainer ? isPrimitiveDataType(property.dataType) : property.isPrimitiveType; addEncoderAndDecoder(property.vendorExtensions, property.dataType, isPrimitiveType ? DataTypeExposure.PRIMITIVE : DataTypeExposure.EXTERNAL); diff --git a/modules/openapi-generator/src/main/resources/elm/union.mustache b/modules/openapi-generator/src/main/resources/elm/customType.mustache similarity index 67% rename from modules/openapi-generator/src/main/resources/elm/union.mustache rename to modules/openapi-generator/src/main/resources/elm/customType.mustache index 25dc6d89cdeb..282c1808ac4b 100644 --- a/modules/openapi-generator/src/main/resources/elm/union.mustache +++ b/modules/openapi-generator/src/main/resources/elm/customType.mustache @@ -1,4 +1,4 @@ -type {{#vendorExtensions}}{{elmUnionType}}{{/vendorExtensions}} +type {{#vendorExtensions}}{{elmCustomType}}{{/vendorExtensions}} {{#allowableValues}} {{#enumVars}} {{#-first}}={{/-first}}{{^-first}}|{{/-first}} {{name}} diff --git a/modules/openapi-generator/src/main/resources/elm/unionDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/customTypeDecoder.mustache similarity index 97% rename from modules/openapi-generator/src/main/resources/elm/unionDecoder.mustache rename to modules/openapi-generator/src/main/resources/elm/customTypeDecoder.mustache index 4051dce9f6ea..51847f262337 100644 --- a/modules/openapi-generator/src/main/resources/elm/unionDecoder.mustache +++ b/modules/openapi-generator/src/main/resources/elm/customTypeDecoder.mustache @@ -1,4 +1,4 @@ -{{vendorExtensions.elmDecoder}} : Decoder {{vendorExtensions.elmUnionType}} +{{vendorExtensions.elmDecoder}} : Decoder {{vendorExtensions.elmCustomType}} {{vendorExtensions.elmDecoder}} = Decode.string |> Decode.andThen diff --git a/modules/openapi-generator/src/main/resources/elm/unionEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/customTypeEncoder.mustache similarity index 68% rename from modules/openapi-generator/src/main/resources/elm/unionEncoder.mustache rename to modules/openapi-generator/src/main/resources/elm/customTypeEncoder.mustache index 2c286154f07e..e5dbfbe02a4b 100644 --- a/modules/openapi-generator/src/main/resources/elm/unionEncoder.mustache +++ b/modules/openapi-generator/src/main/resources/elm/customTypeEncoder.mustache @@ -1,4 +1,4 @@ -{{vendorExtensions.elmEncoder}} : {{vendorExtensions.elmUnionType}} -> Encode.Value +{{vendorExtensions.elmEncoder}} : {{vendorExtensions.elmCustomType}} -> Encode.Value {{vendorExtensions.elmEncoder}} model = case model of {{#allowableValues}} diff --git a/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache deleted file mode 100644 index c40e55b73903..000000000000 --- a/modules/openapi-generator/src/main/resources/elm/fieldDecoder.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#required}}required{{/required}}{{^required}}optional{{/required}} "{{baseName}}" {{^required}}(Decode.nullable {{/required}}{{#isMapContainer}}(Decode.dict {{/isMapContainer}}{{#isListContainer}}(Decode.list {{/isListContainer}}{{vendorExtensions.elmDecoder}}{{#isContainer}}){{/isContainer}}{{^required}}){{/required}}{{^required}} {{{defaultValue}}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache deleted file mode 100644 index 58bd131abbf4..000000000000 --- a/modules/openapi-generator/src/main/resources/elm/fieldEncoder.mustache +++ /dev/null @@ -1 +0,0 @@ -( "{{baseName}}", {{#discriminatorValue}}Encode.string "{{discriminatorValue}}"{{/discriminatorValue}}{{^discriminatorValue}}{{^required}}Maybe.withDefault Encode.null (Maybe.map {{/required}}{{#isMapContainer}}(Encode.dict identity {{/isMapContainer}}{{#isListContainer}}(Encode.list {{#isElm018}}<< List.map {{/isElm018}}{{/isListContainer}}{{vendorExtensions.elmEncoder}}{{#isContainer}}){{/isContainer}} model.{{name}}{{^required}}){{/required}}{{/discriminatorValue}} ) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/model.mustache b/modules/openapi-generator/src/main/resources/elm/model.mustache index 4fef4dd19d53..a0868e90286d 100644 --- a/modules/openapi-generator/src/main/resources/elm/model.mustache +++ b/modules/openapi-generator/src/main/resources/elm/model.mustache @@ -1,6 +1,6 @@ {{>licenseInfo}} -module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmUnionType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encoder{{/model}}{{/models}}) +module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmCustomType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encoder{{/model}}{{/models}}) {{>imports}}import Dict exposing (Dict) import Json.Decode as Decode exposing (Decoder) @@ -14,6 +14,6 @@ import Json.Encode as Encode {-| {{{description}}} -} {{/description}} -{{#isEnum}}{{>modelTypeUnion}}{{/isEnum}}{{^isEnum}}{{#discriminator}}{{>modelTypeDiscriminator}}{{/discriminator}}{{^discriminator}}{{#isAlias}}{{>modelTypePrimitive}}{{/isAlias}}{{^isAlias}}{{#isArrayModel}}{{>modelTypeArray}}{{/isArrayModel}}{{^isArrayModel}}{{>modelTypeAlias}}{{/isArrayModel}}{{/isAlias}}{{/discriminator}}{{/isEnum}} +{{#isEnum}}{{>modelTypeCustom}}{{/isEnum}}{{^isEnum}}{{#discriminator}}{{>modelTypeDiscriminator}}{{/discriminator}}{{^discriminator}}{{#isAlias}}{{>modelTypePrimitive}}{{/isAlias}}{{^isAlias}}{{#isArrayModel}}{{>modelTypeArray}}{{/isArrayModel}}{{^isArrayModel}}{{>modelTypeRecord}}{{/isArrayModel}}{{/isAlias}}{{/discriminator}}{{/isEnum}} {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache b/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache deleted file mode 100644 index 1a3341779007..000000000000 --- a/modules/openapi-generator/src/main/resources/elm/modelTypeAlias.mustache +++ /dev/null @@ -1,26 +0,0 @@ -type alias {{classname}} = - { {{#allVars}}{{^-first}} , {{/-first}}{{name}} : {{^required}}Maybe {{#isContainer}}({{/isContainer}}{{/required}}{{#isMapContainer}}Dict String {{/isMapContainer}}{{#isListContainer}}List {{/isListContainer}}{{#isEnum}}{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{dataType}}{{/isEnum}}{{^required}}{{#isContainer}}){{/isContainer}}{{/required}} -{{/allVars}} } -{{#vars}} -{{#isEnum}} - - -{{>union}} -{{/isEnum}} -{{/vars}} - - -{{>aliasDecoder}} - - -{{>aliasEncoder}} -{{#vars}} -{{#isEnum}} - - -{{>unionDecoder}} - - -{{>unionEncoder}} -{{/isEnum}} -{{/vars}} diff --git a/modules/openapi-generator/src/main/resources/elm/modelTypeCustom.mustache b/modules/openapi-generator/src/main/resources/elm/modelTypeCustom.mustache new file mode 100644 index 000000000000..cc062e430310 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/modelTypeCustom.mustache @@ -0,0 +1,7 @@ +{{>customType}} + + +{{>customTypeDecoder}} + + +{{>customTypeEncoder}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/modelTypeRecord.mustache b/modules/openapi-generator/src/main/resources/elm/modelTypeRecord.mustache new file mode 100644 index 000000000000..cb2e5185791a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/modelTypeRecord.mustache @@ -0,0 +1,26 @@ +type alias {{classname}} = + { {{#allVars}}{{^-first}} , {{/-first}}{{name}} : {{^required}}{{^isNullable}}Maybe ({{/isNullable}}{{/required}}{{>recordFieldType}}{{^required}}{{^isNullable}}){{/isNullable}}{{/required}} +{{/allVars}} } +{{#vars}} +{{#isEnum}} + + +{{>customType}} +{{/isEnum}} +{{/vars}} + + +{{>recordDecoder}} + + +{{>recordEncoder}} +{{#vars}} +{{#isEnum}} + + +{{>customTypeDecoder}} + + +{{>customTypeEncoder}} +{{/isEnum}} +{{/vars}} diff --git a/modules/openapi-generator/src/main/resources/elm/modelTypeUnion.mustache b/modules/openapi-generator/src/main/resources/elm/modelTypeUnion.mustache deleted file mode 100644 index 4e353e849769..000000000000 --- a/modules/openapi-generator/src/main/resources/elm/modelTypeUnion.mustache +++ /dev/null @@ -1,7 +0,0 @@ -{{>union}} - - -{{>unionDecoder}} - - -{{>unionEncoder}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/aliasDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordDecoder.mustache similarity index 81% rename from modules/openapi-generator/src/main/resources/elm/aliasDecoder.mustache rename to modules/openapi-generator/src/main/resources/elm/recordDecoder.mustache index c03d1c5b74f6..f9b2e9076158 100644 --- a/modules/openapi-generator/src/main/resources/elm/aliasDecoder.mustache +++ b/modules/openapi-generator/src/main/resources/elm/recordDecoder.mustache @@ -2,5 +2,5 @@ decoder : Decoder {{classname}} decoder = {{#isElm018}}decode{{/isElm018}}{{#isElm019}}Decode.succeed{{/isElm019}} {{classname}} {{#allVars}} - |> {{>fieldDecoder}} + |> {{>recordFieldDecoder}} {{/allVars}} diff --git a/modules/openapi-generator/src/main/resources/elm/aliasEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordEncoder.mustache similarity index 84% rename from modules/openapi-generator/src/main/resources/elm/aliasEncoder.mustache rename to modules/openapi-generator/src/main/resources/elm/recordEncoder.mustache index b4435dfb03d2..af4815e01563 100644 --- a/modules/openapi-generator/src/main/resources/elm/aliasEncoder.mustache +++ b/modules/openapi-generator/src/main/resources/elm/recordEncoder.mustache @@ -2,6 +2,6 @@ encoder : {{#vendorExtensions.discriminatorName}}String -> {{/vendorExtensions.d encoder {{#vendorExtensions.discriminatorName}}tag {{/vendorExtensions.discriminatorName}}model = Encode.object {{#allVars}} - {{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>fieldEncoder}} + {{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>recordFieldEncoder}} {{/allVars}}{{#vendorExtensions.discriminatorName}} , ( "{{{vendorExtensions.discriminatorName}}}", Encode.string tag ){{/vendorExtensions.discriminatorName}} ] diff --git a/modules/openapi-generator/src/main/resources/elm/recordFieldDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordFieldDecoder.mustache new file mode 100644 index 000000000000..9a9b7ee08567 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/recordFieldDecoder.mustache @@ -0,0 +1 @@ +{{#required}}required{{/required}}{{^required}}optional{{/required}} "{{baseName}}" {{^required}}{{^isNullable}}(Decode.nullable {{/isNullable}}{{/required}}{{>recordFieldValueDecoder}}{{^required}}{{^isNullable}}) {{{defaultValue}}}{{/isNullable}}{{/required}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/recordFieldEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordFieldEncoder.mustache new file mode 100644 index 000000000000..4bfef791c487 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/recordFieldEncoder.mustache @@ -0,0 +1 @@ +( "{{baseName}}", {{#discriminatorValue}}Encode.string "{{discriminatorValue}}"{{/discriminatorValue}}{{^discriminatorValue}}{{^required}}{{^isNullable}}Maybe.withDefault Encode.null (Maybe.map {{/isNullable}}{{/required}}{{>recordFieldValueEncoder}} model.{{name}}{{^required}}{{^isNullable}}){{/isNullable}}{{/required}}{{/discriminatorValue}} ) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/recordFieldType.mustache b/modules/openapi-generator/src/main/resources/elm/recordFieldType.mustache new file mode 100644 index 000000000000..bbfefae18e81 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/recordFieldType.mustache @@ -0,0 +1 @@ +{{#isNullable}}(Maybe {{/isNullable}}{{#isContainer}}({{#isListContainer}}List{{/isListContainer}}{{#isMapContainer}}Dict String{{/isMapContainer}} {{#items}}{{>recordFieldType}}{{/items}}){{/isContainer}}{{^isContainer}}{{#isEnum}}{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{dataType}}{{/isEnum}}{{/isContainer}}{{#isNullable}}){{/isNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/recordFieldValueDecoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordFieldValueDecoder.mustache new file mode 100644 index 000000000000..03a57989f134 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/recordFieldValueDecoder.mustache @@ -0,0 +1 @@ +{{#isNullable}}(Decode.nullable {{/isNullable}}{{#isContainer}}({{#isListContainer}}Decode.list{{/isListContainer}}{{#isMapContainer}}Decode.dict{{/isMapContainer}} {{#items}}{{>recordFieldValueDecoder}}{{/items}}){{/isContainer}}{{^isContainer}}{{vendorExtensions.elmDecoder}}{{/isContainer}}{{#isNullable}}) {{{defaultValue}}}{{/isNullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/elm/recordFieldValueEncoder.mustache b/modules/openapi-generator/src/main/resources/elm/recordFieldValueEncoder.mustache new file mode 100644 index 000000000000..88a3d811a032 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/elm/recordFieldValueEncoder.mustache @@ -0,0 +1 @@ +{{#isNullable}}Maybe.withDefault Encode.null (Maybe.map {{/isNullable}}{{#isContainer}}({{#isListContainer}}Encode.list{{#isElm018}} << List.map{{/isElm018}}{{/isListContainer}}{{#isMapContainer}}Encode.dict identity{{/isMapContainer}} {{#items}}{{>recordFieldValueEncoder}}{{/items}}{{/isContainer}}{{^isContainer}}{{vendorExtensions.elmEncoder}}{{/isContainer}}{{#isContainer}}){{/isContainer}}{{#isNullable}}){{/isNullable}} \ No newline at end of file diff --git a/samples/client/petstore/elm-0.18/.openapi-generator/VERSION b/samples/client/petstore/elm-0.18/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/elm-0.18/.openapi-generator/VERSION +++ b/samples/client/petstore/elm-0.18/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/elm/.openapi-generator/VERSION b/samples/client/petstore/elm/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/elm/.openapi-generator/VERSION +++ b/samples/client/petstore/elm/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file From 0ba92783084d1f31e0e4155344d1fed0115b60b8 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Sat, 24 Nov 2018 09:42:09 +0100 Subject: [PATCH 12/14] #1506 Bump Zone.js to remove warnings when using angular >=6. (#1522) * 1506 allow zonejs 0.7.x and 0.8.x to support a wider range of angular versions * #1506 Removed zone.js as peer since it comes with angular itself * #1506 Removed zone.js as peer since it comes with angular itself --- .../src/main/resources/typescript-angular/package.mustache | 5 ++--- .../client/petstore/typescript-angular-v2/npm/package.json | 5 ++--- .../client/petstore/typescript-angular-v4.3/npm/package.json | 5 ++--- .../client/petstore/typescript-angular-v4/npm/package.json | 5 ++--- .../builds/with-npm/package.json | 5 ++--- .../builds/with-npm/package.json | 5 ++--- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache index 9ecc2a8265ad..99b540f2bc7c 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/package.mustache @@ -29,8 +29,7 @@ "@angular/compiler": "^{{ngVersion}}", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "{{#useRxJS6}}^6.1.0{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}", - "zone.js": "^0.7.6" + "rxjs": "{{#useRxJS6}}^6.1.0{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}" }, "devDependencies": { "@angular/compiler-cli": "^{{ngVersion}}", @@ -42,7 +41,7 @@ "ng-packagr": {{#useOldNgPackagr}}"^1.6.0"{{/useOldNgPackagr}}{{^useOldNgPackagr}}"^2.4.1"{{/useOldNgPackagr}},{{/useNgPackagr}} "reflect-metadata": "^0.1.3", "rxjs": "{{#useRxJS6}}^6.1.0{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} diff --git a/samples/client/petstore/typescript-angular-v2/npm/package.json b/samples/client/petstore/typescript-angular-v2/npm/package.json index 6afdfd0caa2a..58a0a48dc8ad 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/package.json +++ b/samples/client/petstore/typescript-angular-v2/npm/package.json @@ -22,8 +22,7 @@ "@angular/compiler": "^2.0.0", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "^5.4.0", - "zone.js": "^0.7.6" + "rxjs": "^5.4.0" }, "devDependencies": { "@angular/compiler-cli": "^2.0.0", @@ -34,7 +33,7 @@ "@angular/platform-browser": "^2.0.0", "reflect-metadata": "^0.1.3", "rxjs": "^5.4.0", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }, "publishConfig": { diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/package.json b/samples/client/petstore/typescript-angular-v4.3/npm/package.json index 39536b495e5c..f14235ef102a 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/package.json +++ b/samples/client/petstore/typescript-angular-v4.3/npm/package.json @@ -18,8 +18,7 @@ "@angular/compiler": "^4.3.0", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "^5.4.0", - "zone.js": "^0.7.6" + "rxjs": "^5.4.0" }, "devDependencies": { "@angular/compiler-cli": "^4.3.0", @@ -31,7 +30,7 @@ "ng-packagr": "^1.6.0", "reflect-metadata": "^0.1.3", "rxjs": "^5.4.0", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }, "publishConfig": { diff --git a/samples/client/petstore/typescript-angular-v4/npm/package.json b/samples/client/petstore/typescript-angular-v4/npm/package.json index 55127c56b74d..6ca7b3abf9ef 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/package.json +++ b/samples/client/petstore/typescript-angular-v4/npm/package.json @@ -18,8 +18,7 @@ "@angular/compiler": "^4.0.0", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "^5.4.0", - "zone.js": "^0.7.6" + "rxjs": "^5.4.0" }, "devDependencies": { "@angular/compiler-cli": "^4.0.0", @@ -31,7 +30,7 @@ "ng-packagr": "^1.6.0", "reflect-metadata": "^0.1.3", "rxjs": "^5.4.0", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }, "publishConfig": { diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/package.json b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/package.json index 40e9973f9a93..789d75f6260b 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/package.json +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/package.json @@ -18,8 +18,7 @@ "@angular/compiler": "^6.0.0", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "^6.1.0", - "zone.js": "^0.7.6" + "rxjs": "^6.1.0" }, "devDependencies": { "@angular/compiler-cli": "^6.0.0", @@ -31,7 +30,7 @@ "ng-packagr": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "^6.1.0", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }, "publishConfig": { diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/package.json b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/package.json index 40e9973f9a93..789d75f6260b 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/package.json +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/package.json @@ -18,8 +18,7 @@ "@angular/compiler": "^6.0.0", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", - "rxjs": "^6.1.0", - "zone.js": "^0.7.6" + "rxjs": "^6.1.0" }, "devDependencies": { "@angular/compiler-cli": "^6.0.0", @@ -31,7 +30,7 @@ "ng-packagr": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "^6.1.0", - "zone.js": "^0.7.6", + "zone.js": "^0.7.6 || ^0.8.26", "typescript": ">=2.1.5 <2.8" }, "publishConfig": { From f8ada391c4a4fb0b104864bcd590299b29a52404 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 24 Nov 2018 16:42:32 +0800 Subject: [PATCH 13/14] Fix boolean value handling in HTTP request body (#1515) * fix boolean http body handling * fix typo in parameter name --- .../resources/Javascript/ApiClient.mustache | 2 +- .../Javascript/es6/ApiClient.mustache | 4 +- .../javascript-es6/.openapi-generator/VERSION | 2 +- .../client/petstore/javascript-es6/README.md | 1 + .../petstore/javascript-es6/docs/Category.md | 2 +- .../petstore/javascript-es6/docs/FakeApi.md | 55 ++++++++++++ .../petstore/javascript-es6/src/ApiClient.js | 4 +- .../javascript-es6/src/api/FakeApi.js | 67 +++++++++++++++ .../javascript-es6/src/model/Category.js | 11 ++- .../.openapi-generator/VERSION | 2 +- .../petstore/javascript-promise-es6/README.md | 1 + .../javascript-promise-es6/docs/Category.md | 2 +- .../javascript-promise-es6/docs/FakeApi.md | 54 ++++++++++++ .../javascript-promise-es6/src/ApiClient.js | 4 +- .../javascript-promise-es6/src/api/FakeApi.js | 79 ++++++++++++++++++ .../src/model/Category.js | 11 ++- .../.openapi-generator/VERSION | 2 +- .../petstore/javascript-promise/README.md | 1 + .../javascript-promise/docs/Category.md | 2 +- .../javascript-promise/docs/FakeApi.md | 54 ++++++++++++ .../javascript-promise/src/ApiClient.js | 4 +- .../src/api/AnotherFakeApi.js | 2 +- .../javascript-promise/src/api/FakeApi.js | 83 ++++++++++++++++++- .../src/api/FakeClassnameTags123Api.js | 2 +- .../javascript-promise/src/api/PetApi.js | 2 +- .../javascript-promise/src/api/StoreApi.js | 2 +- .../javascript-promise/src/api/UserApi.js | 2 +- .../petstore/javascript-promise/src/index.js | 2 +- .../src/model/AdditionalPropertiesClass.js | 2 +- .../javascript-promise/src/model/Animal.js | 2 +- .../src/model/AnimalFarm.js | 2 +- .../src/model/ApiResponse.js | 2 +- .../src/model/ArrayOfArrayOfNumberOnly.js | 2 +- .../src/model/ArrayOfNumberOnly.js | 2 +- .../javascript-promise/src/model/ArrayTest.js | 2 +- .../src/model/Capitalization.js | 2 +- .../javascript-promise/src/model/Cat.js | 2 +- .../javascript-promise/src/model/Category.js | 9 +- .../src/model/ClassModel.js | 2 +- .../javascript-promise/src/model/Client.js | 2 +- .../javascript-promise/src/model/Dog.js | 2 +- .../src/model/EnumArrays.js | 2 +- .../javascript-promise/src/model/EnumClass.js | 2 +- .../javascript-promise/src/model/EnumTest.js | 2 +- .../javascript-promise/src/model/File.js | 2 +- .../src/model/FileSchemaTestClass.js | 2 +- .../src/model/FormatTest.js | 2 +- .../src/model/HasOnlyReadOnly.js | 2 +- .../javascript-promise/src/model/List.js | 2 +- .../javascript-promise/src/model/MapTest.js | 2 +- ...dPropertiesAndAdditionalPropertiesClass.js | 2 +- .../src/model/Model200Response.js | 2 +- .../src/model/ModelReturn.js | 2 +- .../javascript-promise/src/model/Name.js | 2 +- .../src/model/NumberOnly.js | 2 +- .../javascript-promise/src/model/Order.js | 2 +- .../src/model/OuterComposite.js | 2 +- .../javascript-promise/src/model/OuterEnum.js | 2 +- .../javascript-promise/src/model/Pet.js | 2 +- .../src/model/ReadOnlyFirst.js | 2 +- .../src/model/SpecialModelName.js | 2 +- .../src/model/StringBooleanMap.js | 2 +- .../javascript-promise/src/model/Tag.js | 2 +- .../javascript-promise/src/model/User.js | 2 +- .../javascript/.openapi-generator/VERSION | 2 +- samples/client/petstore/javascript/README.md | 1 + .../petstore/javascript/docs/Category.md | 2 +- .../petstore/javascript/docs/FakeApi.md | 56 +++++++++++++ .../petstore/javascript/src/ApiClient.js | 4 +- .../javascript/src/api/AnotherFakeApi.js | 2 +- .../petstore/javascript/src/api/FakeApi.js | 71 +++++++++++++++- .../src/api/FakeClassnameTags123Api.js | 2 +- .../petstore/javascript/src/api/PetApi.js | 2 +- .../petstore/javascript/src/api/StoreApi.js | 2 +- .../petstore/javascript/src/api/UserApi.js | 2 +- .../client/petstore/javascript/src/index.js | 2 +- .../src/model/AdditionalPropertiesClass.js | 2 +- .../petstore/javascript/src/model/Animal.js | 2 +- .../javascript/src/model/AnimalFarm.js | 2 +- .../javascript/src/model/ApiResponse.js | 2 +- .../src/model/ArrayOfArrayOfNumberOnly.js | 2 +- .../javascript/src/model/ArrayOfNumberOnly.js | 2 +- .../javascript/src/model/ArrayTest.js | 2 +- .../javascript/src/model/Capitalization.js | 2 +- .../petstore/javascript/src/model/Cat.js | 2 +- .../petstore/javascript/src/model/Category.js | 9 +- .../javascript/src/model/ClassModel.js | 2 +- .../petstore/javascript/src/model/Client.js | 2 +- .../petstore/javascript/src/model/Dog.js | 2 +- .../javascript/src/model/EnumArrays.js | 2 +- .../javascript/src/model/EnumClass.js | 2 +- .../petstore/javascript/src/model/EnumTest.js | 2 +- .../petstore/javascript/src/model/File.js | 2 +- .../src/model/FileSchemaTestClass.js | 2 +- .../javascript/src/model/FormatTest.js | 2 +- .../javascript/src/model/HasOnlyReadOnly.js | 2 +- .../petstore/javascript/src/model/List.js | 2 +- .../petstore/javascript/src/model/MapTest.js | 2 +- ...dPropertiesAndAdditionalPropertiesClass.js | 2 +- .../javascript/src/model/Model200Response.js | 2 +- .../javascript/src/model/ModelReturn.js | 2 +- .../petstore/javascript/src/model/Name.js | 2 +- .../javascript/src/model/NumberOnly.js | 2 +- .../petstore/javascript/src/model/Order.js | 2 +- .../javascript/src/model/OuterComposite.js | 2 +- .../javascript/src/model/OuterEnum.js | 2 +- .../petstore/javascript/src/model/Pet.js | 2 +- .../javascript/src/model/ReadOnlyFirst.js | 2 +- .../javascript/src/model/SpecialModelName.js | 2 +- .../javascript/src/model/StringBooleanMap.js | 2 +- .../petstore/javascript/src/model/Tag.js | 2 +- .../petstore/javascript/src/model/User.js | 2 +- 112 files changed, 648 insertions(+), 117 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index 997e9446f0f1..b6bbc4737493 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -445,7 +445,7 @@ } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index f824d552fcec..49b92e21cae8 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -397,7 +397,7 @@ class ApiClient { } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } @@ -602,4 +602,4 @@ ApiClient.CollectionFormatEnum = { * @type {module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient} */{{/emitJSDoc}} ApiClient.instance = new ApiClient(); -export default ApiClient; \ No newline at end of file +export default ApiClient; diff --git a/samples/client/petstore/javascript-es6/.openapi-generator/VERSION b/samples/client/petstore/javascript-es6/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/javascript-es6/.openapi-generator/VERSION +++ b/samples/client/petstore/javascript-es6/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/javascript-es6/README.md b/samples/client/petstore/javascript-es6/README.md index 7674da7bb398..b4f29570532e 100644 --- a/samples/client/petstore/javascript-es6/README.md +++ b/samples/client/petstore/javascript-es6/README.md @@ -100,6 +100,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *OpenApiPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *OpenApiPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*OpenApiPetstore.FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *OpenApiPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *OpenApiPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *OpenApiPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case diff --git a/samples/client/petstore/javascript-es6/docs/Category.md b/samples/client/petstore/javascript-es6/docs/Category.md index e3f934442abc..5c333f8f61ff 100644 --- a/samples/client/petstore/javascript-es6/docs/Category.md +++ b/samples/client/petstore/javascript-es6/docs/Category.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **Number** | | [optional] -**name** | **String** | | [optional] +**name** | **String** | | [default to 'default-name'] diff --git a/samples/client/petstore/javascript-es6/docs/FakeApi.md b/samples/client/petstore/javascript-es6/docs/FakeApi.md index 0407a450fff4..1dea8f79698f 100644 --- a/samples/client/petstore/javascript-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-es6/docs/FakeApi.md @@ -13,6 +13,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -453,6 +454,60 @@ No authorization required - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined + +# **testGroupParameters** +> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let requiredStringGroup = 56; // Number | Required String in group parameters +let requiredBooleanGroup = true; // Boolean | Required Boolean in group parameters +let requiredInt64Group = 789; // Number | Required Integer in group parameters +let opts = { + 'stringGroup': 56, // Number | String in group parameters + 'booleanGroup': true, // Boolean | Boolean in group parameters + 'int64Group': 789 // Number | Integer in group parameters +}; +apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts, (error, data, response) => { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requiredStringGroup** | **Number**| Required String in group parameters | + **requiredBooleanGroup** | **Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **Number**| Required Integer in group parameters | + **stringGroup** | **Number**| String in group parameters | [optional] + **booleanGroup** | **Boolean**| Boolean in group parameters | [optional] + **int64Group** | **Number**| Integer in group parameters | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testInlineAdditionalProperties** > testInlineAdditionalProperties(requestBody) diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 5f0486a18417..369632309dc9 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -399,7 +399,7 @@ class ApiClient { } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } @@ -586,4 +586,4 @@ ApiClient.CollectionFormatEnum = { * @type {module:ApiClient} */ ApiClient.instance = new ApiClient(); -export default ApiClient; \ No newline at end of file +export default ApiClient; diff --git a/samples/client/petstore/javascript-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-es6/src/api/FakeApi.js index b559f3607816..49bbe41cb8ae 100644 --- a/samples/client/petstore/javascript-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-es6/src/api/FakeApi.js @@ -482,6 +482,73 @@ export default class FakeApi { ); } + /** + * Callback function to receive the result of the testGroupParameters operation. + * @callback module:api/FakeApi~testGroupParametersCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @param {module:api/FakeApi~testGroupParametersCallback} callback The callback function, accepting three arguments: error, data, response + */ + testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts, callback) { + opts = opts || {}; + let postBody = null; + + // verify the required parameter 'requiredStringGroup' is set + if (requiredStringGroup === undefined || requiredStringGroup === null) { + throw new Error("Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredBooleanGroup' is set + if (requiredBooleanGroup === undefined || requiredBooleanGroup === null) { + throw new Error("Missing the required parameter 'requiredBooleanGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredInt64Group' is set + if (requiredInt64Group === undefined || requiredInt64Group === null) { + throw new Error("Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); + } + + + let pathParams = { + }; + let queryParams = { + 'required_string_group': requiredStringGroup, + 'required_int64_group': requiredInt64Group, + 'string_group': opts['stringGroup'], + 'int64_group': opts['int64Group'] + }; + let headerParams = { + 'required_boolean_group': requiredBooleanGroup, + 'boolean_group': opts['booleanGroup'] + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = []; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake', 'DELETE', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the testInlineAdditionalProperties operation. * @callback module:api/FakeApi~testInlineAdditionalPropertiesCallback diff --git a/samples/client/petstore/javascript-es6/src/model/Category.js b/samples/client/petstore/javascript-es6/src/model/Category.js index fd0bf79dafb3..5540805591cb 100644 --- a/samples/client/petstore/javascript-es6/src/model/Category.js +++ b/samples/client/petstore/javascript-es6/src/model/Category.js @@ -22,10 +22,11 @@ class Category { /** * Constructs a new Category. * @alias module:model/Category + * @param name {String} */ - constructor() { + constructor(name) { - Category.initialize(this); + Category.initialize(this, name); } /** @@ -33,7 +34,8 @@ class Category { * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). * Only for internal use. */ - static initialize(obj) { + static initialize(obj, name) { + obj['name'] = name; } /** @@ -67,8 +69,9 @@ Category.prototype['id'] = undefined; /** * @member {String} name + * @default 'default-name' */ -Category.prototype['name'] = undefined; +Category.prototype['name'] = 'default-name'; diff --git a/samples/client/petstore/javascript-promise-es6/.openapi-generator/VERSION b/samples/client/petstore/javascript-promise-es6/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/javascript-promise-es6/.openapi-generator/VERSION +++ b/samples/client/petstore/javascript-promise-es6/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/javascript-promise-es6/README.md b/samples/client/petstore/javascript-promise-es6/README.md index 46b329b1bc4c..347e37e72ce8 100644 --- a/samples/client/petstore/javascript-promise-es6/README.md +++ b/samples/client/petstore/javascript-promise-es6/README.md @@ -98,6 +98,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *OpenApiPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *OpenApiPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*OpenApiPetstore.FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *OpenApiPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *OpenApiPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *OpenApiPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case diff --git a/samples/client/petstore/javascript-promise-es6/docs/Category.md b/samples/client/petstore/javascript-promise-es6/docs/Category.md index e3f934442abc..5c333f8f61ff 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/Category.md +++ b/samples/client/petstore/javascript-promise-es6/docs/Category.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **Number** | | [optional] -**name** | **String** | | [optional] +**name** | **String** | | [default to 'default-name'] diff --git a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md index a9e7e06545d0..16c96651c46f 100644 --- a/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise-es6/docs/FakeApi.md @@ -13,6 +13,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -444,6 +445,59 @@ No authorization required - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined + +# **testGroupParameters** +> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```javascript +import OpenApiPetstore from 'open_api_petstore'; + +let apiInstance = new OpenApiPetstore.FakeApi(); +let requiredStringGroup = 56; // Number | Required String in group parameters +let requiredBooleanGroup = true; // Boolean | Required Boolean in group parameters +let requiredInt64Group = 789; // Number | Required Integer in group parameters +let opts = { + 'stringGroup': 56, // Number | String in group parameters + 'booleanGroup': true, // Boolean | Boolean in group parameters + 'int64Group': 789 // Number | Integer in group parameters +}; +apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts).then(() => { + console.log('API called successfully.'); +}, (error) => { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requiredStringGroup** | **Number**| Required String in group parameters | + **requiredBooleanGroup** | **Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **Number**| Required Integer in group parameters | + **stringGroup** | **Number**| String in group parameters | [optional] + **booleanGroup** | **Boolean**| Boolean in group parameters | [optional] + **int64Group** | **Number**| Integer in group parameters | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testInlineAdditionalProperties** > testInlineAdditionalProperties(requestBody) diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index 4ce5c1e48d3c..2b2d43810cf0 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -392,7 +392,7 @@ class ApiClient { } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } @@ -578,4 +578,4 @@ ApiClient.CollectionFormatEnum = { * @type {module:ApiClient} */ ApiClient.instance = new ApiClient(); -export default ApiClient; \ No newline at end of file +export default ApiClient; diff --git a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js index 63650ef631b1..1f8bcf6cb3e6 100644 --- a/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise-es6/src/api/FakeApi.js @@ -552,6 +552,85 @@ export default class FakeApi { } + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) { + opts = opts || {}; + let postBody = null; + + // verify the required parameter 'requiredStringGroup' is set + if (requiredStringGroup === undefined || requiredStringGroup === null) { + throw new Error("Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredBooleanGroup' is set + if (requiredBooleanGroup === undefined || requiredBooleanGroup === null) { + throw new Error("Missing the required parameter 'requiredBooleanGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredInt64Group' is set + if (requiredInt64Group === undefined || requiredInt64Group === null) { + throw new Error("Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); + } + + + let pathParams = { + }; + let queryParams = { + 'required_string_group': requiredStringGroup, + 'required_int64_group': requiredInt64Group, + 'string_group': opts['stringGroup'], + 'int64_group': opts['int64Group'] + }; + let headerParams = { + 'required_boolean_group': requiredBooleanGroup, + 'boolean_group': opts['booleanGroup'] + }; + let formParams = { + }; + + let authNames = []; + let contentTypes = []; + let accepts = []; + let returnType = null; + + return this.apiClient.callApi( + '/fake', 'DELETE', + pathParams, queryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) { + return this.testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * test inline additionalProperties * @param {Object.} requestBody request body diff --git a/samples/client/petstore/javascript-promise-es6/src/model/Category.js b/samples/client/petstore/javascript-promise-es6/src/model/Category.js index fd0bf79dafb3..5540805591cb 100644 --- a/samples/client/petstore/javascript-promise-es6/src/model/Category.js +++ b/samples/client/petstore/javascript-promise-es6/src/model/Category.js @@ -22,10 +22,11 @@ class Category { /** * Constructs a new Category. * @alias module:model/Category + * @param name {String} */ - constructor() { + constructor(name) { - Category.initialize(this); + Category.initialize(this, name); } /** @@ -33,7 +34,8 @@ class Category { * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). * Only for internal use. */ - static initialize(obj) { + static initialize(obj, name) { + obj['name'] = name; } /** @@ -67,8 +69,9 @@ Category.prototype['id'] = undefined; /** * @member {String} name + * @default 'default-name' */ -Category.prototype['name'] = undefined; +Category.prototype['name'] = 'default-name'; diff --git a/samples/client/petstore/javascript-promise/.openapi-generator/VERSION b/samples/client/petstore/javascript-promise/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/javascript-promise/.openapi-generator/VERSION +++ b/samples/client/petstore/javascript-promise/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/javascript-promise/README.md b/samples/client/petstore/javascript-promise/README.md index 93b5f02e2239..59bf811bf4cf 100644 --- a/samples/client/petstore/javascript-promise/README.md +++ b/samples/client/petstore/javascript-promise/README.md @@ -122,6 +122,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *OpenApiPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *OpenApiPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*OpenApiPetstore.FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *OpenApiPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *OpenApiPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *OpenApiPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case diff --git a/samples/client/petstore/javascript-promise/docs/Category.md b/samples/client/petstore/javascript-promise/docs/Category.md index e3f934442abc..5c333f8f61ff 100644 --- a/samples/client/petstore/javascript-promise/docs/Category.md +++ b/samples/client/petstore/javascript-promise/docs/Category.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **Number** | | [optional] -**name** | **String** | | [optional] +**name** | **String** | | [default to 'default-name'] diff --git a/samples/client/petstore/javascript-promise/docs/FakeApi.md b/samples/client/petstore/javascript-promise/docs/FakeApi.md index d582de17b0a2..657796e7986a 100644 --- a/samples/client/petstore/javascript-promise/docs/FakeApi.md +++ b/samples/client/petstore/javascript-promise/docs/FakeApi.md @@ -13,6 +13,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -444,6 +445,59 @@ No authorization required - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined + +# **testGroupParameters** +> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```javascript +var OpenApiPetstore = require('open_api_petstore'); + +var apiInstance = new OpenApiPetstore.FakeApi(); +var requiredStringGroup = 56; // Number | Required String in group parameters +var requiredBooleanGroup = true; // Boolean | Required Boolean in group parameters +var requiredInt64Group = 789; // Number | Required Integer in group parameters +var opts = { + 'stringGroup': 56, // Number | String in group parameters + 'booleanGroup': true, // Boolean | Boolean in group parameters + 'int64Group': 789 // Number | Integer in group parameters +}; +apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts).then(function() { + console.log('API called successfully.'); +}, function(error) { + console.error(error); +}); + +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requiredStringGroup** | **Number**| Required String in group parameters | + **requiredBooleanGroup** | **Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **Number**| Required Integer in group parameters | + **stringGroup** | **Number**| String in group parameters | [optional] + **booleanGroup** | **Boolean**| Boolean in group parameters | [optional] + **int64Group** | **Number**| Integer in group parameters | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testInlineAdditionalProperties** > testInlineAdditionalProperties(requestBody) diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index fd9b273f1c40..0415153dac19 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -442,7 +442,7 @@ } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } diff --git a/samples/client/petstore/javascript-promise/src/api/AnotherFakeApi.js b/samples/client/petstore/javascript-promise/src/api/AnotherFakeApi.js index 4eda5bcca476..0cf76b87e8da 100644 --- a/samples/client/petstore/javascript-promise/src/api/AnotherFakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/AnotherFakeApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/api/FakeApi.js b/samples/client/petstore/javascript-promise/src/api/FakeApi.js index 9ce1caaeae75..1aa120ea66c8 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeApi.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -583,6 +583,87 @@ } + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response + */ + this.testGroupParametersWithHttpInfo = function(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) { + opts = opts || {}; + var postBody = null; + + // verify the required parameter 'requiredStringGroup' is set + if (requiredStringGroup === undefined || requiredStringGroup === null) { + throw new Error("Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredBooleanGroup' is set + if (requiredBooleanGroup === undefined || requiredBooleanGroup === null) { + throw new Error("Missing the required parameter 'requiredBooleanGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredInt64Group' is set + if (requiredInt64Group === undefined || requiredInt64Group === null) { + throw new Error("Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); + } + + + var pathParams = { + }; + var queryParams = { + 'required_string_group': requiredStringGroup, + 'required_int64_group': requiredInt64Group, + 'string_group': opts['stringGroup'], + 'int64_group': opts['int64Group'], + }; + var collectionQueryParams = { + }; + var headerParams = { + 'required_boolean_group': requiredBooleanGroup, + 'boolean_group': opts['booleanGroup'] + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = []; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake', 'DELETE', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType + ); + } + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @return {Promise} a {@link https://www.promisejs.org/|Promise} + */ + this.testGroupParameters = function(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) { + return this.testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + .then(function(response_and_data) { + return response_and_data.data; + }); + } + + /** * test inline additionalProperties * @param {Object.} requestBody request body diff --git a/samples/client/petstore/javascript-promise/src/api/FakeClassnameTags123Api.js b/samples/client/petstore/javascript-promise/src/api/FakeClassnameTags123Api.js index a7afa739af35..db5c71108c3c 100644 --- a/samples/client/petstore/javascript-promise/src/api/FakeClassnameTags123Api.js +++ b/samples/client/petstore/javascript-promise/src/api/FakeClassnameTags123Api.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index f1ec4381556b..163988f1e6e8 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index c84d1e93c7f5..a353ffa8ff1c 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index 88e15f0386db..cb9f8ac3ef15 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/index.js b/samples/client/petstore/javascript-promise/src/index.js index f7de11f4e558..e00b58c4016b 100644 --- a/samples/client/petstore/javascript-promise/src/index.js +++ b/samples/client/petstore/javascript-promise/src/index.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js index aa85406e6a6d..0d48ba4f1876 100644 --- a/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript-promise/src/model/AdditionalPropertiesClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Animal.js b/samples/client/petstore/javascript-promise/src/model/Animal.js index 1c26f336515f..8e654bb67e2c 100644 --- a/samples/client/petstore/javascript-promise/src/model/Animal.js +++ b/samples/client/petstore/javascript-promise/src/model/Animal.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js index 1186bb4b207c..ad8a9a2549b7 100644 --- a/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js +++ b/samples/client/petstore/javascript-promise/src/model/AnimalFarm.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js index 8a5161ed12da..b828a05a2bd9 100644 --- a/samples/client/petstore/javascript-promise/src/model/ApiResponse.js +++ b/samples/client/petstore/javascript-promise/src/model/ApiResponse.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ArrayOfArrayOfNumberOnly.js b/samples/client/petstore/javascript-promise/src/model/ArrayOfArrayOfNumberOnly.js index aa150c35acc3..a37b20ccca0a 100644 --- a/samples/client/petstore/javascript-promise/src/model/ArrayOfArrayOfNumberOnly.js +++ b/samples/client/petstore/javascript-promise/src/model/ArrayOfArrayOfNumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ArrayOfNumberOnly.js b/samples/client/petstore/javascript-promise/src/model/ArrayOfNumberOnly.js index c0a345a76b1a..b8acf5a198aa 100644 --- a/samples/client/petstore/javascript-promise/src/model/ArrayOfNumberOnly.js +++ b/samples/client/petstore/javascript-promise/src/model/ArrayOfNumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ArrayTest.js b/samples/client/petstore/javascript-promise/src/model/ArrayTest.js index 955463cf2cee..b9a9200a5027 100644 --- a/samples/client/petstore/javascript-promise/src/model/ArrayTest.js +++ b/samples/client/petstore/javascript-promise/src/model/ArrayTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Capitalization.js b/samples/client/petstore/javascript-promise/src/model/Capitalization.js index 2f960c5b9efc..a8363bf03308 100644 --- a/samples/client/petstore/javascript-promise/src/model/Capitalization.js +++ b/samples/client/petstore/javascript-promise/src/model/Capitalization.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Cat.js b/samples/client/petstore/javascript-promise/src/model/Cat.js index 20131cfe2d14..7d781b51be02 100644 --- a/samples/client/petstore/javascript-promise/src/model/Cat.js +++ b/samples/client/petstore/javascript-promise/src/model/Cat.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index bd9d7e54685e..9512d0bc2369 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -42,10 +42,12 @@ * Constructs a new Category. * @alias module:model/Category * @class + * @param name {String} */ - var exports = function() { + var exports = function(name) { var _this = this; + _this['name'] = name; }; /** @@ -74,8 +76,9 @@ exports.prototype['id'] = undefined; /** * @member {String} name + * @default 'default-name' */ - exports.prototype['name'] = undefined; + exports.prototype['name'] = 'default-name'; diff --git a/samples/client/petstore/javascript-promise/src/model/ClassModel.js b/samples/client/petstore/javascript-promise/src/model/ClassModel.js index a1208fdd5756..6ae2d532ca15 100644 --- a/samples/client/petstore/javascript-promise/src/model/ClassModel.js +++ b/samples/client/petstore/javascript-promise/src/model/ClassModel.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Client.js b/samples/client/petstore/javascript-promise/src/model/Client.js index e2af3bfa10fe..d5dd5500fa7e 100644 --- a/samples/client/petstore/javascript-promise/src/model/Client.js +++ b/samples/client/petstore/javascript-promise/src/model/Client.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Dog.js b/samples/client/petstore/javascript-promise/src/model/Dog.js index f5a73c3bca89..1a9f2e24b45c 100644 --- a/samples/client/petstore/javascript-promise/src/model/Dog.js +++ b/samples/client/petstore/javascript-promise/src/model/Dog.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/EnumArrays.js b/samples/client/petstore/javascript-promise/src/model/EnumArrays.js index c0c93dfecb71..e147e6f5b736 100644 --- a/samples/client/petstore/javascript-promise/src/model/EnumArrays.js +++ b/samples/client/petstore/javascript-promise/src/model/EnumArrays.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/EnumClass.js b/samples/client/petstore/javascript-promise/src/model/EnumClass.js index be0e548d3ff0..6548a6a2e3c8 100644 --- a/samples/client/petstore/javascript-promise/src/model/EnumClass.js +++ b/samples/client/petstore/javascript-promise/src/model/EnumClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/EnumTest.js b/samples/client/petstore/javascript-promise/src/model/EnumTest.js index b0c37e129bcd..c0ab8d677888 100644 --- a/samples/client/petstore/javascript-promise/src/model/EnumTest.js +++ b/samples/client/petstore/javascript-promise/src/model/EnumTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/File.js b/samples/client/petstore/javascript-promise/src/model/File.js index eb5bd17d80be..9ce05336134f 100644 --- a/samples/client/petstore/javascript-promise/src/model/File.js +++ b/samples/client/petstore/javascript-promise/src/model/File.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/FileSchemaTestClass.js b/samples/client/petstore/javascript-promise/src/model/FileSchemaTestClass.js index 93a23dcbd7b2..5863d01f6ad4 100644 --- a/samples/client/petstore/javascript-promise/src/model/FileSchemaTestClass.js +++ b/samples/client/petstore/javascript-promise/src/model/FileSchemaTestClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/FormatTest.js b/samples/client/petstore/javascript-promise/src/model/FormatTest.js index 63b9b2832992..3df6cc6cfe48 100644 --- a/samples/client/petstore/javascript-promise/src/model/FormatTest.js +++ b/samples/client/petstore/javascript-promise/src/model/FormatTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/HasOnlyReadOnly.js b/samples/client/petstore/javascript-promise/src/model/HasOnlyReadOnly.js index 817af5d86b7e..81fcd4182085 100644 --- a/samples/client/petstore/javascript-promise/src/model/HasOnlyReadOnly.js +++ b/samples/client/petstore/javascript-promise/src/model/HasOnlyReadOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/List.js b/samples/client/petstore/javascript-promise/src/model/List.js index 4412a32c822a..b25bf17304fa 100644 --- a/samples/client/petstore/javascript-promise/src/model/List.js +++ b/samples/client/petstore/javascript-promise/src/model/List.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/MapTest.js b/samples/client/petstore/javascript-promise/src/model/MapTest.js index f5499f47517c..790f79f35d99 100644 --- a/samples/client/petstore/javascript-promise/src/model/MapTest.js +++ b/samples/client/petstore/javascript-promise/src/model/MapTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js index e92184fcf2d8..057d7256a658 100644 --- a/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript-promise/src/model/MixedPropertiesAndAdditionalPropertiesClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Model200Response.js b/samples/client/petstore/javascript-promise/src/model/Model200Response.js index 45ecd7bcbc3e..fcc9504c30fe 100644 --- a/samples/client/petstore/javascript-promise/src/model/Model200Response.js +++ b/samples/client/petstore/javascript-promise/src/model/Model200Response.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js index ba50a193fcab..d218626864ce 100644 --- a/samples/client/petstore/javascript-promise/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript-promise/src/model/ModelReturn.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Name.js b/samples/client/petstore/javascript-promise/src/model/Name.js index 77fe28677aa1..44b004b25826 100644 --- a/samples/client/petstore/javascript-promise/src/model/Name.js +++ b/samples/client/petstore/javascript-promise/src/model/Name.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/NumberOnly.js b/samples/client/petstore/javascript-promise/src/model/NumberOnly.js index dd082b35f365..bba5fde5c921 100644 --- a/samples/client/petstore/javascript-promise/src/model/NumberOnly.js +++ b/samples/client/petstore/javascript-promise/src/model/NumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js index 6e5659cfce07..e455167d94af 100644 --- a/samples/client/petstore/javascript-promise/src/model/Order.js +++ b/samples/client/petstore/javascript-promise/src/model/Order.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/OuterComposite.js b/samples/client/petstore/javascript-promise/src/model/OuterComposite.js index 3660cda183d2..e0b1c679b891 100644 --- a/samples/client/petstore/javascript-promise/src/model/OuterComposite.js +++ b/samples/client/petstore/javascript-promise/src/model/OuterComposite.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/OuterEnum.js b/samples/client/petstore/javascript-promise/src/model/OuterEnum.js index 772429172082..9f3ad94a5faa 100644 --- a/samples/client/petstore/javascript-promise/src/model/OuterEnum.js +++ b/samples/client/petstore/javascript-promise/src/model/OuterEnum.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js index 422bab25fd13..eb83de036aeb 100644 --- a/samples/client/petstore/javascript-promise/src/model/Pet.js +++ b/samples/client/petstore/javascript-promise/src/model/Pet.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js index 2c0cb7802827..f9198309e653 100644 --- a/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js +++ b/samples/client/petstore/javascript-promise/src/model/ReadOnlyFirst.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js index b694729ee2aa..a510a12f4315 100644 --- a/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript-promise/src/model/SpecialModelName.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/StringBooleanMap.js b/samples/client/petstore/javascript-promise/src/model/StringBooleanMap.js index aa287f6cdc96..1bc5c4e59c69 100644 --- a/samples/client/petstore/javascript-promise/src/model/StringBooleanMap.js +++ b/samples/client/petstore/javascript-promise/src/model/StringBooleanMap.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js index 3ba4159ebb61..0aa84ec6e843 100644 --- a/samples/client/petstore/javascript-promise/src/model/Tag.js +++ b/samples/client/petstore/javascript-promise/src/model/Tag.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js index 8c500d4ae3cc..345e29d95a3c 100644 --- a/samples/client/petstore/javascript-promise/src/model/User.js +++ b/samples/client/petstore/javascript-promise/src/model/User.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/.openapi-generator/VERSION b/samples/client/petstore/javascript/.openapi-generator/VERSION index a65271290834..d077ffb477a4 100644 --- a/samples/client/petstore/javascript/.openapi-generator/VERSION +++ b/samples/client/petstore/javascript/.openapi-generator/VERSION @@ -1 +1 @@ -3.3.2-SNAPSHOT \ No newline at end of file +3.3.4-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/javascript/README.md b/samples/client/petstore/javascript/README.md index 5283d7248f67..a4152b975348 100644 --- a/samples/client/petstore/javascript/README.md +++ b/samples/client/petstore/javascript/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *OpenApiPetstore.FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model *OpenApiPetstore.FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *OpenApiPetstore.FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +*OpenApiPetstore.FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *OpenApiPetstore.FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *OpenApiPetstore.FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data *OpenApiPetstore.FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case diff --git a/samples/client/petstore/javascript/docs/Category.md b/samples/client/petstore/javascript/docs/Category.md index e3f934442abc..5c333f8f61ff 100644 --- a/samples/client/petstore/javascript/docs/Category.md +++ b/samples/client/petstore/javascript/docs/Category.md @@ -4,6 +4,6 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **Number** | | [optional] -**name** | **String** | | [optional] +**name** | **String** | | [default to 'default-name'] diff --git a/samples/client/petstore/javascript/docs/FakeApi.md b/samples/client/petstore/javascript/docs/FakeApi.md index c7d9c6de6c72..e656c039c76e 100644 --- a/samples/client/petstore/javascript/docs/FakeApi.md +++ b/samples/client/petstore/javascript/docs/FakeApi.md @@ -13,6 +13,7 @@ Method | HTTP request | Description [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters +[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data @@ -462,6 +463,61 @@ No authorization required - **Content-Type**: application/x-www-form-urlencoded - **Accept**: Not defined + +# **testGroupParameters** +> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts) + +Fake endpoint to test group parameters (optional) + +Fake endpoint to test group parameters (optional) + +### Example +```javascript +var OpenApiPetstore = require('open_api_petstore'); + +var apiInstance = new OpenApiPetstore.FakeApi(); +var requiredStringGroup = 56; // Number | Required String in group parameters +var requiredBooleanGroup = true; // Boolean | Required Boolean in group parameters +var requiredInt64Group = 789; // Number | Required Integer in group parameters +var opts = { + 'stringGroup': 56, // Number | String in group parameters + 'booleanGroup': true, // Boolean | Boolean in group parameters + 'int64Group': 789 // Number | Integer in group parameters +}; +var callback = function(error, data, response) { + if (error) { + console.error(error); + } else { + console.log('API called successfully.'); + } +}; +apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts, callback); +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requiredStringGroup** | **Number**| Required String in group parameters | + **requiredBooleanGroup** | **Boolean**| Required Boolean in group parameters | + **requiredInt64Group** | **Number**| Required Integer in group parameters | + **stringGroup** | **Number**| String in group parameters | [optional] + **booleanGroup** | **Boolean**| Boolean in group parameters | [optional] + **int64Group** | **Number**| Integer in group parameters | [optional] + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testInlineAdditionalProperties** > testInlineAdditionalProperties(requestBody) diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index e5d21515ca03..07b9ab030ec4 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -451,7 +451,7 @@ } } } - } else if (bodyParam) { + } else if (bodyParam !== null && bodyParam !== undefined) { request.send(bodyParam); } diff --git a/samples/client/petstore/javascript/src/api/AnotherFakeApi.js b/samples/client/petstore/javascript/src/api/AnotherFakeApi.js index 3b2af03572a8..09dce2f50583 100644 --- a/samples/client/petstore/javascript/src/api/AnotherFakeApi.js +++ b/samples/client/petstore/javascript/src/api/AnotherFakeApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/api/FakeApi.js b/samples/client/petstore/javascript/src/api/FakeApi.js index 9f3e8d2ebe2a..3fe403934893 100644 --- a/samples/client/petstore/javascript/src/api/FakeApi.js +++ b/samples/client/petstore/javascript/src/api/FakeApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -513,6 +513,75 @@ ); } + /** + * Callback function to receive the result of the testGroupParameters operation. + * @callback module:api/FakeApi~testGroupParametersCallback + * @param {String} error Error message, if any. + * @param data This operation does not return a value. + * @param {String} response The complete HTTP response. + */ + + /** + * Fake endpoint to test group parameters (optional) + * Fake endpoint to test group parameters (optional) + * @param {Number} requiredStringGroup Required String in group parameters + * @param {Boolean} requiredBooleanGroup Required Boolean in group parameters + * @param {Number} requiredInt64Group Required Integer in group parameters + * @param {Object} opts Optional parameters + * @param {Number} opts.stringGroup String in group parameters + * @param {Boolean} opts.booleanGroup Boolean in group parameters + * @param {Number} opts.int64Group Integer in group parameters + * @param {module:api/FakeApi~testGroupParametersCallback} callback The callback function, accepting three arguments: error, data, response + */ + this.testGroupParameters = function(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, opts, callback) { + opts = opts || {}; + var postBody = null; + + // verify the required parameter 'requiredStringGroup' is set + if (requiredStringGroup === undefined || requiredStringGroup === null) { + throw new Error("Missing the required parameter 'requiredStringGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredBooleanGroup' is set + if (requiredBooleanGroup === undefined || requiredBooleanGroup === null) { + throw new Error("Missing the required parameter 'requiredBooleanGroup' when calling testGroupParameters"); + } + + // verify the required parameter 'requiredInt64Group' is set + if (requiredInt64Group === undefined || requiredInt64Group === null) { + throw new Error("Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); + } + + + var pathParams = { + }; + var queryParams = { + 'required_string_group': requiredStringGroup, + 'required_int64_group': requiredInt64Group, + 'string_group': opts['stringGroup'], + 'int64_group': opts['int64Group'], + }; + var collectionQueryParams = { + }; + var headerParams = { + 'required_boolean_group': requiredBooleanGroup, + 'boolean_group': opts['booleanGroup'] + }; + var formParams = { + }; + + var authNames = []; + var contentTypes = []; + var accepts = []; + var returnType = null; + + return this.apiClient.callApi( + '/fake', 'DELETE', + pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody, + authNames, contentTypes, accepts, returnType, callback + ); + } + /** * Callback function to receive the result of the testInlineAdditionalProperties operation. * @callback module:api/FakeApi~testInlineAdditionalPropertiesCallback diff --git a/samples/client/petstore/javascript/src/api/FakeClassnameTags123Api.js b/samples/client/petstore/javascript/src/api/FakeClassnameTags123Api.js index ca878d474b18..55669c688d45 100644 --- a/samples/client/petstore/javascript/src/api/FakeClassnameTags123Api.js +++ b/samples/client/petstore/javascript/src/api/FakeClassnameTags123Api.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 834ab1f71aa8..6ccf6a102e0c 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 658de0dd20bc..ef6f1713a7dc 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/api/UserApi.js b/samples/client/petstore/javascript/src/api/UserApi.js index f5daf5012d2d..faf8be95f1e9 100644 --- a/samples/client/petstore/javascript/src/api/UserApi.js +++ b/samples/client/petstore/javascript/src/api/UserApi.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/index.js b/samples/client/petstore/javascript/src/index.js index f7de11f4e558..e00b58c4016b 100644 --- a/samples/client/petstore/javascript/src/index.js +++ b/samples/client/petstore/javascript/src/index.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js b/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js index aa85406e6a6d..0d48ba4f1876 100644 --- a/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript/src/model/AdditionalPropertiesClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Animal.js b/samples/client/petstore/javascript/src/model/Animal.js index 1c26f336515f..8e654bb67e2c 100644 --- a/samples/client/petstore/javascript/src/model/Animal.js +++ b/samples/client/petstore/javascript/src/model/Animal.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/AnimalFarm.js b/samples/client/petstore/javascript/src/model/AnimalFarm.js index 1186bb4b207c..ad8a9a2549b7 100644 --- a/samples/client/petstore/javascript/src/model/AnimalFarm.js +++ b/samples/client/petstore/javascript/src/model/AnimalFarm.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ApiResponse.js b/samples/client/petstore/javascript/src/model/ApiResponse.js index 8a5161ed12da..b828a05a2bd9 100644 --- a/samples/client/petstore/javascript/src/model/ApiResponse.js +++ b/samples/client/petstore/javascript/src/model/ApiResponse.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ArrayOfArrayOfNumberOnly.js b/samples/client/petstore/javascript/src/model/ArrayOfArrayOfNumberOnly.js index aa150c35acc3..a37b20ccca0a 100644 --- a/samples/client/petstore/javascript/src/model/ArrayOfArrayOfNumberOnly.js +++ b/samples/client/petstore/javascript/src/model/ArrayOfArrayOfNumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ArrayOfNumberOnly.js b/samples/client/petstore/javascript/src/model/ArrayOfNumberOnly.js index c0a345a76b1a..b8acf5a198aa 100644 --- a/samples/client/petstore/javascript/src/model/ArrayOfNumberOnly.js +++ b/samples/client/petstore/javascript/src/model/ArrayOfNumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ArrayTest.js b/samples/client/petstore/javascript/src/model/ArrayTest.js index 955463cf2cee..b9a9200a5027 100644 --- a/samples/client/petstore/javascript/src/model/ArrayTest.js +++ b/samples/client/petstore/javascript/src/model/ArrayTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Capitalization.js b/samples/client/petstore/javascript/src/model/Capitalization.js index 2f960c5b9efc..a8363bf03308 100644 --- a/samples/client/petstore/javascript/src/model/Capitalization.js +++ b/samples/client/petstore/javascript/src/model/Capitalization.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Cat.js b/samples/client/petstore/javascript/src/model/Cat.js index 20131cfe2d14..7d781b51be02 100644 --- a/samples/client/petstore/javascript/src/model/Cat.js +++ b/samples/client/petstore/javascript/src/model/Cat.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Category.js b/samples/client/petstore/javascript/src/model/Category.js index bd9d7e54685e..9512d0bc2369 100644 --- a/samples/client/petstore/javascript/src/model/Category.js +++ b/samples/client/petstore/javascript/src/model/Category.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * @@ -42,10 +42,12 @@ * Constructs a new Category. * @alias module:model/Category * @class + * @param name {String} */ - var exports = function() { + var exports = function(name) { var _this = this; + _this['name'] = name; }; /** @@ -74,8 +76,9 @@ exports.prototype['id'] = undefined; /** * @member {String} name + * @default 'default-name' */ - exports.prototype['name'] = undefined; + exports.prototype['name'] = 'default-name'; diff --git a/samples/client/petstore/javascript/src/model/ClassModel.js b/samples/client/petstore/javascript/src/model/ClassModel.js index a1208fdd5756..6ae2d532ca15 100644 --- a/samples/client/petstore/javascript/src/model/ClassModel.js +++ b/samples/client/petstore/javascript/src/model/ClassModel.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Client.js b/samples/client/petstore/javascript/src/model/Client.js index e2af3bfa10fe..d5dd5500fa7e 100644 --- a/samples/client/petstore/javascript/src/model/Client.js +++ b/samples/client/petstore/javascript/src/model/Client.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Dog.js b/samples/client/petstore/javascript/src/model/Dog.js index f5a73c3bca89..1a9f2e24b45c 100644 --- a/samples/client/petstore/javascript/src/model/Dog.js +++ b/samples/client/petstore/javascript/src/model/Dog.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/EnumArrays.js b/samples/client/petstore/javascript/src/model/EnumArrays.js index c0c93dfecb71..e147e6f5b736 100644 --- a/samples/client/petstore/javascript/src/model/EnumArrays.js +++ b/samples/client/petstore/javascript/src/model/EnumArrays.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/EnumClass.js b/samples/client/petstore/javascript/src/model/EnumClass.js index be0e548d3ff0..6548a6a2e3c8 100644 --- a/samples/client/petstore/javascript/src/model/EnumClass.js +++ b/samples/client/petstore/javascript/src/model/EnumClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/EnumTest.js b/samples/client/petstore/javascript/src/model/EnumTest.js index b0c37e129bcd..c0ab8d677888 100644 --- a/samples/client/petstore/javascript/src/model/EnumTest.js +++ b/samples/client/petstore/javascript/src/model/EnumTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/File.js b/samples/client/petstore/javascript/src/model/File.js index eb5bd17d80be..9ce05336134f 100644 --- a/samples/client/petstore/javascript/src/model/File.js +++ b/samples/client/petstore/javascript/src/model/File.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/FileSchemaTestClass.js b/samples/client/petstore/javascript/src/model/FileSchemaTestClass.js index 93a23dcbd7b2..5863d01f6ad4 100644 --- a/samples/client/petstore/javascript/src/model/FileSchemaTestClass.js +++ b/samples/client/petstore/javascript/src/model/FileSchemaTestClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/FormatTest.js b/samples/client/petstore/javascript/src/model/FormatTest.js index 63b9b2832992..3df6cc6cfe48 100644 --- a/samples/client/petstore/javascript/src/model/FormatTest.js +++ b/samples/client/petstore/javascript/src/model/FormatTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/HasOnlyReadOnly.js b/samples/client/petstore/javascript/src/model/HasOnlyReadOnly.js index 817af5d86b7e..81fcd4182085 100644 --- a/samples/client/petstore/javascript/src/model/HasOnlyReadOnly.js +++ b/samples/client/petstore/javascript/src/model/HasOnlyReadOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/List.js b/samples/client/petstore/javascript/src/model/List.js index 4412a32c822a..b25bf17304fa 100644 --- a/samples/client/petstore/javascript/src/model/List.js +++ b/samples/client/petstore/javascript/src/model/List.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/MapTest.js b/samples/client/petstore/javascript/src/model/MapTest.js index f5499f47517c..790f79f35d99 100644 --- a/samples/client/petstore/javascript/src/model/MapTest.js +++ b/samples/client/petstore/javascript/src/model/MapTest.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js b/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js index e92184fcf2d8..057d7256a658 100644 --- a/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js +++ b/samples/client/petstore/javascript/src/model/MixedPropertiesAndAdditionalPropertiesClass.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Model200Response.js b/samples/client/petstore/javascript/src/model/Model200Response.js index 45ecd7bcbc3e..fcc9504c30fe 100644 --- a/samples/client/petstore/javascript/src/model/Model200Response.js +++ b/samples/client/petstore/javascript/src/model/Model200Response.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ModelReturn.js b/samples/client/petstore/javascript/src/model/ModelReturn.js index ba50a193fcab..d218626864ce 100644 --- a/samples/client/petstore/javascript/src/model/ModelReturn.js +++ b/samples/client/petstore/javascript/src/model/ModelReturn.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Name.js b/samples/client/petstore/javascript/src/model/Name.js index 77fe28677aa1..44b004b25826 100644 --- a/samples/client/petstore/javascript/src/model/Name.js +++ b/samples/client/petstore/javascript/src/model/Name.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/NumberOnly.js b/samples/client/petstore/javascript/src/model/NumberOnly.js index dd082b35f365..bba5fde5c921 100644 --- a/samples/client/petstore/javascript/src/model/NumberOnly.js +++ b/samples/client/petstore/javascript/src/model/NumberOnly.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js index 6e5659cfce07..e455167d94af 100644 --- a/samples/client/petstore/javascript/src/model/Order.js +++ b/samples/client/petstore/javascript/src/model/Order.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/OuterComposite.js b/samples/client/petstore/javascript/src/model/OuterComposite.js index 3660cda183d2..e0b1c679b891 100644 --- a/samples/client/petstore/javascript/src/model/OuterComposite.js +++ b/samples/client/petstore/javascript/src/model/OuterComposite.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/OuterEnum.js b/samples/client/petstore/javascript/src/model/OuterEnum.js index 772429172082..9f3ad94a5faa 100644 --- a/samples/client/petstore/javascript/src/model/OuterEnum.js +++ b/samples/client/petstore/javascript/src/model/OuterEnum.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js index 422bab25fd13..eb83de036aeb 100644 --- a/samples/client/petstore/javascript/src/model/Pet.js +++ b/samples/client/petstore/javascript/src/model/Pet.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js b/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js index 2c0cb7802827..f9198309e653 100644 --- a/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js +++ b/samples/client/petstore/javascript/src/model/ReadOnlyFirst.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/SpecialModelName.js b/samples/client/petstore/javascript/src/model/SpecialModelName.js index b694729ee2aa..a510a12f4315 100644 --- a/samples/client/petstore/javascript/src/model/SpecialModelName.js +++ b/samples/client/petstore/javascript/src/model/SpecialModelName.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/StringBooleanMap.js b/samples/client/petstore/javascript/src/model/StringBooleanMap.js index aa287f6cdc96..1bc5c4e59c69 100644 --- a/samples/client/petstore/javascript/src/model/StringBooleanMap.js +++ b/samples/client/petstore/javascript/src/model/StringBooleanMap.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/Tag.js b/samples/client/petstore/javascript/src/model/Tag.js index 3ba4159ebb61..0aa84ec6e843 100644 --- a/samples/client/petstore/javascript/src/model/Tag.js +++ b/samples/client/petstore/javascript/src/model/Tag.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * diff --git a/samples/client/petstore/javascript/src/model/User.js b/samples/client/petstore/javascript/src/model/User.js index 8c500d4ae3cc..345e29d95a3c 100644 --- a/samples/client/petstore/javascript/src/model/User.js +++ b/samples/client/petstore/javascript/src/model/User.js @@ -7,7 +7,7 @@ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * - * OpenAPI Generator version: 3.3.2-SNAPSHOT + * OpenAPI Generator version: 3.3.4-SNAPSHOT * * Do not edit the class manually. * From bf2932d41cd4b8d926e0f656c006d640bb2e573f Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sat, 24 Nov 2018 17:04:59 +0800 Subject: [PATCH 14/14] fix array of enum class in JS (#1484) --- .../src/main/resources/Javascript/ApiClient.mustache | 4 ++-- .../src/main/resources/Javascript/es6/ApiClient.mustache | 4 ++-- samples/client/petstore/javascript-es6/src/ApiClient.js | 4 ++-- .../client/petstore/javascript-promise-es6/src/ApiClient.js | 4 ++-- samples/client/petstore/javascript-promise/src/ApiClient.js | 4 ++-- samples/client/petstore/javascript/src/ApiClient.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache index b6bbc4737493..c0c692fc5b0a 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache @@ -546,8 +546,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache index 49b92e21cae8..694013f1425c 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/es6/ApiClient.mustache @@ -502,8 +502,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-es6/src/ApiClient.js b/samples/client/petstore/javascript-es6/src/ApiClient.js index 369632309dc9..50bdc6111313 100644 --- a/samples/client/petstore/javascript-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-es6/src/ApiClient.js @@ -486,8 +486,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js index 2b2d43810cf0..50ef10e264e9 100644 --- a/samples/client/petstore/javascript-promise-es6/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise-es6/src/ApiClient.js @@ -478,8 +478,8 @@ class ApiClient { if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User and enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 0415153dac19..883b148d5ab3 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -525,8 +525,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String'] diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index 07b9ab030ec4..4e33f192e4a0 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -536,8 +536,8 @@ if (type === Object) { // generic object, return directly return data; - } else if (typeof type === 'function') { - // for model type like: User + } else if (typeof type.constructFromObject === 'function') { + // for model type like User or enum class return type.constructFromObject(data); } else if (Array.isArray(type)) { // for array type like: ['String']