本文整理汇总了Java中io.swagger.models.parameters.SerializableParameter.setType方法的典型用法代码示例。如果您正苦于以下问题:Java SerializableParameter.setType方法的具体用法?Java SerializableParameter.setType怎么用?Java SerializableParameter.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.parameters.SerializableParameter
的用法示例。
在下文中一共展示了SerializableParameter.setType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testArrayMulti
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArrayMulti() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("multi");
List<String> paramsList = new ArrayList<>();
paramsList.add("toto");
paramsList.add("tutu");
paramsList.add("titi");
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, paramsList);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(paramsList.toArray(), ((List) result).toArray());
}
示例2: complement
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
private SerializableParameter complement(Property property, RouteParameter source,
SerializableParameter param) {
param.setType(property.getType());
param.setFormat(property.getFormat());
// array param:
if (property instanceof ArrayProperty) {
param.setItems(((ArrayProperty) property).getItems());
}
// enum values:
List<String> enums = source.enums();
if (enums.size() > 0) {
param.setEnum(enums);
}
// default value:
if (param instanceof AbstractSerializableParameter) {
((AbstractSerializableParameter) param).setDefault(source.defaultValue());
}
return param;
}
示例3: testArray
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArray() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat(null);
String param = "toto,tutu,titi";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例4: testArraySsv
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArraySsv() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("ssv");
String param = "toto tutu titi";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例5: testArrayCsv
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArrayCsv() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("csv");
String param = "toto,tutu,titi";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例6: testArrayTsv
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArrayTsv() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("tsv");
String param = "toto\ttutu\ttiti";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例7: testArrayPipes
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArrayPipes() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("pipes");
String param = "toto|tutu|titi";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例8: testArrayOther
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testArrayOther() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("array");
parameter.setCollectionFormat("anyOtherValue");
String param = "toto,tutu,titi";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertArrayEquals(new String[] { "toto", "tutu", "titi" },
((List) result).toArray());
}
示例9: testDefault
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testDefault() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setType("string");
String param = "toto";
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, param);
Object result = abstractSerializableParameterExtractor.extract(name, parameter, params);
Assert.assertEquals("toto", result);
}
示例10: setParameterType
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
/**
* Converts the given Java parameter type into a Swagger param type and sets it into the given Swagger param.
*
* @param parameterSource the parameter source.
* @param swaggerParam the Swagger parameter.
*/
private void setParameterType(ParameterSource<JavaClassSource> parameterSource, SerializableParameter swaggerParam) throws MojoExecutionException
{
try
{
String typeName = parameterSource.getType().getQualifiedName();
if (String.class.getName().equals(typeName))
{
swaggerParam.setType("string");
}
else if (Integer.class.getName().equals(typeName) || Long.class.getName().equals(typeName))
{
swaggerParam.setType("integer");
}
else if (Boolean.class.getName().equals(typeName))
{
swaggerParam.setType("boolean");
}
else
{
// See if the type is an enum.
Enum<?>[] enumValues = (Enum<?>[]) Class.forName(parameterSource.getType().getQualifiedName()).getEnumConstants();
if (enumValues != null)
{
swaggerParam.setType("string");
swaggerParam.setEnum(new ArrayList<>());
for (Enum<?> enumEntry : enumValues)
{
swaggerParam.getEnum().add(enumEntry.name());
}
}
else
{
// Assume "string" for all other types since everything is ultimately a string.
swaggerParam.setType("string");
}
}
log.debug("Parameter \"" + parameterSource.getName() + "\" is a type \"" + swaggerParam.getType() + "\".");
}
catch (ClassNotFoundException e)
{
throw new MojoExecutionException("Unable to instantiate class \"" + parameterSource.getType().getQualifiedName() + "\". Reason: " + e.getMessage(),
e);
}
}