From 90442db86d9d53f1d52ca5fe8e2bf4022ada697c Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 29 Apr 2016 11:10:52 +0800 Subject: [PATCH] skip overwriting ruby spec files --- .../java/io/swagger/codegen/DefaultGenerator.java | 7 +++++++ .../swagger/codegen/languages/RubyClientCodegen.java | 7 +++++++ samples/client/petstore/ruby/README.md | 4 ++-- samples/client/petstore/ruby/docs/FakeApi.md | 4 ++-- samples/client/petstore/ruby/docs/FormatTest.md | 1 + .../petstore/ruby/lib/petstore/models/format_test.rb | 11 ++++++++++- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index aebf7e50de..b5a920004c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -264,6 +264,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String suffix = config.modelTemplateFiles().get(templateName); String filename = config.modelFileFolder() + File.separator + config.toModelFilename(name) + suffix; if (!config.shouldOverwrite(filename)) { + LOGGER.info("Skipped overwriting " + filename); continue; } String templateFile = getFullTemplateFile(config, templateName); @@ -286,6 +287,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String suffix = config.modelTestTemplateFiles().get(templateName); String filename = config.modelTestFileFolder() + File.separator + config.toModelTestFilename(name) + suffix; if (!config.shouldOverwrite(filename)) { + LOGGER.info("Skipped overwriting " + filename); continue; } String templateFile = getFullTemplateFile(config, templateName); @@ -308,6 +310,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { String suffix = config.modelDocTemplateFiles().get(templateName); String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(name) + suffix; if (!config.shouldOverwrite(filename)) { + LOGGER.info("Skipped overwriting " + filename); continue; } String templateFile = getFullTemplateFile(config, templateName); @@ -393,6 +396,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTemplateFiles().keySet()) { String filename = config.apiFilename(templateName, tag); if (!config.shouldOverwrite(filename) && new File(filename).exists()) { + LOGGER.info("Skipped overwriting " + filename); continue; } @@ -416,6 +420,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiTestTemplateFiles().keySet()) { String filename = config.apiTestFilename(templateName, tag); if (!config.shouldOverwrite(filename) && new File(filename).exists()) { + LOGGER.info("Skipped overwriting " + filename); continue; } @@ -439,6 +444,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String templateName : config.apiDocTemplateFiles().keySet()) { String filename = config.apiDocFilename(templateName, tag); if (!config.shouldOverwrite(filename) && new File(filename).exists()) { + LOGGER.info("Skipped overwriting " + filename); continue; } @@ -521,6 +527,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { } String outputFilename = outputFolder + File.separator + support.destinationFilename; if (!config.shouldOverwrite(outputFilename)) { + LOGGER.info("Skipped overwriting " + outputFilename); continue; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java index 828cd0eb71..e81aa71726 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RubyClientCodegen.java @@ -642,4 +642,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig { public void setGemAuthorEmail(String gemAuthorEmail) { this.gemAuthorEmail = gemAuthorEmail; } + + + @Override + public boolean shouldOverwrite(String filename) { + // skip spec file as the file might have been updated with new test cases + return super.shouldOverwrite(filename) && !filename.endsWith("_spec.rb"); + } } diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index cab06a92ce..da8816ec71 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-26T10:05:22.048-07:00 +- Build date: 2016-04-29T11:03:36.514+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -57,7 +57,7 @@ require 'petstore' api_instance = Petstore::FakeApi.new -number = "number_example" # String | None +number = 3.4 # Float | None double = 1.2 # Float | None diff --git a/samples/client/petstore/ruby/docs/FakeApi.md b/samples/client/petstore/ruby/docs/FakeApi.md index a7c0b42a47..32f2902d93 100644 --- a/samples/client/petstore/ruby/docs/FakeApi.md +++ b/samples/client/petstore/ruby/docs/FakeApi.md @@ -21,7 +21,7 @@ require 'petstore' api_instance = Petstore::FakeApi.new -number = "number_example" # String | None +number = 3.4 # Float | None double = 1.2 # Float | None @@ -52,7 +52,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **number** | **String**| None | + **number** | **Float**| None | **double** | **Float**| None | **string** | **String**| None | **byte** | **String**| None | diff --git a/samples/client/petstore/ruby/docs/FormatTest.md b/samples/client/petstore/ruby/docs/FormatTest.md index 7197a7a658..014f2431f1 100644 --- a/samples/client/petstore/ruby/docs/FormatTest.md +++ b/samples/client/petstore/ruby/docs/FormatTest.md @@ -14,6 +14,7 @@ Name | Type | Description | Notes **binary** | **String** | | [optional] **date** | **Date** | | **date_time** | **DateTime** | | [optional] +**uuid** | [**UUID**](UUID.md) | | [optional] **password** | **String** | | 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 a7ebd095f9..807a8f4d60 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -40,6 +40,8 @@ module Petstore attr_accessor :date_time + attr_accessor :uuid + attr_accessor :password # Attribute mapping from ruby-style variable name to JSON key. @@ -56,6 +58,7 @@ module Petstore :'binary' => :'binary', :'date' => :'date', :'date_time' => :'dateTime', + :'uuid' => :'uuid', :'password' => :'password' } end @@ -74,6 +77,7 @@ module Petstore :'binary' => :'String', :'date' => :'Date', :'date_time' => :'DateTime', + :'uuid' => :'UUID', :'password' => :'String' } end @@ -130,6 +134,10 @@ module Petstore 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 @@ -354,6 +362,7 @@ module Petstore binary == o.binary && date == o.date && date_time == o.date_time && + uuid == o.uuid && password == o.password end @@ -366,7 +375,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, password].hash + [integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password].hash end # Builds the object from hash