mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-29 04:00:51 +00:00
fix scala test cases
This commit is contained in:
parent
a529d9dfe0
commit
b09d34e37c
@ -112,6 +112,7 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
"Long",
|
"Long",
|
||||||
"Float",
|
"Float",
|
||||||
"Object",
|
"Object",
|
||||||
|
"Any",
|
||||||
"List",
|
"List",
|
||||||
"Map")
|
"Map")
|
||||||
);
|
);
|
||||||
@ -257,4 +258,60 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// sanitize name
|
||||||
|
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||||
|
|
||||||
|
if("_".equals(name)) {
|
||||||
|
name = "_u";
|
||||||
|
}
|
||||||
|
|
||||||
|
// if it's all uppper case, do nothing
|
||||||
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// pet_id => petId
|
||||||
|
name = camelize(name, true);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelName(final String name) {
|
||||||
|
final String sanitizedName = sanitizeName(modelNamePrefix + name + modelNameSuffix);
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
final String camelizedName = camelize(sanitizedName);
|
||||||
|
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(camelizedName)) {
|
||||||
|
final String modelName = "Model" + camelizedName;
|
||||||
|
LOGGER.warn(camelizedName + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||||
|
return modelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return camelizedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// should be the same as the model name
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.swagger.client.api
|
package io.swagger.client.api
|
||||||
|
|
||||||
import io.swagger.client.model.Pet
|
import io.swagger.client.model.Pet
|
||||||
import io.swagger.client.model.Inline_response_200
|
import io.swagger.client.model.InlineResponse200
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import io.swagger.client.ApiInvoker
|
import io.swagger.client.ApiInvoker
|
||||||
import io.swagger.client.ApiException
|
import io.swagger.client.ApiException
|
||||||
@ -321,9 +321,9 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
|||||||
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
|
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
|
||||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
* @param petId ID of pet that needs to be fetched
|
* @param petId ID of pet that needs to be fetched
|
||||||
* @return Inline_response_200
|
* @return InlineResponse200
|
||||||
*/
|
*/
|
||||||
def getPetByIdInObject (petId: Long) : Option[Inline_response_200] = {
|
def getPetByIdInObject (petId: Long) : Option[InlineResponse200] = {
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
val path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
|
val path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId))
|
||||||
|
|
||||||
@ -357,7 +357,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
|||||||
try {
|
try {
|
||||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match {
|
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match {
|
||||||
case s: String =>
|
case s: String =>
|
||||||
Some(ApiInvoker.deserialize(s, "", classOf[Inline_response_200]).asInstanceOf[Inline_response_200])
|
Some(ApiInvoker.deserialize(s, "", classOf[InlineResponse200]).asInstanceOf[InlineResponse200])
|
||||||
|
|
||||||
case _ => None
|
case _ => None
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package io.swagger.client.api
|
package io.swagger.client.api
|
||||||
|
|
||||||
import io.swagger.client.model.Order
|
import io.swagger.client.model.Order
|
||||||
import io.swagger.client.model.Any
|
|
||||||
import io.swagger.client.ApiInvoker
|
import io.swagger.client.ApiInvoker
|
||||||
import io.swagger.client.ApiException
|
import io.swagger.client.ApiException
|
||||||
|
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case class $special[model.name] (
|
|
||||||
$special[property.name]: Long)
|
|
||||||
|
|
@ -3,7 +3,7 @@ package io.swagger.client.model
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
case class Inline_response_200 (
|
case class InlineResponse200 (
|
||||||
tags: List[Tag],
|
tags: List[Tag],
|
||||||
id: Long,
|
id: Long,
|
||||||
category: Any,
|
category: Any,
|
@ -1,8 +0,0 @@
|
|||||||
package io.swagger.client.model
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case class Return (
|
|
||||||
_return: Integer)
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
|||||||
|
package io.swagger.client.model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case class SpecialModelName (
|
||||||
|
specialPropertyName: Long)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user