mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
Minor enhancements to the MySQL generator (#1148)
* minor enhancements to the mysql generator * add ybelenko to the README
This commit is contained in:
parent
e4b5f50515
commit
3a5ec0a69d
@ -46,7 +46,7 @@ OpenAPI Generator allows generation of API client libraries (SDK generation), se
|
||||
**Server stubs** | **Ada**, **C#** (ASP.NET Core, NancyFx), **C++** (Pistache, Restbed), **Erlang**, **Go**, **Haskell** (Servant), **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy, Play Framework, [PKMST](https://github.com/ProKarma-Inc/pkmst-getting-started-examples)), **Kotlin** (Spring Boot), **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** ([Finch](https://github.com/finagle/finch), [Lagom](https://github.com/lagom/lagom), Scalatra)
|
||||
**API documentation generators** | **HTML**, **Confluence Wiki**
|
||||
**Configuration files** | [**Apache2**](https://httpd.apache.org/)
|
||||
**Others** | **JMeter**
|
||||
**Others** | **JMeter**, **MySQL Schema**
|
||||
|
||||
## Table of contents
|
||||
|
||||
@ -603,6 +603,8 @@ Here is a list of template creators:
|
||||
* Confluence Wiki: @jhitchcock
|
||||
* Configuration
|
||||
* Apache2: @stkrwork
|
||||
* Schema
|
||||
* MySQL: @ybelenko
|
||||
|
||||
#### How to join the core team
|
||||
|
||||
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/mysql-schema -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g mysql-schema -o samples/schema/petstore/mysql $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
10
bin/windows/mysql-schema-petstore.bat
Executable file
10
bin/windows/mysql-schema-petstore.bat
Executable file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g mysql-schema -o samples\schema\petstore\mysql
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -311,7 +311,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (Boolean.TRUE.equals(isEnum)) {
|
||||
Map<String, Object> allowableValues = property.getAllowableValues();
|
||||
List<Object> enumValues = (List<Object>) allowableValues.get("values");
|
||||
for (Integer i = 0; i< enumValues.size(); i++) {
|
||||
for (Integer i = 0; i < enumValues.size(); i++) {
|
||||
if (i > ENUM_MAX_ELEMENTS - 1) {
|
||||
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
|
||||
break;
|
||||
@ -322,7 +322,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
columnDefinition.put("colDataType", "ENUM");
|
||||
columnDefinition.put("colDataTypeArguments", columnDataTypeArguments);
|
||||
} else {
|
||||
if (dataFormat == "int64") {
|
||||
if ("int64".equals(dataFormat)) {
|
||||
columnDefinition.put("colDataType", "BIGINT");
|
||||
} else {
|
||||
Long min = (minimum != null) ? Long.parseLong(minimum) : null;
|
||||
@ -391,7 +391,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (Boolean.TRUE.equals(isEnum)) {
|
||||
Map<String, Object> allowableValues = property.getAllowableValues();
|
||||
List<Object> enumValues = (List<Object>) allowableValues.get("values");
|
||||
for (Integer i = 0; i< enumValues.size(); i++) {
|
||||
for (Integer i = 0; i < enumValues.size(); i++) {
|
||||
if (i > ENUM_MAX_ELEMENTS - 1) {
|
||||
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
|
||||
break;
|
||||
@ -515,7 +515,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
List<Object> enumValues = (List<Object>) allowableValues.get("values");
|
||||
columnDefinition.put("colDataType", "ENUM");
|
||||
columnDefinition.put("colDataTypeArguments", columnDataTypeArguments);
|
||||
for (Integer i = 0; i< enumValues.size(); i++) {
|
||||
for (Integer i = 0; i < enumValues.size(); i++) {
|
||||
if (i > ENUM_MAX_ELEMENTS - 1) {
|
||||
LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i));
|
||||
break;
|
||||
@ -523,7 +523,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String value = String.valueOf(enumValues.get(i));
|
||||
columnDataTypeArguments.add(toCodegenMysqlDataTypeArgument(value, (Boolean) (i + 1 < enumValues.size())));
|
||||
}
|
||||
} else if (dataType.equals("MEDIUMBLOB")){
|
||||
} else if (dataType.equals("MEDIUMBLOB")) {
|
||||
columnDefinition.put("colDataType", "MEDIUMBLOB");
|
||||
} else {
|
||||
String matchedStringType = getMysqlMatchedStringDataType(minLength, maxLength);
|
||||
@ -855,7 +855,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (minLength != null && maxLength != null && minLength > maxLength) {
|
||||
LOGGER.warn("Codegen property 'minLength' cannot be greater than 'maxLength'");
|
||||
}
|
||||
if (actualMax.equals(actualMin) && actualMax <= 255 ) {
|
||||
if (actualMax.equals(actualMin) && actualMax <= 255) {
|
||||
return "CHAR";
|
||||
} else if (actualMax <= 255) {
|
||||
return "VARCHAR";
|
||||
@ -947,7 +947,7 @@ public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String escapedName = escapeMysqlQuotedIdentifier(name);
|
||||
// Database, table, and column names cannot end with space characters.
|
||||
if (escapedName.matches(".*\\s$")) {
|
||||
LOGGER.warn("Database, table, and column names cannot end with space characters. Check '" + name + "' name" );
|
||||
LOGGER.warn("Database, table, and column names cannot end with space characters. Check '" + name + "' name");
|
||||
escapedName = escapedName.replaceAll("\\s+$", "");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user