• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ModelImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.swagger.models.ModelImpl的典型用法代码示例。如果您正苦于以下问题:Java ModelImpl类的具体用法?Java ModelImpl怎么用?Java ModelImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ModelImpl类属于io.swagger.models包,在下文中一共展示了ModelImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initConverters

import io.swagger.models.ModelImpl; //导入依赖的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.ModelImpl; //导入依赖的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: load

import io.swagger.models.ModelImpl; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private ModelImpl load(Collection<Entry<String, PropertyDescription>> desc) {
    ModelImpl res = new ModelImpl();

    for (Entry<String, PropertyDescription> e : desc) {
        String name = e.getKey();
        PropertyDescription pd = e.getValue();
        if (pd.usageOptions.contains(PropertyUsageOption.INFRASTRUCTURE)
                || pd.usageOptions.contains(PropertyUsageOption.SERVICE_USE)) {
            continue;
        }
        Property property = makeProperty(pd);
        property.description(pd.propertyDocumentation);

        if (pd.exampleValue instanceof Collection) {
            property.setExample((Object) null);
        }
        if (pd.exampleValue != null && pd.exampleValue.getClass().isArray()) {
            property.setExample((Object) null);
        }

        res.addProperty(name, property);
    }

    return res;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:27,代码来源:ModelRegistry.java


示例4: paramBody

import io.swagger.models.ModelImpl; //导入依赖的package包/类
/**
 * Build BodyParameter for the Route parameter of type body.
 */
private BodyParameter paramBody(List<RequestRouter.Parameter> routeParams, Route route) {
    BodyParameter bodyParam = new BodyParameter();
    bodyParam.setRequired(false);

    Model model = new ModelImpl();
    if (routeParams != null) {
        Map<String, Property> properties = new HashMap<>(routeParams.size());
        routeParams.stream().forEach((p) -> {
            StringProperty stringProperty = new StringProperty();
            stringProperty.setName(p.name);
            stringProperty
                    .setDescription(isBlank(p.description) ? route.description : p.description);
            stringProperty.setDefault(p.value);
            stringProperty.setRequired(p.required);
            stringProperty.setType(StringProperty.TYPE);

            properties.put(p.name, stringProperty);
        });
        model.setProperties(properties);
    }
    bodyParam.setSchema(model);
    return bodyParam;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:27,代码来源:SwaggerAssembler.java


示例5: mapGraphValue_ReturnsResults_WhenRefCanBeResolved

import io.swagger.models.ModelImpl; //导入依赖的package包/类
@Test
public void mapGraphValue_ReturnsResults_WhenRefCanBeResolved() {
  // Arrange
  property.set$ref(DUMMY_REF);
  Model refModel = new ModelImpl();
  refModel.setProperties(ImmutableMap.of(KEY_1, PROPERTY_1, KEY_2, PROPERTY_2));

  when(entityBuilderContext.getLdPathExecutor()).thenReturn(ldPathExecutor);
  when(entityBuilderContext.getSwaggerDefinitions()).thenReturn(
      ImmutableMap.of(property.getSimpleRef(), refModel));
  when(ldPathExecutor.ldPathQuery(context, LD_PATH_QUERY)).thenReturn(ImmutableList.of(VALUE_2));

  // Act
  Map<String, Object> result =
      (Map<String, Object>) schemaMapper.mapGraphValue(property, entityBuilderContext,
          ValueContext.builder().value(context).build(), schemaMapperAdapter);

  // Assert
  assertThat(result.keySet(), hasSize(2));
  assertEquals(((Optional) result.get(KEY_1)).orNull(), VALUE_1.stringValue());
  assertEquals(((Optional) result.get(KEY_2)).orNull(), VALUE_2.intValue());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:RefSchemaMapperTest.java


示例6: scanBeanParamResource

import io.swagger.models.ModelImpl; //导入依赖的package包/类
@Test
public void scanBeanParamResource() {
    final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
    final List<Parameter> params = getParameters(swagger, "/bean/{id}");

    final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
    assertEquals(1, headerParam1.getDefaultValue());
    assertEquals("test order annotation 1", headerParam1.getName());

    final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
    assertEquals(2, headerParam2.getDefaultValue());
    assertEquals("test order annotation 2", headerParam2.getName());

    final QueryParameter priority1 = (QueryParameter) params.get(2);
    assertNull(priority1.getDefaultValue());
    assertEquals("test priority 1", priority1.getName());

    final QueryParameter priority2 = (QueryParameter) params.get(3);
    assertEquals(4, priority2.getDefaultValue());
    assertEquals("test priority 2", priority2.getName());

    final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
    assertEquals("bodyParam", bodyParam1.getDefaultValue());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:25,代码来源:ScannerTest.java


示例7: createFields

import io.swagger.models.ModelImpl; //导入依赖的package包/类
/**
 * Returns list of {@link com.google.protobuf.Field.Builder} created using the properties of a
 * {@link ModelImpl} object.
 */
private ImmutableList.Builder<Field> createFields(
    Service.Builder serviceBuilder, ModelImpl modelImpl) {
  ImmutableList.Builder<Field> fieldsBuilder = ImmutableList.builder();
  int count = 1;
  if (modelImpl.getProperties() != null) {
    for (String propertyName : modelImpl.getProperties().keySet()) {
      Property prop = modelImpl.getProperties().get(propertyName);
      TypeInfo typeInfo =
          ensureNamed(
              serviceBuilder,
              getTypeInfo(serviceBuilder, prop),
              NameConverter.propertyNameToMessageName(propertyName));
      fieldsBuilder.add(createField(propertyName, count++, typeInfo).build());
    }
  }
  return fieldsBuilder;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:22,代码来源:TypeBuilder.java


示例8: registerErrorModel

import io.swagger.models.ModelImpl; //导入依赖的package包/类
/**
 * Manually register the Pippo Error class as  Swagger model.
 *
 * @param swagger
 * @return a ref for the Error model
 */
protected RefProperty registerErrorModel(Swagger swagger) {
    String ref = Error.class.getSimpleName();
    if (swagger.getDefinitions() != null && swagger.getDefinitions().containsKey(ref)) {
        // model already registered
        return new RefProperty(ref);
    }

    ModelImpl model = new ModelImpl();
    swagger.addDefinition(ref, model);

    model.setDescription("an error message");

    model.addProperty("statusCode", new IntegerProperty().readOnly().description("http status code"));
    model.addProperty("statusMessage", new StringProperty().readOnly().description("description of the http status code"));
    model.addProperty("requestMethod", new StringProperty().readOnly().description("http request method"));
    model.addProperty("requestUri", new StringProperty().readOnly().description("http request path"));
    model.addProperty("message", new StringProperty().readOnly().description("application message"));

    if (settings.isDev()) {
        // in DEV mode the stacktrace is returned in the error message
        model.addProperty("stacktrace", new StringProperty().readOnly().description("application stacktrace"));
    }

    return new RefProperty(ref);
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:32,代码来源:SwaggerBuilder.java


示例9: collectRefProperty

import io.swagger.models.ModelImpl; //导入依赖的package包/类
protected DataProvider collectRefProperty(Swagger swagger, RefProperty schema, boolean clean) {
    Model model = swagger.getDefinitions() != null ? swagger.getDefinitions().get(schema.getSimpleRef()) : null;
    if (model == null) throw new IllegalArgumentException("CAN'T find model for " + schema.getSimpleRef());

    if (model instanceof ArrayModel) {
        DataProvider itemProvider = collect(swagger, ((ArrayModel) model).getItems(), clean);
        return new ListDataProvider(itemProvider, schema.getSimpleRef());
    } else if (model instanceof ModelImpl) {
        Map<String, DataProvider> fields =
            (model.getProperties() != null ? model.getProperties() : Collections.<String, Property>emptyMap()).entrySet().stream()
                .map(e -> entry(e.getKey(), collect(swagger, e.getValue(), clean)))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

        return new ObjectDataProvider(fields, schema.getSimpleRef());
    }

    throw new IllegalArgumentException("Unsupported model type: " + model.getClass());
}
 
开发者ID:tminglei,项目名称:binder-swagger-java,代码行数:19,代码来源:DataProviders.java


示例10: getResponseSchema

import io.swagger.models.ModelImpl; //导入依赖的package包/类
private static Property getResponseSchema(String responseModelName, boolean inlineResponseSchema,
		Swagger swagger, Map<String, Integer> modelRefCount) {
	Property schema = new RefProperty(responseModelName);
	if (inlineResponseSchema && !modelRefCount.containsKey(responseModelName)) {
		io.swagger.models.Model model = swagger.getDefinitions().get(responseModelName);
		//If empty model was generated for response type
		if (model instanceof ModelImpl) {
			Map<String, Property> modelProperties = ((ModelImpl) model).getProperties();
			if (modelProperties == null || modelProperties.isEmpty()) {
				String type = ((ModelImpl) model).getType();
				if (type != null) {
					Property property = PropertyBuilder.build(type, ((ModelImpl) model).getFormat(), null);
					if (property != null) {
						schema = property;
						swagger.getDefinitions().remove(responseModelName);
					}
				}
			}
		}
	}
	return schema;
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:23,代码来源:APIGExporter.java


示例11: getDefinitions

import io.swagger.models.ModelImpl; //导入依赖的package包/类
private static Map<String, io.swagger.models.Model> getDefinitions(RestApi restApi)
		throws IOException, JsonParseException, JsonMappingException {
	Map<String, io.swagger.models.Model> result = new HashMap<String, io.swagger.models.Model>();
	for (Models models = restApi.getModels(); models != null; models = safeGetNext(models)) {
		for (Model modelItem : models.getItem()) {
			String content = modelItem.getSchema(); 
			io.swagger.models.Model model = 
					Json.mapper().readValue(content, io.swagger.models.Model.class);
			if (model instanceof ModelImpl) {
				((ModelImpl) model).setName(modelItem.getName());
			}
			model.setDescription(modelItem.getDescription());
			result.put(modelItem.getName(), model);
		}
	}
	return result;
}
 
开发者ID:isabinin,项目名称:aws-apigateway-swagger-exporter,代码行数:18,代码来源:APIGExporter.java


示例12: processModelRefs

import io.swagger.models.ModelImpl; //导入依赖的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


示例13: findByRef

import io.swagger.models.ModelImpl; //导入依赖的package包/类
public static JavaType findByRef(ClassLoader classLoader, String packageName, Swagger swagger, String refName) {
  Model ref = swagger.getDefinitions().get(refName);
  if (ModelImpl.class.isInstance(ref) && ((ModelImpl) ref).getName() == null) {
    ((ModelImpl) ref).setName(refName);
  }
  return findJavaType(classLoader, packageName, swagger, ref);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:ConverterMgr.java


示例14: doConvert

import io.swagger.models.ModelImpl; //导入依赖的package包/类
@Override
public JavaType doConvert(ClassLoader classLoader, String packageName, Swagger swagger, Object model) {
  ModelImpl modelImpl = (ModelImpl) model;

  JavaType javaType = ConverterMgr.findJavaType(modelImpl.getType(), modelImpl.getFormat());
  if (javaType != null) {
    return javaType;
  }

  if (modelImpl.getReference() != null) {
    return ConverterMgr.findByRef(classLoader, packageName, swagger, modelImpl.getReference());
  }

  if (modelImpl.getAdditionalProperties() != null) {
    return MapPropertyConverter.findJavaType(classLoader,
        packageName,
        swagger,
        modelImpl.getAdditionalProperties());
  }

  if (ObjectProperty.TYPE.equals(modelImpl.getType())
      && modelImpl.getProperties() == null
      && modelImpl.getName() == null) {
    return TypeFactory.defaultInstance().constructType(Object.class);
  }

  // 根据name、property动态生成class
  if (packageName == null) {
    throw new Error("packageName should not be null");
  }
  String clsName = packageName + "." + modelImpl.getName();
  Class<?> cls =
      ClassUtils.getOrCreateClass(classLoader, packageName, swagger, modelImpl.getProperties(), clsName);
  return TypeFactory.defaultInstance().constructType(cls);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:36,代码来源:ModelImplConverter.java


示例15: resolve

import io.swagger.models.ModelImpl; //导入依赖的package包/类
@Override
public Model resolve(JavaType type, ModelConverterContext context, Iterator<ModelConverter> next) {
  // property is not a model
  if (propertyCreatorMap.containsKey(type.getRawClass())) {
    return null;
  }

  Model model = super.resolve(type, context, next);
  if (model == null) {
    return null;
  }

  checkType(type);

  // 只有声明model的地方才需要标注类型
  if (ModelImpl.class.isInstance(model) && !StringUtils.isEmpty(((ModelImpl) model).getName())) {
    setType(type, model.getVendorExtensions());
  }
  return model;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:ModelResolverExt.java


示例16: getModel

import io.swagger.models.ModelImpl; //导入依赖的package包/类
public ModelImpl getModel(ServiceDocument template) {
    String kind = getStrippedKind(template.documentKind);
    ModelImpl model = (ModelImpl) this.byKind.get(kind);

    if (model == null) {
        model = load(template.documentDescription.propertyDescriptions.entrySet());
        model.setName(getStrippedKind(template.documentKind));
        this.byKind.put(kind, model);
    }

    return model;
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:13,代码来源:ModelRegistry.java


示例17: refProperty

import io.swagger.models.ModelImpl; //导入依赖的package包/类
private RefProperty refProperty(PropertyDescription pd) {
    String kind = getStrippedKind(pd.kind);
    ModelImpl model = (ModelImpl) this.byKind.get(kind);
    if (model == null) {
        model = load(pd.fieldDescriptions.entrySet());
        model.setName(kind);
        this.byKind.put(kind, model);
    }

    return new RefProperty(kind);
}
 
开发者ID:vmware,项目名称:xenon-utils,代码行数:12,代码来源:ModelRegistry.java


示例18: createSchemaFromModel

import io.swagger.models.ModelImpl; //导入依赖的package包/类
private static JsonNode createSchemaFromModel(final String specification, final Model schema) {
    if (schema instanceof ArrayModel) {
        final Property items = ((ArrayModel) schema).getItems();

        return createSchemaFromProperty(specification, items);
    } else if (schema instanceof ModelImpl) {
        return createSchemaFromModelImpl(schema);
    }

    final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", ""));

    return createSchemaFromReference(specification, title, schema.getReference());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:SwaggerUnifiedShapeConnectorGenerator.java


示例19: createShapeFromModel

import io.swagger.models.ModelImpl; //导入依赖的package包/类
static DataShape createShapeFromModel(final String specification, final Model schema) {
    if (schema instanceof ArrayModel) {
        final Property items = ((ArrayModel) schema).getItems();

        return createShapeFromProperty(specification, items);
    } else if (schema instanceof ModelImpl) {
        return createShapeFromModelImpl(schema);
    }

    final String title = Optional.ofNullable(schema.getTitle()).orElse(schema.getReference().replaceAll("^.*/", ""));

    return createShapeFromReference(specification, title, schema.getReference());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:DataShapeHelper.java


示例20: extract

import io.swagger.models.ModelImpl; //导入依赖的package包/类
static RequestParameters extract(@NonNull ApiOperation apiOperation, @NonNull Swagger swagger,
    @NonNull ContainerRequestContext containerRequestContext) {

  UriInfo uriInfo = containerRequestContext.getUriInfo();

  RequestParameters parameters = new RequestParameters();

  parameters.putAll(uriInfo.getPathParameters());
  parameters.putAll(uriInfo.getQueryParameters());
  parameters.putAll(containerRequestContext.getHeaders());

  try {
    Optional<Parameter> parameter =
        apiOperation.getOperation().getParameters().stream().filter(parameterBody -> {
          if ((parameterBody instanceof BodyParameter)) {
            ModelImpl parameterModel = getBodyParameter(swagger, (BodyParameter) parameterBody);
            return "object".equalsIgnoreCase(parameterModel.getType())
                && "body".equalsIgnoreCase(parameterBody.getIn());
          }
          return false;
        }).findFirst();
    extractBodyParameter(parameters, containerRequestContext, parameter);
  } catch (IOException ioe) {
    throw new InternalServerErrorException("Error processing request body.", ioe);
  }

  LOG.info("Extracted parameters: {}", parameters);

  return parameters;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:31,代码来源:RequestParameterExtractor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CountMetric类代码示例发布时间:2022-05-21
下一篇:
Java SuggestOracle类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap