Kotlin model name camelize (#2430)

* Kotlin model name camelize

* Update samples
This commit is contained in:
Thibault Duperron 2019-03-24 03:47:05 +01:00 committed by William Cheng
parent f7943257c5
commit 0935f5345d
58 changed files with 431 additions and 458 deletions

View File

@ -597,10 +597,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
private String sanitizeKotlinSpecificNames(final String name) {
String word = name;
for (Map.Entry<String, String> specialCharacters : specialCharReplacements.entrySet()) {
// Underscore is the only special character we'll allow
if (!specialCharacters.getKey().equals("_")) {
word = word.replaceAll("\\Q" + specialCharacters.getKey() + "\\E", specialCharacters.getValue());
}
word = replaceSpecialCharacters(word, specialCharacters);
}
// Fallback, replace unknowns with underscore.
@ -617,6 +614,38 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
return word;
}
private String replaceSpecialCharacters(String word, Map.Entry<String, String> specialCharacters) {
String specialChar = specialCharacters.getKey();
String replacementChar = specialCharacters.getValue();
// Underscore is the only special character we'll allow
if (!specialChar.equals("_") && word.contains(specialChar)) {
return replaceCharacters(word, specialChar, replacementChar);
}
return word;
}
private String replaceCharacters(String word, String oldValue, String newValue) {
if (!word.contains(oldValue)) {
return word;
}
if ( word.equals(oldValue)) {
return newValue;
}
int i = word.indexOf(oldValue);
String start = word.substring(0, i);
String end = recurseOnEndOfWord(word, oldValue, newValue, i);
return start + newValue + end;
}
private String recurseOnEndOfWord(String word, String oldValue, String newValue, int lastReplacedValue) {
String end = word.substring(lastReplacedValue + 1);
if (!end.isEmpty()) {
end = titleCase(end);
end = replaceCharacters(end, oldValue, newValue);
}
return end;
}
private String titleCase(final String input) {
return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1);
}

View File

@ -15,22 +15,22 @@ public class StringUtils {
* @param word The word
* @return The underscored version of the word
*/
public static String underscore(String word) {
public static String underscore(final String word) {
String firstPattern = "([A-Z]+)([A-Z][a-z])";
String secondPattern = "([a-z\\d])([A-Z])";
String replacementPattern = "$1_$2";
// Replace package separator with slash.
word = word.replaceAll("\\.", "/"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
String result = word.replaceAll("\\.", "/");
// Replace $ with two underscores for inner classes.
word = word.replaceAll("\\$", "__");
result = result.replaceAll("\\$", "__");
// Replace capital letter with _ plus lowercase letter.
word = word.replaceAll(firstPattern, replacementPattern);
word = word.replaceAll(secondPattern, replacementPattern);
word = word.replace('-', '_');
result = result.replaceAll(firstPattern, replacementPattern);
result = result.replaceAll(secondPattern, replacementPattern);
result = result.replace('-', '_');
// replace space with underscore
word = word.replace(' ', '_');
word = word.toLowerCase(Locale.ROOT);
return word;
result = result.replace(' ', '_');
result = result.toLowerCase(Locale.ROOT);
return result;
}
/**

View File

@ -85,17 +85,24 @@ public class AbstractKotlinCodegenTest {
}
@Test
public void toModelNameShouldUseProvidedMapping() throws Exception {
public void toModelNameShouldUseProvidedMapping() {
codegen.importMapping().put("json_myclass", "com.test.MyClass");
assertEquals("com.test.MyClass", codegen.toModelName("json_myclass"));
}
@Test
public void convertModelName() throws Exception {
public void convertModelNameTitleCase() {
assertEquals(codegen.toModelName("name"), "Name");
assertEquals(codegen.toModelName("$name"), "Dollarname");
assertEquals(codegen.toModelName("nam#e"), "NamHashe");
assertEquals(codegen.toModelName("$another-fake?"), "DollaranotherMinusfakeQuestionMark");
}
@Test
public void escapeSpecialCharactersCamelize() {
assertEquals(codegen.toModelName("$"), "Dollar");
assertEquals(codegen.toModelName("$$"), "DollarDollar");
assertEquals(codegen.toModelName("Pony?"), "PonyQuestionMark");
assertEquals(codegen.toModelName("$name"), "DollarName");
assertEquals(codegen.toModelName("nam#e"), "NamHashE");
assertEquals(codegen.toModelName("$another-fake?"), "DollarAnotherMinusFakeQuestionMark");
assertEquals(codegen.toModelName("Pony>=>="), "PonyGreaterThanEqualGreaterThanEqual");
}
}

View File

@ -5,9 +5,15 @@ import org.testng.annotations.Test;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class StringUtilsTest {
// we'll assume that <i>underscore</i> (Twitter elephant bird) works fine
@Test
public void testUnderscore() {
Assert.assertEquals(underscore("abcd"), "abcd");
Assert.assertEquals(underscore("abCd"), "ab_cd");
}
@Test
public void testCamelize() throws Exception {

View File

@ -37,6 +37,7 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooget) | **GET** /foo |
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
@ -95,6 +96,7 @@ Class | Method | HTTP request | Description
- [org.openapitools.client.models.Foo](docs/Foo.md)
- [org.openapitools.client.models.FormatTest](docs/FormatTest.md)
- [org.openapitools.client.models.HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [org.openapitools.client.models.HealthCheckResult](docs/HealthCheckResult.md)
- [org.openapitools.client.models.InlineObject](docs/InlineObject.md)
- [org.openapitools.client.models.InlineObject1](docs/InlineObject1.md)
- [org.openapitools.client.models.InlineObject2](docs/InlineObject2.md)
@ -111,6 +113,9 @@ Class | Method | HTTP request | Description
- [org.openapitools.client.models.Order](docs/Order.md)
- [org.openapitools.client.models.OuterComposite](docs/OuterComposite.md)
- [org.openapitools.client.models.OuterEnum](docs/OuterEnum.md)
- [org.openapitools.client.models.OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
- [org.openapitools.client.models.OuterEnumInteger](docs/OuterEnumInteger.md)
- [org.openapitools.client.models.OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
- [org.openapitools.client.models.Pet](docs/Pet.md)
- [org.openapitools.client.models.ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [org.openapitools.client.models.Return](docs/Return.md)
@ -136,6 +141,11 @@ Class | Method | HTTP request | Description
- **API key parameter name**: api_key_query
- **Location**: URL query string
<a name="bearer_test"></a>
### bearer_test
- **Type**: HTTP basic authentication
<a name="http_basic_test"></a>
### http_basic_test

View File

@ -6,9 +6,9 @@
* `abc` (value: `"_abc"`)
* `minusefg` (value: `"-efg"`)
* `minusEfg` (value: `"-efg"`)
* `leftParenthesisxyzRightParenthesis` (value: `"(xyz)"`)
* `leftParenthesisXyzRightParenthesis` (value: `"(xyz)"`)

View File

@ -9,6 +9,9 @@ Name | Type | Description | Notes
**enumInteger** | [**inline**](#EnumIntegerEnum) | | [optional]
**enumNumber** | [**inline**](#EnumNumberEnum) | | [optional]
**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional]
**outerEnumInteger** | [**OuterEnumInteger**](OuterEnumInteger.md) | | [optional]
**outerEnumDefaultValue** | [**OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional]
**outerEnumIntegerDefaultValue** | [**OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [optional]
<a name="EnumStringEnum"></a>

View File

@ -4,6 +4,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
@ -18,6 +19,47 @@ Method | HTTP request | Description
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
<a name="fakeHealthGet"></a>
# **fakeHealthGet**
> HealthCheckResult fakeHealthGet()
Health check endpoint
### Example
```kotlin
// Import classes:
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*
val apiInstance = FakeApi()
try {
val result : HealthCheckResult = apiInstance.fakeHealthGet()
println(result)
} catch (e: ClientException) {
println("4xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
} catch (e: ServerException) {
println("5xx response calling FakeApi#fakeHealthGet")
e.printStackTrace()
}
```
### Parameters
This endpoint does not need any parameter.
### Return type
[**HealthCheckResult**](HealthCheckResult.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
<a name="fakeOuterBooleanSerialize"></a>
# **fakeOuterBooleanSerialize**
> kotlin.Boolean fakeOuterBooleanSerialize(body)
@ -127,7 +169,7 @@ Test serialization of outer number types
//import org.openapitools.client.models.*
val apiInstance = FakeApi()
val body : java.math.BigDecimal = 1.2 // java.math.BigDecimal | Input number as post body
val body : java.math.BigDecimal = 8.14 // java.math.BigDecimal | Input number as post body
try {
val result : java.math.BigDecimal = apiInstance.fakeOuterNumberSerialize(body)
println(result)
@ -360,7 +402,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
//import org.openapitools.client.models.*
val apiInstance = FakeApi()
val number : java.math.BigDecimal = 1.2 // java.math.BigDecimal | None
val number : java.math.BigDecimal = 8.14 // java.math.BigDecimal | None
val double : kotlin.Double = 1.2 // kotlin.Double | None
val patternWithoutDelimiter : kotlin.String = patternWithoutDelimiter_example // kotlin.String | None
val byte : kotlin.ByteArray = BYTE_ARRAY_DATA_HERE // kotlin.ByteArray | None
@ -526,7 +568,7 @@ null (empty response body)
### Authorization
No authorization required
[bearer_test](../README.md#bearer_test)
### HTTP request headers

View File

@ -0,0 +1,10 @@
# HealthCheckResult
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**nullableMessage** | **kotlin.String** | | [optional]

View File

@ -0,0 +1,14 @@
# OuterEnumDefaultValue
## Enum
* `placed` (value: `"placed"`)
* `approved` (value: `"approved"`)
* `delivered` (value: `"delivered"`)

View File

@ -0,0 +1,14 @@
# OuterEnumInteger
## Enum
* `_0` (value: `0`)
* `_1` (value: `1`)
* `_2` (value: `2`)

View File

@ -0,0 +1,14 @@
# OuterEnumIntegerDefaultValue
## Enum
* `_0` (value: `0`)
* `_1` (value: `1`)
* `_2` (value: `2`)

View File

@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -13,6 +13,7 @@ package org.openapitools.client.apis
import org.openapitools.client.models.Client
import org.openapitools.client.models.FileSchemaTestClass
import org.openapitools.client.models.HealthCheckResult
import org.openapitools.client.models.OuterComposite
import org.openapitools.client.models.User
@ -20,6 +21,37 @@ import org.openapitools.client.infrastructure.*
class FakeApi(basePath: kotlin.String = "http://petstore.swagger.io:80/v2") : ApiClient(basePath) {
/**
* Health check endpoint
*
* @return HealthCheckResult
*/
@Suppress("UNCHECKED_CAST")
fun fakeHealthGet() : HealthCheckResult {
val localVariableBody: kotlin.Any? = null
val localVariableQuery: MultiValueMap = mapOf()
val localVariableHeaders: kotlin.collections.Map<kotlin.String,kotlin.String> = mapOf()
val localVariableConfig = RequestConfig(
RequestMethod.GET,
"/fake/health",
query = localVariableQuery,
headers = localVariableHeaders
)
val response = request<HealthCheckResult>(
localVariableConfig,
localVariableBody
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as HealthCheckResult
ResponseType.Informational -> TODO()
ResponseType.Redirection -> TODO()
ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error")
ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error")
else -> throw kotlin.IllegalStateException("Undefined ResponseType.")
}
}
/**
*
* Test serialization of outer boolean types

View File

@ -60,7 +60,9 @@ open class ApiClient(val baseUrl: String) {
fun toJson(uuid: UUID) = uuid.toString()
@FromJson
fun fromJson(s: String) = UUID.fromString(s)
}).build().adapter(T::class.java).fromJson(body.source())
})
.add(ByteArrayAdapter())
.build().adapter(T::class.java).fromJson(body.source())
else -> TODO()
}
}

View File

@ -0,0 +1,12 @@
package org.openapitools.client.infrastructure
import com.squareup.moshi.FromJson
import com.squareup.moshi.ToJson
class ByteArrayAdapter {
@ToJson
fun toJson(data: ByteArray): String = String(data)
@FromJson
fun fromJson(data: String): ByteArray = data.toByteArray()
}

View File

@ -16,15 +16,15 @@ import com.squareup.moshi.Json
/**
*
* Values: abc,minusefg,leftParenthesisxyzRightParenthesis
* Values: abc,minusEfg,leftParenthesisXyzRightParenthesis
*/
enum class EnumClass(val value: kotlin.String){
@Json(name = "_abc") abc("_abc"),
@Json(name = "-efg") minusefg("-efg"),
@Json(name = "-efg") minusEfg("-efg"),
@Json(name = "(xyz)") leftParenthesisxyzRightParenthesis("(xyz)");
@Json(name = "(xyz)") leftParenthesisXyzRightParenthesis("(xyz)");
}

View File

@ -12,6 +12,9 @@
package org.openapitools.client.models
import org.openapitools.client.models.OuterEnum
import org.openapitools.client.models.OuterEnumDefaultValue
import org.openapitools.client.models.OuterEnumInteger
import org.openapitools.client.models.OuterEnumIntegerDefaultValue
import com.squareup.moshi.Json
/**
@ -21,13 +24,19 @@ import com.squareup.moshi.Json
* @param enumInteger
* @param enumNumber
* @param outerEnum
* @param outerEnumInteger
* @param outerEnumDefaultValue
* @param outerEnumIntegerDefaultValue
*/
data class EnumTest (
val enumStringRequired: EnumTest.EnumStringRequired,
val enumString: EnumTest.EnumString? = null,
val enumInteger: EnumTest.EnumInteger? = null,
val enumNumber: EnumTest.EnumNumber? = null,
val outerEnum: OuterEnum? = null
val outerEnum: OuterEnum? = null,
val outerEnumInteger: OuterEnumInteger? = null,
val outerEnumDefaultValue: OuterEnumDefaultValue? = null,
val outerEnumIntegerDefaultValue: OuterEnumIntegerDefaultValue? = null
) {
/**

View File

@ -0,0 +1,24 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
/**
* Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
* @param nullableMessage
*/
data class HealthCheckResult (
val nullableMessage: kotlin.String? = null
) {
}

View File

@ -39,15 +39,15 @@ data class InlineObject2 (
/**
* Form parameter enum test (string)
* Values: abc,minusefg,leftParenthesisxyzRightParenthesis
* Values: abc,minusEfg,leftParenthesisXyzRightParenthesis
*/
enum class EnumFormString(val value: kotlin.String){
@Json(name = "_abc") abc("_abc"),
@Json(name = "-efg") minusefg("-efg"),
@Json(name = "-efg") minusEfg("-efg"),
@Json(name = "(xyz)") leftParenthesisxyzRightParenthesis("(xyz)");
@Json(name = "(xyz)") leftParenthesisXyzRightParenthesis("(xyz)");
}

View File

@ -0,0 +1,30 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import com.squareup.moshi.Json
/**
*
* Values: placed,approved,delivered
*/
enum class OuterEnumDefaultValue(val value: kotlin.String){
@Json(name = "placed") placed("placed"),
@Json(name = "approved") approved("approved"),
@Json(name = "delivered") delivered("delivered");
}

View File

@ -0,0 +1,30 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import com.squareup.moshi.Json
/**
*
* Values: _0,_1,_2
*/
enum class OuterEnumInteger(val value: kotlin.Int){
@Json(name = "0") _0(0),
@Json(name = "1") _1(1),
@Json(name = "2") _2(2);
}

View File

@ -0,0 +1,30 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.models
import com.squareup.moshi.Json
/**
*
* Values: _0,_1,_2
*/
enum class OuterEnumIntegerDefaultValue(val value: kotlin.Int){
@Json(name = "0") _0(0),
@Json(name = "1") _1(1),
@Json(name = "2") _2(2);
}

View File

@ -1,46 +0,0 @@
package org.openapitools.api
import org.openapitools.model.SysMailFormData
import io.swagger.annotations.*
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.web.multipart.MultipartFile
import org.springframework.beans.factory.annotation.Autowired
import javax.validation.Valid
import javax.validation.constraints.*
import kotlin.collections.List
import kotlin.collections.Map
@Controller
@Validated
@Api(value = "Default", description = "The Default API")
@RequestMapping("\${api.base-path:/v2}")
class DefaultApiController(@Autowired(required = true) val service: DefaultApiService) {
@ApiOperation(
value = "",
nickname = "updateSysMailAtKey",
notes = "Update SysMail template")
@ApiResponses(
value = [ApiResponse(code = 200, message = "OK")])
@RequestMapping(
value = ["/sysmails/{key}"],
consumes = ["application/json"],
method = [RequestMethod.PUT])
fun updateSysMailAtKey(@ApiParam(value = "", required=true, defaultValue="null") @PathVariable("key") key: String,@ApiParam(value = "" ,required=true ) @Valid @RequestBody sysMailFormData: SysMailFormData): ResponseEntity<Unit> {
return ResponseEntity(service.updateSysMailAtKey(key, sysMailFormData), HttpStatus.OK)
}
}

View File

@ -1,8 +0,0 @@
package org.openapitools.api
import org.openapitools.model.SysMailFormData
interface DefaultApiService {
fun updateSysMailAtKey(key: String,sysMailFormData: SysMailFormData): Unit
}

View File

@ -1,12 +0,0 @@
package org.openapitools.api
import org.openapitools.model.SysMailFormData
import org.springframework.stereotype.Service
@Service
class DefaultApiServiceImpl : DefaultApiService {
override fun updateSysMailAtKey(key: String,sysMailFormData: SysMailFormData): Unit {
TODO("Implement me")
}
}

View File

@ -33,7 +33,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@ApiOperation(
value = "Create user",
nickname = "createUser",
notes = "This can only be done by the logged in user.")
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@ -47,7 +48,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithArrayInput",
notes = "")
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@ -61,7 +63,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithListInput",
notes = "")
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@ -75,7 +78,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@ApiOperation(
value = "Delete user",
nickname = "deleteUser",
notes = "This can only be done by the logged in user.")
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
@ -111,14 +115,15 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/login"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity<String> {
fun loginUser(@NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity<String> {
return ResponseEntity(service.loginUser(username, password), HttpStatus.OK)
}
@ApiOperation(
value = "Logs out current logged in user session",
nickname = "logoutUser",
notes = "")
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@ -131,7 +136,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@ApiOperation(
value = "Updated user",
nickname = "updateUser",
notes = "This can only be done by the logged in user.")
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(

View File

@ -15,7 +15,7 @@ data class Category (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: String? = null
) {

View File

@ -1,24 +0,0 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.Valid
import javax.validation.constraints.*
import io.swagger.annotations.ApiModelProperty
/**
* Data to update a SysMail template.
* @param subject
* @param body
*/
data class SysMailFormData (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("subject") val subject: String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("body") val body: String? = null
) {
}

View File

@ -1 +1 @@
3.3.0-SNAPSHOT
4.0.0-SNAPSHOT

View File

@ -42,8 +42,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.POST])
fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet): ResponseEntity<Unit> {
return ResponseEntity(service.addPet(pet), HttpStatus.OK)
fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
return ResponseEntity(service.addPet(body), HttpStatus.OK)
}
@ApiOperation(
@ -56,7 +56,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
@RequestMapping(
value = ["/pet/{petId}"],
method = [RequestMethod.DELETE])
fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: String?): ResponseEntity<Unit> {
fun deletePet(@ApiParam(value = "Pet id to delete", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "" , defaultValue="null") @RequestHeader(value="api_key", required=false) apiKey: String): ResponseEntity<Unit> {
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK)
}
@ -73,7 +73,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: List<String>): ResponseEntity<List<Pet>> {
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold", defaultValue = "null") @Valid @RequestParam(value = "status", required = true, defaultValue="null") status: List<String>): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK)
}
@ -90,7 +90,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: List<String>): ResponseEntity<List<Pet>> {
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true, defaultValue = "null") @Valid @RequestParam(value = "tags", required = true, defaultValue="null") tags: List<String>): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.OK)
}
@ -106,7 +106,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long): ResponseEntity<Pet> {
fun getPetById(@ApiParam(value = "ID of pet to return", required=true, defaultValue="null") @PathVariable("petId") petId: Long): ResponseEntity<Pet> {
return ResponseEntity(service.getPetById(petId), HttpStatus.OK)
}
@ -121,8 +121,8 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.PUT])
fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet): ResponseEntity<Unit> {
return ResponseEntity(service.updatePet(pet), HttpStatus.OK)
fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
return ResponseEntity(service.updatePet(body), HttpStatus.OK)
}
@ApiOperation(
@ -136,7 +136,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
value = ["/pet/{petId}"],
consumes = ["application/x-www-form-urlencoded"],
method = [RequestMethod.POST])
fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity<Unit> {
fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Updated name of the pet", defaultValue="null") @RequestParam(value="name", required=false) name: String ,@ApiParam(value = "Updated status of the pet", defaultValue="null") @RequestParam(value="status", required=false) status: String ): ResponseEntity<Unit> {
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK)
}
@ -153,7 +153,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
produces = ["application/json"],
consumes = ["multipart/form-data"],
method = [RequestMethod.POST])
fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity<ModelApiResponse> {
fun uploadFile(@ApiParam(value = "ID of pet to update", required=true, defaultValue="null") @PathVariable("petId") petId: Long,@ApiParam(value = "Additional data to pass to server", defaultValue="null") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String ,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: MultipartFile): ResponseEntity<ModelApiResponse> {
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK)
}
}

View File

@ -5,9 +5,9 @@ import org.openapitools.model.Pet
interface PetApiService {
fun addPet(pet: Pet): Unit
fun addPet(body: Pet): Unit
fun deletePet(petId: Long,apiKey: String?): Unit
fun deletePet(petId: Long,apiKey: String): Unit
fun findPetsByStatus(status: List<String>): List<Pet>
@ -15,7 +15,7 @@ interface PetApiService {
fun getPetById(petId: Long): Pet
fun updatePet(pet: Pet): Unit
fun updatePet(body: Pet): Unit
fun updatePetWithForm(petId: Long,name: String,status: String): Unit

View File

@ -7,11 +7,11 @@ import org.springframework.stereotype.Service
@Service
class PetApiServiceImpl : PetApiService {
override fun addPet(pet: Pet): Unit {
override fun addPet(body: Pet): Unit {
TODO("Implement me")
}
override fun deletePet(petId: Long,apiKey: String?): Unit {
override fun deletePet(petId: Long,apiKey: String): Unit {
TODO("Implement me")
}
@ -27,7 +27,7 @@ class PetApiServiceImpl : PetApiService {
TODO("Implement me")
}
override fun updatePet(pet: Pet): Unit {
override fun updatePet(body: Pet): Unit {
TODO("Implement me")
}

View File

@ -39,7 +39,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
@RequestMapping(
value = ["/store/order/{orderId}"],
method = [RequestMethod.DELETE])
fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String): ResponseEntity<Unit> {
fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true, defaultValue="null") @PathVariable("orderId") orderId: String): ResponseEntity<Unit> {
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK)
}
@ -71,7 +71,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
value = ["/store/order/{orderId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: Long): ResponseEntity<Order> {
fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true, defaultValue="null") @PathVariable("orderId") orderId: Long): ResponseEntity<Order> {
return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK)
}
@ -86,7 +86,7 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
value = ["/store/order"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.POST])
fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order): ResponseEntity<Order> {
return ResponseEntity(service.placeOrder(order), HttpStatus.OK)
fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody body: Order): ResponseEntity<Order> {
return ResponseEntity(service.placeOrder(body), HttpStatus.OK)
}
}

View File

@ -10,5 +10,5 @@ interface StoreApiService {
fun getOrderById(orderId: Long): Order
fun placeOrder(order: Order): Order
fun placeOrder(body: Order): Order
}

View File

@ -18,7 +18,7 @@ class StoreApiServiceImpl : StoreApiService {
TODO("Implement me")
}
override fun placeOrder(order: Order): Order {
override fun placeOrder(body: Order): Order {
TODO("Implement me")
}
}

View File

@ -39,8 +39,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping(
value = ["/user"],
method = [RequestMethod.POST])
fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity<Unit> {
return ResponseEntity(service.createUser(user), HttpStatus.OK)
fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity<Unit> {
return ResponseEntity(service.createUser(body), HttpStatus.OK)
}
@ApiOperation(
@ -52,8 +52,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping(
value = ["/user/createWithArray"],
method = [RequestMethod.POST])
fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: List<User>): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.OK)
fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List<User>): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.OK)
}
@ApiOperation(
@ -65,8 +65,8 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping(
value = ["/user/createWithList"],
method = [RequestMethod.POST])
fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: List<User>): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.OK)
fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody body: List<User>): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.OK)
}
@ApiOperation(
@ -78,7 +78,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping(
value = ["/user/{username}"],
method = [RequestMethod.DELETE])
fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: String): ResponseEntity<Unit> {
fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity<Unit> {
return ResponseEntity(service.deleteUser(username), HttpStatus.OK)
}
@ -93,7 +93,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/{username}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: String): ResponseEntity<User> {
fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true, defaultValue="null") @PathVariable("username") username: String): ResponseEntity<User> {
return ResponseEntity(service.getUserByName(username), HttpStatus.OK)
}
@ -108,7 +108,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
value = ["/user/login"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: String): ResponseEntity<String> {
fun loginUser(@NotNull @ApiParam(value = "The user name for login", required = true, defaultValue = "null") @Valid @RequestParam(value = "username", required = true, defaultValue="null") username: String,@NotNull @ApiParam(value = "The password for login in clear text", required = true, defaultValue = "null") @Valid @RequestParam(value = "password", required = true, defaultValue="null") password: String): ResponseEntity<String> {
return ResponseEntity(service.loginUser(username, password), HttpStatus.OK)
}
@ -134,7 +134,7 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
@RequestMapping(
value = ["/user/{username}"],
method = [RequestMethod.PUT])
fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User): ResponseEntity<Unit> {
return ResponseEntity(service.updateUser(username, user), HttpStatus.OK)
fun updateUser(@ApiParam(value = "name that need to be deleted", required=true, defaultValue="null") @PathVariable("username") username: String,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody body: User): ResponseEntity<Unit> {
return ResponseEntity(service.updateUser(username, body), HttpStatus.OK)
}
}

View File

@ -4,11 +4,11 @@ import org.openapitools.model.User
interface UserApiService {
fun createUser(user: User): Unit
fun createUser(body: User): Unit
fun createUsersWithArrayInput(user: List<User>): Unit
fun createUsersWithArrayInput(body: List<User>): Unit
fun createUsersWithListInput(user: List<User>): Unit
fun createUsersWithListInput(body: List<User>): Unit
fun deleteUser(username: String): Unit
@ -18,5 +18,5 @@ interface UserApiService {
fun logoutUser(): Unit
fun updateUser(username: String,user: User): Unit
fun updateUser(username: String,body: User): Unit
}

View File

@ -6,15 +6,15 @@ import org.springframework.stereotype.Service
@Service
class UserApiServiceImpl : UserApiService {
override fun createUser(user: User): Unit {
override fun createUser(body: User): Unit {
TODO("Implement me")
}
override fun createUsersWithArrayInput(user: List<User>): Unit {
override fun createUsersWithArrayInput(body: List<User>): Unit {
TODO("Implement me")
}
override fun createUsersWithListInput(user: List<User>): Unit {
override fun createUsersWithListInput(body: List<User>): Unit {
TODO("Implement me")
}
@ -34,7 +34,7 @@ class UserApiServiceImpl : UserApiService {
TODO("Implement me")
}
override fun updateUser(username: String,user: User): Unit {
override fun updateUser(username: String,body: User): Unit {
TODO("Implement me")
}
}

View File

@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Category (
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: String? = null
) {

View File

@ -14,13 +14,13 @@ import io.swagger.annotations.ApiModelProperty
*/
data class ModelApiResponse (
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("code") val code: Int? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("type") val type: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("message") val message: String? = null
) {

View File

@ -18,22 +18,22 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Order (
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("petId") val petId: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity") val quantity: Int? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
@ApiModelProperty(value = "Order Status")
@ApiModelProperty(example = "null", value = "Order Status")
@JsonProperty("status") val status: Order.Status? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("complete") val complete: Boolean? = null
) {

View File

@ -25,19 +25,19 @@ data class Pet (
@JsonProperty("name") val name: String,
@get:NotNull
@ApiModelProperty(required = true, value = "")
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls") val photoUrls: List<String>,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("category") val category: Category? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags") val tags: List<Tag>? = null,
@ApiModelProperty(value = "pet status in the store")
@ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status") val status: Pet.Status? = null
) {

View File

@ -13,10 +13,10 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Tag (
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: String? = null
) {

View File

@ -19,28 +19,28 @@ import io.swagger.annotations.ApiModelProperty
*/
data class User (
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: Long? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("username") val username: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName") val firstName: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName") val lastName: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("email") val email: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("password") val password: String? = null,
@ApiModelProperty(value = "")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("phone") val phone: String? = null,
@ApiModelProperty(value = "User Status")
@ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus") val userStatus: Int? = null
) {