当前位置: 首页>>代码示例>>Java>>正文


Java RefModel类代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:ConverterMgr.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:PendingBodyParameter.java

示例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;
}
 
开发者ID:limberest,项目名称:limberest,代码行数:17,代码来源:BodyParameterValidator.java

示例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());
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:20,代码来源:TestParameterGenerator.java

示例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"));
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:22,代码来源:TestBodyGenerator.java

示例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);
	}
	
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:21,代码来源:APIGExporter.java

示例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();
    }
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:25,代码来源:DefinitionsDocument.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:11,代码来源:PendingBodyParameter.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:TestSwaggerUtils.java

示例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;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:9,代码来源:SwaggerAssembler.java

示例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;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:10,代码来源:OpenApiRequestMapperTest.java

示例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;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:16,代码来源:TypeBuilder.java

示例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();
}
 
开发者ID:awslabs,项目名称:aws-apigateway-importer,代码行数:11,代码来源:ApiGatewaySdkSwaggerApiImporter.java

示例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;
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:11,代码来源:APIGExporter.java

示例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";
}
 
开发者ID:buremba,项目名称:swagger-slate,代码行数:13,代码来源:ModelUtils.java


注:本文中的io.swagger.models.RefModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。