Skip to content

Commit c1c341a

Browse files
authored
Merge branch 'master' into patch-1
2 parents d2334fd + 9eb3224 commit c1c341a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/**
5151
* Goal which generates client/server code from a swagger json/yaml definition.
5252
*/
53-
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
53+
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
5454
public class CodeGenMojo extends AbstractMojo {
5555

5656
@Parameter(name = "verbose", required = false, defaultValue = "false")
@@ -315,6 +315,13 @@ public class CodeGenMojo extends AbstractMojo {
315315

316316
@Override
317317
public void execute() throws MojoExecutionException {
318+
// Using the naive approach for achieving thread safety
319+
synchronized (CodeGenMojo.class) {
320+
execute_();
321+
}
322+
}
323+
324+
protected void execute_() throws MojoExecutionException {
318325

319326
if (skip) {
320327
getLog().info("Code generation is skipped.");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ public CodegenModel fromModel(String name, Model model, Map<String, Model> allDe
14771477

14781478
if(parentName != null) {
14791479
m.parentSchema = parentName;
1480-
m.parent = toModelName(parentName);
1480+
m.parent = typeMapping.containsKey(parentName) ? typeMapping.get(parentName): toModelName(parentName);
14811481
addImport(m, m.parent);
14821482
if (allDefinitions != null) {
14831483
final Model parentModel = allDefinitions.get(m.parentSchema);

0 commit comments

Comments
 (0)