forked from loafle/openapi-generator-original
Compare commits
1 Commits
master
...
appdescrip
Author | SHA1 | Date | |
---|---|---|---|
|
e400a48445 |
@ -292,13 +292,11 @@ public class DefaultGenerator implements Generator {
|
||||
// set OpenAPI to make these available to all methods
|
||||
config.setOpenAPI(openAPI);
|
||||
|
||||
if (!config.additionalProperties().containsKey("generatorVersion")) {
|
||||
config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
|
||||
}
|
||||
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
|
||||
config.additionalProperties().put("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||
config.additionalProperties().put("generatorClass", config.getClass().getName());
|
||||
config.additionalProperties().put("inputSpec", config.getInputSpec());
|
||||
config.additionalProperties().putIfAbsent("generatorVersion", ImplementationVersion.read());
|
||||
config.additionalProperties().putIfAbsent("generatedDate", ZonedDateTime.now().toString());
|
||||
config.additionalProperties().putIfAbsent("generatedYear", String.valueOf(ZonedDateTime.now().getYear()));
|
||||
config.additionalProperties().putIfAbsent("generatorClass", config.getClass().getName());
|
||||
config.additionalProperties().putIfAbsent("inputSpec", config.getInputSpec());
|
||||
|
||||
if (openAPI.getExtensions() != null) {
|
||||
config.vendorExtensions().putAll(openAPI.getExtensions());
|
||||
@ -322,59 +320,59 @@ public class DefaultGenerator implements Generator {
|
||||
return;
|
||||
}
|
||||
if (info.getTitle() != null) {
|
||||
config.additionalProperties().put("appName", config.escapeText(info.getTitle()));
|
||||
config.additionalProperties().putIfAbsent("appName", config.escapeText(info.getTitle()));
|
||||
}
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("appVersion", config.escapeText(info.getVersion()));
|
||||
config.additionalProperties().putIfAbsent("appVersion", config.escapeText(info.getVersion()));
|
||||
} else {
|
||||
LOGGER.error("Missing required field info version. Default appVersion set to 1.0.0");
|
||||
config.additionalProperties().put("appVersion", "1.0.0");
|
||||
config.additionalProperties().putIfAbsent("appVersion", "1.0.0");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
// set a default description if none if provided
|
||||
config.additionalProperties().put("appDescription",
|
||||
config.additionalProperties().putIfAbsent("appDescription",
|
||||
"No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
config.additionalProperties().put("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
|
||||
config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.additionalProperties().get("appDescription"));
|
||||
config.additionalProperties().putIfAbsent("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
} else {
|
||||
config.additionalProperties().put("appDescription", config.escapeText(info.getDescription()));
|
||||
config.additionalProperties().put("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
|
||||
config.additionalProperties().put("unescapedAppDescription", info.getDescription());
|
||||
config.additionalProperties().putIfAbsent("appDescription", config.escapeText(info.getDescription()));
|
||||
config.additionalProperties().putIfAbsent("appDescriptionWithNewLines", config.escapeTextWhileAllowingNewLines(info.getDescription()));
|
||||
config.additionalProperties().putIfAbsent("unescapedAppDescription", info.getDescription());
|
||||
}
|
||||
|
||||
if (info.getContact() != null) {
|
||||
Contact contact = info.getContact();
|
||||
if (contact.getEmail() != null) {
|
||||
config.additionalProperties().put("infoEmail", config.escapeText(contact.getEmail()));
|
||||
config.additionalProperties().putIfAbsent("infoEmail", config.escapeText(contact.getEmail()));
|
||||
}
|
||||
if (contact.getName() != null) {
|
||||
config.additionalProperties().put("infoName", config.escapeText(contact.getName()));
|
||||
config.additionalProperties().putIfAbsent("infoName", config.escapeText(contact.getName()));
|
||||
}
|
||||
if (contact.getUrl() != null) {
|
||||
config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl()));
|
||||
config.additionalProperties().putIfAbsent("infoUrl", config.escapeText(contact.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getLicense() != null) {
|
||||
License license = info.getLicense();
|
||||
if (license.getName() != null) {
|
||||
config.additionalProperties().put("licenseInfo", config.escapeText(license.getName()));
|
||||
config.additionalProperties().putIfAbsent("licenseInfo", config.escapeText(license.getName()));
|
||||
}
|
||||
if (license.getUrl() != null) {
|
||||
config.additionalProperties().put("licenseUrl", config.escapeText(license.getUrl()));
|
||||
config.additionalProperties().putIfAbsent("licenseUrl", config.escapeText(license.getUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
if (info.getVersion() != null) {
|
||||
config.additionalProperties().put("version", config.escapeText(info.getVersion()));
|
||||
config.additionalProperties().putIfAbsent("version", config.escapeText(info.getVersion()));
|
||||
} else {
|
||||
LOGGER.error("Missing required field info version. Default version set to 1.0.0");
|
||||
config.additionalProperties().put("version", "1.0.0");
|
||||
config.additionalProperties().putIfAbsent("version", "1.0.0");
|
||||
}
|
||||
|
||||
if (info.getTermsOfService() != null) {
|
||||
config.additionalProperties().put("termsOfService", config.escapeText(info.getTermsOfService()));
|
||||
config.additionalProperties().putIfAbsent("termsOfService", config.escapeText(info.getTermsOfService()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ public class AsciidocGeneratorTest {
|
||||
markupFileGenerated = true;
|
||||
String markupContent = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
|
||||
// check on some basic asciidoc markup content
|
||||
Assert.assertEquals("", markupContent);
|
||||
Assert.assertTrue(markupContent.contains("= ping test"),
|
||||
"expected = header in: " + markupContent.substring(0, 50));
|
||||
Assert.assertTrue(markupContent.contains(":toc: "),
|
||||
|
Loading…
x
Reference in New Issue
Block a user