本文整理汇总了Java中io.swagger.models.parameters.SerializableParameter.setName方法的典型用法代码示例。如果您正苦于以下问题:Java SerializableParameter.setName方法的具体用法?Java SerializableParameter.setName怎么用?Java SerializableParameter.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.swagger.models.parameters.SerializableParameter
的用法示例。
在下文中一共展示了SerializableParameter.setName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testMissingRequiredParam
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testMissingRequiredParam() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setRequired(true);
abstractSerializableParameterExtractor.extract(name, parameter,
MultiMap.caseInsensitiveMultiMap());
}
示例3: testMissingNonRequiredParam
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test()
public void testMissingNonRequiredParam() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setRequired(false);
Object result = abstractSerializableParameterExtractor.extract(name, parameter,
MultiMap.caseInsensitiveMultiMap());
Assert.assertNull(result);
}
示例4: testNotAllowEmptyValueWithEmptyParameter
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testNotAllowEmptyValueWithEmptyParameter() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
parameter.setAllowEmptyValue(false);
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, "");
abstractSerializableParameterExtractor.extract(name, parameter, params);
}
示例5: testNullAllowEmptyValueWithEmptyParameter
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testNullAllowEmptyValueWithEmptyParameter() {
String name = "myName";
SerializableParameter parameter = new QueryParameter();
parameter.setName("myName");
MultiMap params = MultiMap.caseInsensitiveMultiMap();
params.add(name, "");
abstractSerializableParameterExtractor.extract(name, parameter, params);
}
示例6: 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());
}
示例7: 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());
}
示例8: 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());
}
示例9: 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());
}
示例10: 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());
}
示例11: 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());
}
示例12: 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);
}
示例13: extractParameters
import io.swagger.models.parameters.SerializableParameter; //导入方法依赖的package包/类
private List<Parameter> extractParameters(Class<?> cls) {
List<Parameter> parameters = new ArrayList<Parameter>();
for (AccessibleObject accessibleObject : getDeclaredAndInheritedFieldsAndMethods(cls)) {
SerializableParameter parameter = null;
int i = 0;
int apiParaIdx = -1;
boolean hidden = false;
for (Annotation annotation : accessibleObject.getAnnotations()) {
if (annotation instanceof ApiParam) {
if (((ApiParam) annotation).hidden()) {
hidden = true;
} else {
apiParaIdx = i;
}
}
i++;
Type paramType = extractType(accessibleObject, cls);
parameter = JaxrsParameterExtension.getParameter(paramType, parameter, annotation);
}
if (parameter != null) {
if (apiParaIdx != -1) {
ApiParam param = (ApiParam) accessibleObject.getAnnotations()[apiParaIdx];
parameter.setDescription(param.value());
parameter.setRequired(param.required());
parameter.setAccess(param.access());
if (parameter instanceof AbstractSerializableParameter && StringUtils.isNotEmpty(param.defaultValue())) {
((AbstractSerializableParameter)parameter).setDefaultValue(param.defaultValue());
}
AllowableValues allowableValues = AllowableValuesUtils.create(param.allowableValues());
if (allowableValues != null) {
Map<PropertyBuilder.PropertyId, Object> args = allowableValues.asPropertyArguments();
if (args.containsKey(PropertyBuilder.PropertyId.ENUM)) {
parameter.setEnum((List<String>) args.get(PropertyBuilder.PropertyId.ENUM));
}
}
if (!param.name().isEmpty()) {
parameter.setName(param.name());
}
}
if (!hidden) {
parameters.add(parameter);
}
}
}
return parameters;
}