rename titleCase, minor code format (#8350)

This commit is contained in:
William Cheng 2021-01-06 23:48:11 +08:00 committed by GitHub
parent 9bd2a45e72
commit 923e246fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 21 deletions

View File

@ -80,7 +80,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
| **Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed, Qt5 QHTTPEngine), **Erlang**, **F#** (Giraffe), **Go** (net/http, Gin), **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, Jersey, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples), [Vert.x](https://vertx.io/)), **Kotlin** (Spring Boot, Ktor, Vertx), **PHP** (Laravel, Lumen, Slim, Silex, [Symfony](https://symfony.com/), [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Rust** (rust-server), **Scala** (Akka, [Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), [Play](https://www.playframework.com/), Scalatra) |
| **API documentation generators** | **HTML**, **Confluence Wiki**, **Asciidoc** |
| **Configuration files** | [**Apache2**](https://httpd.apache.org/) |
| **Others** | **GraphQL**, **JMeter**, **MySQL Schema**, **Protocol Buffer** |
| **Others** | **GraphQL**, **JMeter**, **Ktorm**, **MySQL Schema**, **Protocol Buffer** |
## Table of contents
@ -957,6 +957,7 @@ Here is a list of template creators:
* Schema
* Avro: @sgadouar
* GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328)
* Ktorm: @Luiz-Monad
* MySQL: @ybelenko
* Protocol Buffer: @wing328

View File

@ -640,10 +640,10 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
/**
* Processes each model's property type arguments definitions
*
* @param dataType the choosen sql type
* @param dataFormat the choosen sql format
* @param min the minimum value, if specified, in the target type
* @param max the maximum value, if specified, in the target type
* @param dataType the choosen sql type
* @param dataFormat the choosen sql format
* @param min the minimum value, if specified, in the target type
* @param max the maximum value, if specified, in the target type
* @param columnDefinition resulting column definition dictionary
*/
public void processTypeArgs(String dataType, String dataFormat, Object min, Object max, Map<String, Object> columnDefinition) {
@ -670,9 +670,9 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
/**
* Processes each model's property null/default definitions
*
* @param model model's name
* @param property model's property
* @param description property's customized description
* @param model model's name
* @param property model's property
* @param description property's customized description
* @param columnDefinition resulting column definition dictionary
*/
public void processNullAndDefault(CodegenModel model, CodegenProperty property, String description, Map<String, Object> columnDefinition) {
@ -700,8 +700,8 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
/**
* Processes each model's property that relates to another model
*
* @param model model's name
* @param property model's property
* @param model model's name
* @param property model's property
* @param relationDefinition resulting relation definition dictionary
* @return did we create the foreign key section.
*/
@ -715,9 +715,9 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
Boolean isPrimitive = (tryDataType.startsWith("kotlin.") || tryDataType.startsWith("java."));
String propName = isPrimitive ? property.getName() : tryDataType;
String pkName = titleCase(toModelName(modelName));
String pkName = toTitleCase(toModelName(modelName));
String pkColName = toColumnName(pkName);
String fkName = titleCase(toModelName(propName));
String fkName = toTitleCase(toModelName(propName));
String fkColName = toColumnName(fkName);
String relName = toModelName(camelize(modelName) + camelize(propName));
String relTblName = toTableName(relName);
@ -759,7 +759,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
return true;
}
private String titleCase(final String input) {
private String toTitleCase(final String input) {
return input.substring(0, 1).toLowerCase(Locale.ROOT) + input.substring(1);
}
@ -795,7 +795,7 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
/**
* Checks if the model type should be a relationship instead.
*
* @param dataType type name
* @param dataType type name
* @return is a relation
*/
private boolean isRelation(String dataType) {
@ -939,9 +939,9 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
* Generates codegen default value mapping between ktor and sqlite
* Ref: http://www.sqlite.org/draft/lang_createtable.html, sec3.2
*
* @param defaultValue value
* @param dataType type name
* @param dataFormat type format
* @param defaultValue value
* @param dataType type name
* @param dataFormat type format
* @return generated codegen default
*/
private Map<String, Object> toColumnTypeDefault(String defaultValue, String dataType, String dataFormat) {
@ -1205,15 +1205,14 @@ public class KtormSchemaCodegen extends AbstractKotlinCodegen {
* Slightly modified version of AbstractPhpCodegen.toSrcPath method.
*
* @param packageName package name
*
* @return path
*/
public String toSrcPath(String packageName) {
// Trim prefix file separators from package path
String packagePath = StringUtils.removeStart(
// Replace period, backslash, forward slash with file separator in package name
packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/")),
File.separator
// Replace period, backslash, forward slash with file separator in package name
packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/")),
File.separator
);
// Trim trailing file separators from the overall path