forked from loafle/openapi-generator-original
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",
|
||||
"Float",
|
||||
"Object",
|
||||
"Any",
|
||||
"List",
|
||||
"Map")
|
||||
);
|
||||
@ -257,4 +258,60 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
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
|
||||
|
||||
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 io.swagger.client.ApiInvoker
|
||||
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'
|
||||
* 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
|
||||
* @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
|
||||
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 {
|
||||
apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match {
|
||||
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
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.swagger.client.api
|
||||
|
||||
import io.swagger.client.model.Order
|
||||
import io.swagger.client.model.Any
|
||||
import io.swagger.client.ApiInvoker
|
||||
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],
|
||||
id: Long,
|
||||
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