Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ public class CodeGenMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {

Swagger swagger = new SwaggerParser().read(inputSpec);

//attempt to read from config file
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configurationFile);

Expand Down Expand Up @@ -258,7 +256,7 @@ public void execute() throws MojoExecutionException {
configurator.addSystemProperty(key, value);
}
}

final ClientOptInput input = configurator.toClientOptInput();
final CodegenConfig config = input.getConfig();

Expand All @@ -285,7 +283,7 @@ public void execute() throws MojoExecutionException {
// Maven logs exceptions thrown by plugins only if invoked with -e
// I find it annoying to jump through hoops to get basic diagnostic information,
// so let's log it in any case:
getLog().error(e);
getLog().error(e);
throw new MojoExecutionException("Code generation failed. See above for the full exception.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Swagger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

import java.util.*;
import java.io.File;
Expand Down Expand Up @@ -154,12 +153,12 @@ public HaskellServantCodegen() {
* @return the escaped term
*/
@Override
public String escapeReservedWord(String name) {
public String escapeReservedWord(final String name) {
return name + "_";
}

@Override
public void preprocessSwagger(Swagger swagger) {
public void preprocessSwagger(final Swagger swagger) {
// From the title, compute a reasonable name for the package and the API
String title = swagger.getInfo().getTitle();

Expand Down Expand Up @@ -225,7 +224,7 @@ public void preprocessSwagger(Swagger swagger) {
* @return a string value used as the `dataType` field for model templates, `returnType` for api templates
*/
@Override
public String getTypeDeclaration(Property p) {
public String getTypeDeclaration(final Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
Expand All @@ -246,7 +245,7 @@ public String getTypeDeclaration(Property p) {
* @see io.swagger.models.properties.Property
*/
@Override
public String getSwaggerType(Property p) {
public String getSwaggerType(final Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if (typeMapping.containsKey(swaggerType)) {
Expand All @@ -264,7 +263,7 @@ public String getSwaggerType(Property p) {
}

@Override
public String toInstantiationType(Property p) {
public String toInstantiationType(final Property p) {
if (p instanceof MapProperty) {
MapProperty ap = (MapProperty) p;
Property additionalProperties2 = ap.getAdditionalProperties();
Expand All @@ -288,7 +287,7 @@ public String toInstantiationType(Property p) {


// Intersperse a separator string between a list of strings, like String.join.
private String joinStrings(String sep, List<String> ss) {
private String joinStrings(final String sep, final List<String> ss) {
StringBuilder sb = new StringBuilder();
for (String s : ss) {
if (sb.length() > 0) {
Expand All @@ -303,7 +302,7 @@ private String joinStrings(String sep, List<String> ss) {
// For example, the path /api/jobs/info/{id}/last would become:
// "api" :> "jobs" :> "info" :> Capture "id" IdType :> "last"
// IdType is provided by the capture params.
private List<String> pathToServantRoute(String path, List<CodegenParameter> pathParams) {
private List<String> pathToServantRoute(String path, final List<CodegenParameter> pathParams) {
// Map the capture params by their names.
HashMap<String, String> captureTypes = new HashMap<String, String>();
for (CodegenParameter param : pathParams) {
Expand Down Expand Up @@ -331,7 +330,7 @@ private List<String> pathToServantRoute(String path, List<CodegenParameter> path
}

// Extract the arguments that are passed in the route path parameters
private List<String> pathToClientType(String path, List<CodegenParameter> pathParams) {
private List<String> pathToClientType(String path, final List<CodegenParameter> pathParams) {
// Map the capture params by their names.
HashMap<String, String> captureTypes = new HashMap<String, String>();
for (CodegenParameter param : pathParams) {
Expand All @@ -357,7 +356,7 @@ private List<String> pathToClientType(String path, List<CodegenParameter> pathPa


@Override
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
public CodegenOperation fromOperation(final String resourcePath, final String httpMethod, final Operation operation, final Map<String, Model> definitions, final Swagger swagger) {
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, definitions, swagger);

List<String> path = pathToServantRoute(op.path, op.pathParams);
Expand Down Expand Up @@ -423,7 +422,7 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op
return op;
}

private String makeQueryListType(String type, String collectionFormat) {
private String makeQueryListType(String type, final String collectionFormat) {
type = type.substring(1, type.length() - 1);
switch(collectionFormat) {
case "csv": return "(QueryList 'CommaSeparated (" + type + "))";
Expand All @@ -432,11 +431,11 @@ private String makeQueryListType(String type, String collectionFormat) {
case "pipes": return "(QueryList 'PipeSeparated (" + type + "))";
case "multi": return "(QueryList 'MultiParamArray (" + type + "))";
default:
throw new NotImplementedException();
throw new UnsupportedOperationException();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we keep NotImplementedException as existing programs may be a dependency on this. If we switch it to UnsupportedOperationException, we'll need to flag this change as breaking change, which seems not necessary.

}
}

private String fixOperatorChars(String string) {
private String fixOperatorChars(final String string) {
StringBuilder sb = new StringBuilder();
for (char c : string.toCharArray()) {
if (specialCharReplacements.containsKey(c)) {
Expand All @@ -450,13 +449,13 @@ private String fixOperatorChars(String string) {
}

// Remove characters from a string that do not belong in a model classname
private String fixModelChars(String string) {
private String fixModelChars(final String string) {
return string.replace(".", "").replace("-", "");
}

// Override fromModel to create the appropriate model namings
@Override
public CodegenModel fromModel(String name, Model mod, Map<String, Model> allDefinitions) {
public CodegenModel fromModel(final String name, final Model mod, final Map<String, Model> allDefinitions) {
CodegenModel model = super.fromModel(name, mod, allDefinitions);

// Clean up the class name to remove invalid characters
Expand Down Expand Up @@ -487,7 +486,7 @@ public CodegenModel fromModel(String name, Model mod, Map<String, Model> allDefi
}

@Override
public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
public CodegenParameter fromParameter(final Parameter param, final Set<String> imports) {
CodegenParameter p = super.fromParameter(param, imports);
p.vendorExtensions.put("x-formParamName", camelize(p.baseName));
p.dataType = fixModelChars(p.dataType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.swagger.codegen.Go;
package io.swagger.codegen.go;

import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
Expand Down Expand Up @@ -29,7 +29,7 @@ protected void setExpectations() {
clientCodegen.setPackageVersion(GoClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
clientCodegen.setPackageName(GoClientOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;
times = 1;
}};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.swagger.codegen.Go;
package io.swagger.codegen.go;

import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
Expand Down Expand Up @@ -257,7 +257,7 @@ public static Object[][] primeNumbers() {
}

@Test(dataProvider = "modelNames", description = "avoid inner class")
public void modelNameTest(String name, String expectedName) {
public void modelNameTest(final String name, final String expectedName) {
final Model model = new ModelImpl();
final DefaultCodegen codegen = new GoClientCodegen();
final CodegenModel cm = codegen.fromModel(name, model);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.swagger.codegen.slim;
package io.swagger.codegen.lumen;

import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.swagger.codegen.springBoot;
package io.swagger.codegen.springboot;

import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.java.JavaClientOptionsTest;
Expand Down Expand Up @@ -54,7 +54,7 @@ protected void setExpectations() {
times = 1;
clientCodegen.setBasePackage(SpringBootServerOptionsProvider.BASE_PACKAGE_VALUE);
times = 1;

}};
}
}