Skip to content

Commit 4edfc35

Browse files
authored
Merge branch 'master' into write-stringToFile-withUtf8
2 parents 75f49bd + caf7bc2 commit 4edfc35

File tree

74 files changed

+750
-198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+750
-198
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
[![Build Status](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-master-java7/badge/icon?subject=jenkins%20build%20-%20java%207)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-master-java7/)
88

9-
- Master (2.4.12-SNAPSHOT): [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/master.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
9+
- Master (2.4.13-SNAPSHOT): [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/master.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
1010
[![Java Test](https://img.shields.io/jenkins/build.svg?jobUrl=https://jenkins.swagger.io/job/oss-swagger-codegen-master)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-master)
1111
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/swaggerhub-bot/swagger-codegen)
1212

13-
- 3.0.16-SNAPSHOT: [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/3.0.0.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
13+
- 3.0.19-SNAPSHOT: [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/3.0.0.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
1414
[![Java Test](https://img.shields.io/jenkins/build.svg?jobUrl=https://jenkins.swagger.io/job/oss-swagger-codegen-3)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-3)
1515
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=3.0.0&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/swaggerhub-bot/swagger-codegen)
1616

@@ -52,7 +52,7 @@ dependency example:
5252
<dependency>
5353
<groupId>io.swagger</groupId>
5454
<artifactId>swagger-codegen-maven-plugin</artifactId>
55-
<version>2.4.12-SNAPSHOT</version>
55+
<version>2.4.12</version>
5656
</dependency>
5757
```
5858

@@ -70,7 +70,7 @@ dependency example:
7070
<dependency>
7171
<groupId>io.swagger.codegen.v3</groupId>
7272
<artifactId>swagger-codegen-maven-plugin</artifactId>
73-
<version>3.0.16-SNAPSHOT</version>
73+
<version>3.0.18</version>
7474
</dependency>
7575
```
7676

@@ -134,7 +134,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
134134

135135
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
136136
-------------------------- | ------------ | -------------------------- | -----
137-
3.0.16-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.16-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
137+
3.0.19-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.19-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
138+
[3.0.18](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.18) (**current stable**) | 2020-02-26 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.18](https://github.com/swagger-api/swagger-codegen/tree/v3.0.18)
139+
[3.0.17](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.17) (**current stable**) | 2020-02-23 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.17](https://github.com/swagger-api/swagger-codegen/tree/v3.0.17)
140+
[3.0.17](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.16) (**current stable**) | 2020-01-15 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.16](https://github.com/swagger-api/swagger-codegen/tree/v3.0.16)
138141
[3.0.15](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.15) (**current stable**) | 2020-01-03 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.15](https://github.com/swagger-api/swagger-codegen/tree/v3.0.15)
139142
[3.0.14](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.14) | 2019-11-16 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.14](https://github.com/swagger-api/swagger-codegen/tree/v3.0.14)
140143
[3.0.13](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.13) | 2019-10-16 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.13](https://github.com/swagger-api/swagger-codegen/tree/v3.0.13)
@@ -150,7 +153,8 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
150153
[3.0.2](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.2)| 2018-10-19 | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
151154
[3.0.1](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.1)| 2018-10-05 | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes
152155
[3.0.0](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.0)| 2018-09-06 | 1.0, 1.1, 1.2, 2.0, 3.0 | Major release with breaking changes
153-
2.4.12-SNAPSHOT (current master, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/2.4.12-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0 | Minor release
156+
2.4.13-SNAPSHOT (current master, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/2.4.13-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0 | Minor release
157+
[2.4.12](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.12) (**current stable**) | 2020-01-15 | 1.0, 1.1, 1.2, 2.0 | [tag v2.4.12](https://github.com/swagger-api/swagger-codegen/tree/v2.4.12)
154158
[2.4.11](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.11) (**current stable**) | 2020-01-03 | 1.0, 1.1, 1.2, 2.0 | [tag v2.4.11](https://github.com/swagger-api/swagger-codegen/tree/v2.4.11)
155159
[2.4.10](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.10) | 2019-11-16 | 1.0, 1.1, 1.2, 2.0 | [tag v2.4.10](https://github.com/swagger-api/swagger-codegen/tree/v2.4.10)
156160
[2.4.9](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.4.9) | 2019-10-14 | 1.0, 1.1, 1.2, 2.0 | [tag v2.4.9](https://github.com/swagger-api/swagger-codegen/tree/v2.4.9)
@@ -177,12 +181,16 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
177181
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
178182

179183
```sh
180-
wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.10/swagger-codegen-cli-2.4.10.jar -O swagger-codegen-cli.jar
184+
# Download current stable 2.x.x branch (Swagger and OpenAPI version 2)
185+
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar -O swagger-codegen-cli.jar
186+
187+
# Download current stable 3.x.x branch (OpenAPI version 3)
188+
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.18/swagger-codegen-cli-3.0.18.jar -O swagger-codegen-cli.jar
181189

182190
java -jar swagger-codegen-cli.jar help
183191
```
184192

185-
For Windows users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. `Invoke-WebRequest -OutFile swagger-codegen-cli.jar http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.10/swagger-codegen-cli-2.4.10.jar`
193+
For Windows users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. `Invoke-WebRequest -OutFile swagger-codegen-cli.jar https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar`
186194

187195
On a mac, it's even easier with `brew`:
188196
```sh
@@ -327,7 +335,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
327335
```
328336
(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`)
329337

330-
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.10/swagger-codegen-cli-2.4.10.jar)
338+
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar)
331339

332340
To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate`
333341

modules/swagger-codegen-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.4.12-SNAPSHOT</version>
6+
<version>2.4.13-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Generate.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public class Generate implements Runnable {
175175
@Option(name = {"--skip-alias-generation"}, title = "skip alias generation.", description = "skip code generation for models identified as alias.")
176176
private Boolean skipAliasGeneration;
177177

178+
@Option(name = {"--ignore-import-mapping"}, title = "ignore import mapping", description = "allow generate model classes using names previously listed on import mappings.")
179+
private String ignoreImportMappings;
180+
178181
@Override
179182
public void run() {
180183

@@ -280,6 +283,10 @@ public void run() {
280283
configurator.setSkipAliasGeneration(removeOperationIdPrefix);
281284
}
282285

286+
if (ignoreImportMappings != null) {
287+
additionalProperties.add(String.format("%s=%s", CodegenConstants.IGNORE_IMPORT_MAPPING_OPTION, Boolean.parseBoolean(ignoreImportMappings)));
288+
}
289+
283290
applySystemPropertiesKvpList(systemProperties, configurator);
284291
applyInstantiationTypesKvpList(instantiationTypes, configurator);
285292
applyImportMappingsKvpList(importMappings, configurator);

modules/swagger-codegen-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.swagger</groupId>
66
<artifactId>swagger-codegen-project</artifactId>
7-
<version>2.4.12-SNAPSHOT</version>
7+
<version>2.4.13-SNAPSHOT</version>
88
<relativePath>../..</relativePath>
99
</parent>
1010
<artifactId>swagger-codegen-maven-plugin</artifactId>

modules/swagger-codegen/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.4.12-SNAPSHOT</version>
6+
<version>2.4.13-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,10 @@ public interface CodegenConfig {
226226

227227
Boolean getSkipAliasGeneration();
228228

229+
boolean getIgnoreImportMapping();
230+
231+
void setIgnoreImportMapping(boolean ignoreImportMapping);
232+
233+
boolean defaultIgnoreImportMappingOption();
234+
229235
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,6 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
234234
public static final String ASP_NET_CORE_VERSION = "aspnetCoreVersion";
235235
public static final String INTERFACE_ONLY = "interface-only";
236236
public static final String INTERFACE_CONTROLLER = "interface-controller";
237+
238+
public static final String IGNORE_IMPORT_MAPPING_OPTION = "ignoreImportMappings";
237239
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class DefaultCodegen {
104104
protected String httpUserAgent;
105105
protected Boolean hideGenerationTimestamp = true;
106106
protected Boolean skipAliasGeneration;
107+
protected boolean ignoreImportMapping;
107108
// How to encode special characters like $
108109
// They are translated to words like "Dollar" and prefixed with '
109110
// Then translated back during JSON encoding and decoding
@@ -163,6 +164,12 @@ public void processOpts() {
163164
this.setRemoveOperationIdPrefix(Boolean.valueOf(additionalProperties
164165
.get(CodegenConstants.REMOVE_OPERATION_ID_PREFIX).toString()));
165166
}
167+
168+
if (additionalProperties.get(CodegenConstants.IGNORE_IMPORT_MAPPING_OPTION) != null) {
169+
setIgnoreImportMapping(Boolean.parseBoolean( additionalProperties.get(CodegenConstants.IGNORE_IMPORT_MAPPING_OPTION).toString()));
170+
} else {
171+
setIgnoreImportMapping(defaultIgnoreImportMappingOption());
172+
}
166173
}
167174

168175
// override with any special post-processing for all models
@@ -3264,6 +3271,10 @@ private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Pro
32643271
// FIXME: readWriteVars can contain duplicated properties. Debug/breakpoint here while running C# generator (Dog and Cat models)
32653272
m.readWriteVars.add(cp);
32663273
}
3274+
3275+
if (m.discriminator != null && cp.name.equals(m.discriminator) && cp.isEnum) {
3276+
m.vendorExtensions.put("x-discriminator-is-enum", true);
3277+
}
32673278
}
32683279
}
32693280
}
@@ -3958,4 +3969,16 @@ protected void configureDataForTestTemplate(CodegenOperation codegenOperation) {
39583969
}
39593970
codegenOperation.testPath = path;
39603971
}
3972+
3973+
public boolean getIgnoreImportMapping() {
3974+
return ignoreImportMapping;
3975+
}
3976+
3977+
public void setIgnoreImportMapping(boolean ignoreImportMapping) {
3978+
this.ignoreImportMapping = ignoreImportMapping;
3979+
}
3980+
3981+
public boolean defaultIgnoreImportMappingOption() {
3982+
return false;
3983+
}
39613984
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private Model getParent(Model model) {
378378
for (String name : modelKeys) {
379379
try {
380380
//don't generate models that have an import mapping
381-
if (config.importMapping().containsKey(name)) {
381+
if (!config.getIgnoreImportMapping() && config.importMapping().containsKey(name)) {
382382
LOGGER.info("Model " + name + " not imported due to import mapping");
383383
continue;
384384
}
@@ -409,7 +409,7 @@ private Model getParent(Model model) {
409409
models.put("modelPackage", config.modelPackage());
410410
try {
411411
//don't generate models that have an import mapping
412-
if (config.importMapping().containsKey(modelName)) {
412+
if (!config.getIgnoreImportMapping() && config.importMapping().containsKey(modelName)) {
413413
continue;
414414
}
415415
Map<String, Object> modelTemplate = (Map<String, Object>) ((List<Object>) models.get("models")).get(0);

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public String toParamName(String name) {
603603
public String toModelName(final String name) {
604604
// We need to check if import-mapping has a different model for this class, so we use it
605605
// instead of the auto-generated one.
606-
if (importMapping.containsKey(name)) {
606+
if (!getIgnoreImportMapping() && importMapping.containsKey(name)) {
607607
return importMapping.get(name);
608608
}
609609

@@ -1349,4 +1349,8 @@ public String sanitizeTag(String tag) {
13491349
return tag;
13501350
}
13511351

1352+
public boolean defaultIgnoreImportMappingOption() {
1353+
return true;
1354+
}
1355+
13521356
}

0 commit comments

Comments
 (0)