本文整理汇总了Java中io.swagger.models.properties.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于io.swagger.models.properties包,在下文中一共展示了Property类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: apply_ReturnsOkResponseWithEntityObject_ForTupleResult
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void apply_ReturnsOkResponseWithEntityObject_ForTupleResult() {
// Arrange
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getPath()).thenReturn("/");
when(containerRequestContextMock.getUriInfo()).thenReturn(uriInfo);
TupleQueryResult result = mock(TupleQueryResult.class);
final Map<String, Property> schemaMap = ImmutableMap.of();
when(informationProductMock.getResult(ImmutableMap.of())).thenReturn(result);
when(informationProductMock.getResultType()).thenReturn(ResultType.TUPLE);
// Act
Response response = getRequestHandler.apply(containerRequestContextMock);
// Assert
assertThat(response.getStatus(), equalTo(Status.OK.getStatusCode()));
assertThat(response.getEntity(), instanceOf(TupleEntity.class));
assertThat(((TupleEntity) response.getEntity()).getResult(), equalTo(result));
assertThat(((TupleEntity) response.getEntity()).getSchemaMap(), equalTo(schemaMap));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:GetRequestHandlerTest.java
示例2: mapCollection
import io.swagger.models.properties.Property; //导入依赖的package包/类
private Object mapCollection(TupleEntity entity, ArrayProperty schema,
ValueContext valueContext) {
Property itemSchema = schema.getItems();
if (itemSchema == null) {
throw new EntityMapperRuntimeException("Array schemas must have an 'items' property.");
}
if (!(itemSchema instanceof ObjectProperty)) {
throw new EntityMapperRuntimeException(
"Only array items of type 'object' are supported for now.");
}
TupleQueryResult result = entity.getResult();
ImmutableList.Builder<Map<String, Object>> collectionBuilder = new ImmutableList.Builder<>();
Map<String, Property> itemProperties = ((ObjectProperty) itemSchema).getProperties();
while (result.hasNext()) {
collectionBuilder.add(mapBindingSet(result.next(), itemProperties, valueContext));
}
return collectionBuilder.build();
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:TupleEntityMapper.java
示例3: process
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Override
public Property process(OperationGenerator operationGenerator) {
// Response完全表达应答类型
// 如果produces是text,那么可以假设是string,否则只能报错
List<String> produces = operationGenerator.getOperation().getProduces();
if (produces == null) {
produces = operationGenerator.getSwagger().getProduces();
}
if (produces != null) {
if (produces.contains(MediaType.TEXT_PLAIN)) {
Type responseType = String.class;
ParamUtils.addDefinitions(operationGenerator.getSwagger(), responseType);
return ModelConverters.getInstance().readAsProperty(responseType);
}
}
throw new Error("Use ApiOperation or ApiResponses to declare response type");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:JaxrsResponseProcessor.java
示例4: map_BodyParameter
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void map_BodyParameter() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyParameter("object");
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().get(newOp));
// Act
requestMapper.map(httpConfigurationMock);
// Assert
verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
Resource resource = resourceCaptor.getValue();
assertThat(resource.getPath(), equalTo("/" + DBEERPEDIA.OPENAPI_HOST + "/breweries"));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:OpenApiRequestMapperTest.java
示例5: mapEndpointWithoutBasePath
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void mapEndpointWithoutBasePath() throws IOException {
// Arrange
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.TEXT_PLAIN).path("/breweries",
new Path().get(new Operation().vendorExtensions(
ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue())).response(Status.OK.getStatusCode(),
new Response().schema(mock(Property.class)))));
when(informationProductResourceProviderMock.get(DBEERPEDIA.BREWERIES)).thenReturn(
informationProductMock);
// Act
requestMapper.map(httpConfigurationMock);
// Assert
verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
Resource resource = resourceCaptor.getValue();
assertThat(resource.getPath(), equalTo("/" + DBEERPEDIA.OPENAPI_HOST + "/breweries"));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:20,代码来源:OpenApiRequestMapperTest.java
示例6: map_ProducesPrecedence_WithValidData
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void map_ProducesPrecedence_WithValidData() throws IOException {
// Arrange
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.TEXT_PLAIN).path("/breweries",
new Path().get(new Operation().vendorExtensions(
ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue())).produces(MediaType.APPLICATION_JSON).response(
Status.OK.getStatusCode(), new Response().schema(mock(Property.class)))));
when(informationProductResourceProviderMock.get(DBEERPEDIA.BREWERIES)).thenReturn(
informationProductMock);
// Act
requestMapper.map(httpConfigurationMock);
// Assert
verify(httpConfigurationMock).registerResources(resourceCaptor.capture());
ResourceMethod method = resourceCaptor.getValue().getResourceMethods().get(0);
assertThat(method.getProducedTypes(), hasSize(1));
assertThat(method.getProducedTypes().get(0), equalTo(MediaType.APPLICATION_JSON_TYPE));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:OpenApiRequestMapperTest.java
示例7: extractProperties
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void extractProperties() {
final Map<String, Model> models = ModelConverters.getInstance().readAll(Family.class);
assertEquals(models.size(), 3);
final Model person = models.get("Person");
final Property employer = person.getProperties().get("employer");
assertTrue(employer instanceof ArrayProperty);
final ArrayProperty employerProperty = (ArrayProperty) employer;
final Property items = employerProperty.getItems();
assertTrue(items instanceof RefProperty);
assertEquals(((RefProperty) items).getSimpleRef(), "Employer");
final Property awards = person.getProperties().get("awards");
assertTrue(awards instanceof ArrayProperty);
assertTrue(((ArrayProperty) awards).getItems() instanceof StringProperty);
}
开发者ID:pegasystems,项目名称:api2swagger,代码行数:20,代码来源:ModelPropertyTest.java
示例8: resolveProperty
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Override
public Property resolveProperty(JavaType propType, ModelConverterContext context, Annotation[] annotations,
Iterator<ModelConverter> next) {
checkType(propType);
PropertyCreator creator = propertyCreatorMap.get(propType.getRawClass());
if (creator != null) {
return creator.createProperty();
}
Property property = super.resolveProperty(propType, context, annotations, next);
if (StringProperty.class.isInstance(property)) {
if (StringPropertyConverter.isEnum((StringProperty) property)) {
setType(propType, property.getVendorExtensions());
}
}
return property;
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:ModelResolverExt.java
示例9: map_BodyParameterNoObject
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void map_BodyParameterNoObject() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyParameter("object2");
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().get(newOp));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(String.format("No object property in body parameter"));
// Act
requestMapper.map(httpConfigurationMock);
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:OpenApiRequestMapperTest.java
示例10: injectResultContainerModel
import io.swagger.models.properties.Property; //导入依赖的package包/类
private ModelImpl injectResultContainerModel(Swagger swagger, ModelImpl innerModel, SwaggerRefPropertyFactory.PropertyContainerType containerType) {
// Only inject result container model once.
if (innerModel.getName().startsWith(resultContainerName)) {
return null;
}
// Create result container model instance based on result container definition.
Model model = swagger.getDefinitions().get(resultContainerName);
if (model == null || !(model instanceof ModelImpl)) {
return null;
}
ModelImpl resultContainerModel = (ModelImpl) model.clone();
// Set unique name of result container model per container type to avoid overwriting documentation.
resultContainerModel.setName(resultContainerName + "-" + innerModel.getName() + "-" + containerType);
// Inject innerModel into 'data' property.
Property dataProperty = SwaggerRefPropertyFactory.create(containerType, innerModel);
dataProperty.setRequired(true);
dataProperty.setDescription(createDataPropertyDescription(containerType));
resultContainerModel.addProperty(resultContainerDataProperty, dataProperty);
// Put result container model with injected innerModel into Swagger.
swagger.addDefinition(resultContainerModel.getName(), resultContainerModel);
return resultContainerModel;
}
开发者ID:mnemonic-no,项目名称:common-services,代码行数:26,代码来源:ResultContainerTransformation.java
示例11: arrayParam
import io.swagger.models.properties.Property; //导入依赖的package包/类
public static SerializableParameter arrayParam(final boolean required,
final String collectionFormat,
final Integer minItems,
final Integer maxItems,
final Boolean unique,
final Property items) {
final SerializableParameter result = mock(SerializableParameter.class);
when(result.getName()).thenReturn("Test Parameter");
when(result.getType()).thenReturn("array");
when(result.getCollectionFormat()).thenReturn(collectionFormat);
when(result.getRequired()).thenReturn(required);
when(result.getMinItems()).thenReturn(minItems);
when(result.getMaxItems()).thenReturn(maxItems);
when(result.isUniqueItems()).thenReturn(unique);
when(result.getItems()).thenReturn(items);
return result;
}
开发者ID:networknt,项目名称:light-rest-4j,代码行数:19,代码来源:ValidatorTestUtil.java
示例12: parseResponseHeaders
import io.swagger.models.properties.Property; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(ReaderContext context,
ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(
header.responseContainer(), property, ContainerWrapper.ARRAY,
ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(context.getSwagger(), cls);
}
}
}
}
return responseHeaders;
}
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:26,代码来源:DubboReaderExtension.java
示例13: load
import io.swagger.models.properties.Property; //导入依赖的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
示例14: paramBody
import io.swagger.models.properties.Property; //导入依赖的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
示例15: parseResponseHeaders
import io.swagger.models.properties.Property; //导入依赖的package包/类
private static Map<String, Property> parseResponseHeaders(Swagger swagger, ReaderContext context, ResponseHeader[] headers) {
Map<String, Property> responseHeaders = null;
for (ResponseHeader header : headers) {
final String name = header.name();
if (StringUtils.isNotEmpty(name)) {
if (responseHeaders == null) {
responseHeaders = new HashMap<String, Property>();
}
final Class<?> cls = header.response();
if (!ReflectionUtils.isVoid(cls)) {
final Property property = ModelConverters.getInstance().readAsProperty(cls);
if (property != null) {
final Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(),
property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
responseProperty.setDescription(header.description());
responseHeaders.put(name, responseProperty);
appendModels(swagger, cls);
}
}
}
}
return responseHeaders;
}
开发者ID:yangfuhai,项目名称:jboot,代码行数:24,代码来源:ControllerReaderExtension.java
示例16: getSchemaStructureFromResponse
import io.swagger.models.properties.Property; //导入依赖的package包/类
private SwaggerSchema getSchemaStructureFromResponse(Response response) throws IOException {
SwaggerSchema swaggerSchema = new SwaggerSchema();
swaggerSchema.setDescription(response.getDescription());
Property responseProperty = response.getSchema();
if (responseProperty != null) {
swaggerSchema.setType(responseProperty.getType());
if (swaggerSchema.getType() == "object" && responseProperty instanceof MapProperty) {
Property additionalProperties = ((MapProperty) responseProperty).getAdditionalProperties();
swaggerSchema.setAdditionalPropertiesType(additionalProperties.getType());
} else {
String mainScehmaReference = getMainDefinitionNameInResponse(response);
if (!mainScehmaReference.isEmpty())
swaggerSchema.setParsedSchema(new SwaggerParserHelper(swagger).getDefinationsFromSchemaReference(mainScehmaReference, "root"));
}
}
return swaggerSchema;
}
开发者ID:bsneha90,项目名称:RecursiveSwaggerSchemaParser,代码行数:19,代码来源:SwaggerSchemaResponseParser.java
示例17: map_BodyParameterWithRefObject
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Test
public void map_BodyParameterWithRefObject() throws IOException {
// Arrange
Property property = mock(Property.class);
List<Parameter> parameters = createBodyRefParameter();
Operation newOp = new Operation();
newOp.setParameters(parameters);
newOp.vendorExtensions(ImmutableMap.of(OpenApiSpecificationExtensions.INFORMATION_PRODUCT,
DBEERPEDIA.BREWERIES.stringValue()));
newOp.response(200, new Response().schema(property));
mockDefinition().host(DBEERPEDIA.OPENAPI_HOST).produces(MediaType.APPLICATION_JSON).path(
"/breweries", new Path().post(newOp));
// Assert
thrown.expect(ConfigurationException.class);
thrown.expectMessage(String.format("No object property in body parameter"));
// Act
requestMapper.map(httpConfigurationMock);
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:OpenApiRequestMapperTest.java
示例18: map
import io.swagger.models.properties.Property; //导入依赖的package包/类
@Override
public Object map(@NonNull TupleEntity entity, @NonNull MediaType mediaType) {
Property schema = entity.getSchemaMap().get(mediaType);
ValueContext valueContext = ValueContext.builder().build();
if (schema == null) {
throw new EntityMapperRuntimeException(
String.format("No schema found for media type '%s'.", mediaType.toString()));
}
if (schema instanceof ResponseProperty) {
schema = ((ResponseProperty) schema).getSchema();
}
if (schema instanceof ObjectProperty) {
return mapObject(entity, (ObjectProperty) schema, valueContext);
}
if (schema instanceof ArrayProperty) {
return mapCollection(entity, (ArrayProperty) schema, valueContext);
}
return ImmutableMap.of();
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:TupleEntityMapper.java
示例19: mapBindingSet
import io.swagger.models.properties.Property; //导入依赖的package包/类
private ImmutableMap<String, Object> mapBindingSet(BindingSet bindingSet,
Map<String, Property> itemProperties, ValueContext valueContext) {
ImmutableMap.Builder<String, Object> itemBuilder = new ImmutableMap.Builder<>();
itemProperties.forEach((name, property) -> {
if (property.getRequired() && !bindingSet.hasBinding(name)) {
throw new EntityMapperRuntimeException(String.format("Property '%s' is required.", name));
}
if (!bindingSet.hasBinding(name)) {
itemBuilder.put(name, Optional.absent());
return;
}
ValueContext newValueContext =
valueContext.toBuilder().value(bindingSet.getValue(name)).build();
itemBuilder.put(name, schemaMapperAdapter.mapTupleValue(property, newValueContext));
});
return itemBuilder.build();
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:TupleEntityMapper.java
示例20: getSubject
import io.swagger.models.properties.Property; //导入依赖的package包/类
/**
* @return Applies the subject filter and returns the single subject, or {@code null} if no
* subject can be found.
* @throws IllegalStateException If the property does not have the
* {@link OpenApiSpecificationExtensions#SUBJECT_FILTER} vendor extension defined. Please
* call {@link #hasSubjectFilterVendorExtension(Property)} before calling this method.
* @throws SchemaMapperRuntimeException If no predicate and object have been defined for the
* subject filter.
* @throws SchemaMapperRuntimeException If the property is required, and no subject can be found.
* @throws SchemaMapperRuntimeException If more than one subject has been found.
*/
protected final Value getSubject(@NonNull Property property,
@NonNull GraphEntityContext graphEntityContext) {
Set<Resource> subjects = getSubjects(property, graphEntityContext);
if (subjects.isEmpty()) {
if (property.getRequired()) {
throw new SchemaMapperRuntimeException(
"Subject filter for a required object property yielded no result.");
}
return null;
}
if (subjects.size() > 1) {
throw new SchemaMapperRuntimeException(
"More entrypoint subjects found. Only one is required.");
}
return subjects.iterator().next();
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:32,代码来源:AbstractSubjectFilterSchemaMapper.java
注:本文中的io.swagger.models.properties.Property类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论