Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated dep versions and enhanced logging #9166

Merged
merged 2 commits into from
Feb 12, 2019
Merged
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
6 changes: 0 additions & 6 deletions modules/swagger-codegen-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,9 @@
<artifactId>swagger-codegen-generators</artifactId>
<version>${swagger-codegen-generators-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
Expand Down
22 changes: 0 additions & 22 deletions modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,35 +203,13 @@
<swagger-codegen-v2-version>2.4.2-SNAPSHOT</swagger-codegen-v2-version>
</properties>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version-v1}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-core</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser-v3</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public String loadSpecContent(String location, List<AuthorizationValue> auths) t
data = ClasspathHelper.loadFileFromClasspath(location);
}
}
LOGGER.debug("Loaded raw data: {}", data);
LOGGER.trace("Loaded raw data: {}", data);
return data;
}

Expand Down Expand Up @@ -470,6 +470,7 @@ public ClientOptInput toClientOptInput() {
input.opts(new ClientOpts())
.openAPI(openAPI);

LOGGER.debug("getClientOptInput - parsed inputSpec");
} else {
String specContent = null;
try {
Expand All @@ -492,7 +493,7 @@ public ClientOptInput toClientOptInput() {
options.setFlatten(true);
SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpecURL, authorizationValues, options);
OpenAPI openAPI = result.getOpenAPI();

LOGGER.debug("getClientOptInput - parsed inputSpecURL " + inputSpecURL);
input.opts(new ClientOpts())
.openAPI(openAPI);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class GeneratorUtil {
protected static final Logger LOGGER = LoggerFactory.getLogger(GeneratorUtil.class);

public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRequest generationRequest) {
LOGGER.debug("getClientOptInputV2 - start");
final Options options = generationRequest.getOptions();
String inputSpec = null;
if (generationRequest.getSpec() == null) {
Expand All @@ -38,7 +39,7 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
String inputSpecURL = generationRequest.getSpecURL();
String lang = generationRequest.getLang();
validateSpec(lang, inputSpec, inputSpecURL);

LOGGER.debug("getClientOptInputV2 - spec validated");
final List<io.swagger.models.auth.AuthorizationValue> authorizationValues = io.swagger.codegen.auth.AuthParser.parse(generationRequest.getOptions().getAuth());
if (generationRequest.getOptions().getAuthorizationValue() != null) {
io.swagger.models.auth.AuthorizationValue authorizationValue = new io.swagger.models.auth.AuthorizationValue()
Expand All @@ -47,7 +48,7 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
.type(generationRequest.getOptions().getAuthorizationValue().getType());
authorizationValues.add(authorizationValue);
}

LOGGER.debug("getClientOptInputV2 - processed auth");

Swagger swagger;
if (StringUtils.isBlank(inputSpec)) {
Expand All @@ -62,6 +63,7 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
} else {
throw new BadRequestException("No swagger specification was supplied");
}
LOGGER.debug("getClientOptInputV2 - parsed inputSpecURL " + inputSpecURL);
} else {
try {
JsonNode node = io.swagger.util.Json.mapper().readTree(inputSpec);
Expand All @@ -74,6 +76,7 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
LOGGER.error("Exception parsing input spec", e);
throw new BadRequestException("The swagger specification supplied was not valid");
}
LOGGER.debug("getClientOptInputV2 - parsed inputSpec");
}
if (swagger == null) {
throw new BadRequestException("The swagger specification supplied was not valid");
Expand Down Expand Up @@ -160,6 +163,7 @@ public static io.swagger.codegen.ClientOptInput getClientOptInputV2(GenerationRe
codegenConfig.additionalProperties().put("swagger", swagger);

clientOptInput.setConfig(codegenConfig);
LOGGER.debug("getClientOptInputV2 - end");
return clientOptInput;
}

Expand All @@ -172,6 +176,7 @@ public static void validateSpec(String lang, String inputSpec, String inputSpecU

}
public static ClientOptInput getClientOptInput(GenerationRequest generationRequest) {
LOGGER.debug("getClientOptInput - start");
final Options options = generationRequest.getOptions();
String inputSpec = null;
if (generationRequest.getSpec() == null) {
Expand All @@ -184,7 +189,7 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque
String inputSpecURL = generationRequest.getSpecURL();
String lang = generationRequest.getLang();
validateSpec(lang, inputSpec, inputSpecURL);

LOGGER.debug("getClientOptInput - validated");
CodegenConfigurator configurator = new CodegenConfigurator();

configurator.setOutputDir(generationRequest.getOptions().getOutputDir());
Expand Down Expand Up @@ -278,7 +283,7 @@ public static ClientOptInput getClientOptInput(GenerationRequest generationReque
configurator.addAdditionalReservedWordMapping(entry.getKey(), entry.getValue());
}
}

LOGGER.debug("getClientOptInput - end");
return configurator.toClientOptInput();
}
}
8 changes: 1 addition & 7 deletions modules/swagger-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,6 @@
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version-v1}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand All @@ -307,7 +302,6 @@
<dependency>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-generators</artifactId>
<version>${swagger-codegen-generators-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
Expand All @@ -330,7 +324,7 @@
<dockerfile.tag.skip>true</dockerfile.tag.skip>
<docker-latest-tag>unstable</docker-latest-tag>
<maven-plugin-version>1.0.0</maven-plugin-version>
<jetty-version>9.4.12.v20180830</jetty-version>
<jetty-version>9.4.14.v20181114</jetty-version>
<inflector-version>2.0.0-rc2</inflector-version>
<junit-version>4.8.2</junit-version>
<servlet-api.version>3.1.0</servlet-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public ResponseContext listOptions(RequestContext requestContext, String languag

public ResponseContext generateFromURL(RequestContext context, String codegenOptionsURL) {
final String content;

LOGGER.debug("generateFromURL start - " + codegenOptionsURL);
try {
content = RemoteUrl.urlToString(codegenOptionsURL, null);
} catch (Exception e) {
Expand Down Expand Up @@ -359,11 +359,64 @@ public ResponseContext generateFromURL(RequestContext context, String codegenOpt
}
}

return generate(context, generationRequest);
ResponseContext responseContext = generate(context, generationRequest);
LOGGER.debug("generateFromURL end - " + codegenOptionsURL);
return responseContext;

}

private String requestLog(GenerationRequest generationRequest) {
final int maxLength = 41;
StringBuffer requestLog = new StringBuffer();
requestLog.append("lang: ");
requestLog.append(generationRequest.getLang());
requestLog.append(", ");
requestLog.append("version: ");
requestLog.append(generationRequest.getCodegenVersion().name());
requestLog.append(", ");
requestLog.append("specURL: ");
requestLog.append(generationRequest.getSpecURL());
requestLog.append(", ");
if (generationRequest.getSpec() != null) {
String spec = null;
if (generationRequest.getSpec() instanceof String && StringUtils.isNotBlank((String) generationRequest.getSpec())) {
if (((String) generationRequest.getSpec()).length() > maxLength) {
spec = ((String) generationRequest.getSpec()).substring(0, 40);
} else {
spec = ((String) generationRequest.getSpec());
}
requestLog.append("spec: ");
requestLog.append(spec);
requestLog.append(", ");
} else {
try {
spec = Json.pretty(generationRequest.getSpec());
if (spec.length() > maxLength) {
spec = spec.substring(0, 40);
}
requestLog.append("spec: ");
requestLog.append(spec);
requestLog.append(", ");
} catch (Exception e) {
requestLog.append("spec: ");
requestLog.append(spec);
requestLog.append(", ");
}
}
}
if (generationRequest.getOptions() != null) {
if (StringUtils.isNotBlank(generationRequest.getOptions().getLibrary())) {
requestLog.append("lib: ");
requestLog.append(generationRequest.getOptions().getLibrary());
}
}
return requestLog.toString();
}

public ResponseContext generate(RequestContext context, GenerationRequest generationRequest) {

String requestLog = requestLog(generationRequest);
LOGGER.debug("generate start - " + requestLog);
File outputRootFolder = getTmpFolder();
String destPath = null;

Expand Down Expand Up @@ -406,7 +459,9 @@ public ResponseContext generate(RequestContext context, GenerationRequest genera

LOGGER.info("file zip file: " + outputFile.getAbsolutePath());

return generate(generationRequest, outputRootFolder, outputContentFolder, outputFile);
ResponseContext responseContext = generate(generationRequest, outputRootFolder, outputContentFolder, outputFile);
LOGGER.debug("generate end - " + requestLog);
return responseContext;

}

Expand Down
6 changes: 6 additions & 0 deletions modules/swagger-generator/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<logger name="io.swagger" level="ERROR"/>
<logger name="org.eclipse.jetty.server" level="INFO"/>
<logger name="io.swagger.v3.generator.online" level="DEBUG"/>
<!--
<logger name="io.swagger.codegen.v3.service" level="DEBUG"/>
<logger name="io.swagger.codegen.v3.config" level="DEBUG"/>
<logger name="io.swagger.codegen.v3.generators.DefaultCodegenConfig" level="TRACE"/>
-->

<root level="WARN">
<appender-ref ref="STDOUT"/>
</root>
Expand Down
Loading