本文整理汇总了Java中io.swagger.models.RefModel类的典型用法代码示例。如果您正苦于以下问题:Java RefModel类的具体用法?Java RefModel怎么用?Java RefModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefModel类属于io.swagger.models包,在下文中一共展示了RefModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initConverters
import io.swagger.models.RefModel; //导入依赖的package包/类
private static void initConverters() {
// inner converters
for (Class<? extends Property> propertyCls : PROPERTY_MAP.keySet()) {
addInnerConverter(propertyCls);
}
converterMap.put(RefProperty.class, new RefPropertyConverter());
converterMap.put(ArrayProperty.class, new ArrayPropertyConverter());
converterMap.put(MapProperty.class, new MapPropertyConverter());
converterMap.put(StringProperty.class, new StringPropertyConverter());
converterMap.put(ObjectProperty.class, new ObjectPropertyConverter());
converterMap.put(ModelImpl.class, new ModelImplConverter());
converterMap.put(RefModel.class, new RefModelConverter());
converterMap.put(ArrayModel.class, new ArrayModelConverter());
converterMap.put(BodyParameter.class, new BodyParameterConverter());
AbstractSerializableParameterConverter converter = new AbstractSerializableParameterConverter();
converterMap.put(QueryParameter.class, converter);
converterMap.put(PathParameter.class, converter);
converterMap.put(HeaderParameter.class, converter);
converterMap.put(FormParameter.class, converter);
converterMap.put(CookieParameter.class, converter);
}
示例2: toRefModel
import io.swagger.models.RefModel; //导入依赖的package包/类
private RefModel toRefModel(String modelType) {
if (RefProperty.class.isInstance(property)) {
return (RefModel) PropertyBuilder.toModel(property);
}
ModelImpl modelImpl = new ModelImpl();
modelImpl.setType("object");
modelImpl.setName(name);
modelImpl.addProperty(name, property);
operationGenerator.getSwagger().addDefinition(modelType, modelImpl);
RefModel refModel = new RefModel();
refModel.setReference("#/definitions/" + modelType);
return refModel;
}
示例3: validate
import io.swagger.models.RefModel; //导入依赖的package包/类
public Result validate(BodyParameter bodyParam, JSONObject body, boolean strict) throws ValidationException {
Result result = new Result();
if (body == null) {
if (bodyParam.getRequired())
result.also(Status.BAD_REQUEST, "Missing required body parameter: " + bodyParam.getName());
}
else {
Model model = bodyParam.getSchema();
if (model instanceof RefModel) {
Model bodyModel = swaggerRequest.getDefinitions().get(((RefModel)model).getSimpleRef());
if (bodyModel != null)
result.also(validate(body, bodyModel, "", strict));
}
}
return result;
}
示例4: testFillBodyStringParameter
import io.swagger.models.RefModel; //导入依赖的package包/类
@Test
public void testFillBodyStringParameter() {
for (int i = 0; i < 100; i++) {
SwagRequest request = new SwagRequest();
RefModel ref = new RefModel();
ref.set$ref("#/definitions/Pet");
BodyParameter param = new BodyParameter();
param.setIn("body");
param.setName("testParam");
param.setSchema(ref);
param.setRequired(true);
ParameterGenerator.fillParameter(swagger.getSwagger(), request, param, TestType.VALID);
assertNotNull(request.getBodyParameters());
}
}
示例5: testFillBodyRef
import io.swagger.models.RefModel; //导入依赖的package包/类
@Test
public void testFillBodyRef() {
for (int i = 0; i < 100; i++) {
RefModel ref = new RefModel();
ref.set$ref("#/definitions/Pet");
Object res = BodyGenerator.fillBody(swagger.getSwagger(), ref, TestType.VALID);
assertNotNull(res);
assertTrue(res instanceof JSONObject);
JSONObject json = (JSONObject) res;
assertTrue(json.has("id"));
assertTrue(json.has("category"));
assertTrue(json.has("name"));
assertTrue(json.has("photoUrls"));
assertTrue(json.has("tags"));
assertTrue(json.has("status"));
}
}
示例6: processModelRefs
import io.swagger.models.RefModel; //导入依赖的package包/类
private static void processModelRefs(io.swagger.models.Model model, Map<String, Integer> modelRefCount) {
if (model instanceof RefModel) {
String ref = ((RefModel) model).getSimpleRef();
Integer count = modelRefCount.get(ref);
modelRefCount.put(ref, count != null ? (count + 1) : 1);
} else if (model instanceof ModelImpl) {
processPropertyModelRefs(((ModelImpl) model).getProperties(), modelRefCount);
processPropertyModelRefs(((ModelImpl) model).getAdditionalProperties(), modelRefCount);
} else if (model instanceof ArrayModel) {
processPropertyModelRefs(((ArrayModel) model).getProperties(), modelRefCount);
processPropertyModelRefs(((ArrayModel) model).getItems(), modelRefCount);
} else if (model instanceof ComposedModel) {
processPropertyModelRefs(((ComposedModel) model).getProperties(), modelRefCount);
processModelRefs(((ComposedModel) model).getChild(), modelRefCount);
processModelRefs(((ComposedModel) model).getParent(), modelRefCount);
processModelRefs(((ComposedModel) model).getAllOf(), modelRefCount);
processModelRefs(((ComposedModel) model).getInterfaces(), modelRefCount);
}
}
示例7: getAllProperties
import io.swagger.models.RefModel; //导入依赖的package包/类
private static Map<String, Property> getAllProperties(Map<String, Model> definitions, Model model) {
if(model instanceof RefModel) {
final String ref = model.getReference();
return definitions.containsKey(ref)
? getAllProperties(definitions, definitions.get(model.getReference()))
: null;
}
if(model instanceof ComposedModel) {
ComposedModel composedModel = (ComposedModel)model;
ImmutableMap.Builder<String, Property> allProperties = ImmutableMap.builder();
if(composedModel.getAllOf() != null) {
for(Model innerModel : composedModel.getAllOf()) {
Map<String, Property> innerProperties = getAllProperties(definitions, innerModel);
if(innerProperties != null) {
allProperties.putAll(innerProperties);
}
}
}
return allProperties.build();
}
else {
return model.getProperties();
}
}
示例8: createBodyParameter
import io.swagger.models.RefModel; //导入依赖的package包/类
public BodyParameter createBodyParameter(String paramName) {
String modelType = ParamUtils.generateBodyParameterName(operationGenerator.getProviderMethod());
RefModel model = toRefModel(modelType);
BodyParameter bodyParameter = new BodyParameter();
bodyParameter.setName(paramName);
bodyParameter.setSchema(model);
return bodyParameter;
}
示例9: testConverter
import io.swagger.models.RefModel; //导入依赖的package包/类
@Test
public void testConverter() {
SwaggerGenerator generator = new SwaggerGeneratorForTest(context, null);
Swagger swagger = generator.getSwagger();
ParamUtils.addDefinitions(swagger, User.class);
Model model = swagger.getDefinitions().get("User");
model.getVendorExtensions().clear();
JavaType javaType = ConverterMgr.findJavaType(generator, model);
checkJavaType(swagger, javaType);
RefModel refModel = new RefModel();
refModel.setReference("User");
javaType = ConverterMgr.findJavaType(generator, refModel);
checkJavaType(swagger, javaType);
}
示例10: paramBody
import io.swagger.models.RefModel; //导入依赖的package包/类
private BodyParameter paramBody(Class<?> type) {
BodyParameter res = new BodyParameter();
res.setName(PARAM_NAME_BODY);
res.setRequired(false);
ModelImpl model = modelForPodo(type);
res.setSchema(new RefModel(model.getName()));
return res;
}
示例11: createBodyRefParameter
import io.swagger.models.RefModel; //导入依赖的package包/类
private List<Parameter> createBodyRefParameter() {
BodyParameter bodyParameter = new BodyParameter();
RefModel schema = new RefModel();
schema.set$ref("myref");
bodyParameter.setSchema(schema);
List<Parameter> parameters = new ArrayList<>();
parameters.add(bodyParameter);
return parameters;
}
示例12: getRefModelTypeInfo
import io.swagger.models.RefModel; //导入依赖的package包/类
/** Returns the {@link TypeInfo} for the referenced model. */
private TypeInfo getRefModelTypeInfo(Service.Builder serviceBuilder, RefModel refModel) {
TypeInfo resultTypeInfo;
Preconditions.checkState(refModel.get$ref().startsWith("#/definitions/"));
String refModelName = refModel.get$ref().substring("#/definitions/".length());
resultTypeInfo =
Preconditions.checkNotNull(
addTypeFromModel(
serviceBuilder,
refModelName,
swagger.getDefinitions() == null
? null
: swagger.getDefinitions().get(refModelName)));
return resultTypeInfo;
}
示例13: getInputModel
import io.swagger.models.RefModel; //导入依赖的package包/类
private Optional<String> getInputModel(BodyParameter p) {
io.swagger.models.Model model = p.getSchema();
if (model instanceof RefModel) {
String modelName = ((RefModel) model).getSimpleRef(); // assumption: complex ref?
return Optional.of(modelName);
}
return Optional.empty();
}
示例14: getBodyParameter
import io.swagger.models.RefModel; //导入依赖的package包/类
private static BodyParameter getBodyParameter(String requestModelName, boolean inlineBodyParameterSchema,
Swagger swagger, Map<String, Integer> modelRefCount) {
BodyParameter parameter = new BodyParameter().name("body").description(requestModelName);
if (inlineBodyParameterSchema && !modelRefCount.containsKey(requestModelName)) {
parameter.setSchema(swagger.getDefinitions().remove(requestModelName));
} else {
parameter.setSchema(new RefModel(requestModelName));
}
return parameter;
}
示例15: getType
import io.swagger.models.RefModel; //导入依赖的package包/类
public static String getType(Model model) {
Validate.notNull(model, "model must not be null!");
if (model instanceof ModelImpl) {
return ((ModelImpl) model).getType();
} else if (model instanceof RefModel) {
return ((RefModel) model).getSimpleRef();
} else if (model instanceof ArrayModel) {
ArrayModel arrayModel = ((ArrayModel) model);
return PropertyUtils.getType(arrayModel.getItems()) + " " + arrayModel.getType();
}
return "NOT FOUND";
}