本文整理汇总了Java中io.swagger.models.properties.MapProperty类的典型用法代码示例。如果您正苦于以下问题:Java MapProperty类的具体用法?Java MapProperty怎么用?Java MapProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapProperty类属于io.swagger.models.properties包,在下文中一共展示了MapProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initConverters
import io.swagger.models.properties.MapProperty; //导入依赖的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: createSchemaFromProperty
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private static JsonNode createSchemaFromProperty(final String specification, final Property schema) {
if (schema instanceof MapProperty) {
try {
final String schemaString = Json.mapper().writeValueAsString(schema);
return parseJsonSchema(schemaString);
} catch (final JsonProcessingException e) {
throw new IllegalStateException("Unable to serialize/read given JSON specification in response schema: " + schema, e);
}
} else if (schema instanceof StringProperty) {
return null;
}
final String reference = determineSchemaReference(schema);
final String title = Optional.ofNullable(schema.getTitle()).orElse(reference.replaceAll("^.*/", ""));
return createSchemaFromReference(specification, title, reference);
}
示例3: createShapeFromProperty
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private static DataShape createShapeFromProperty(final String specification, final Property schema) {
if (schema instanceof MapProperty) {
try {
final String schemaString = Json.mapper().writeValueAsString(schema);
return new DataShape.Builder().kind("json-schema").specification(schemaString).build();
} catch (final JsonProcessingException e) {
throw new IllegalStateException("Unable to serialize given JSON specification in response schema: " + schema, e);
}
} else if (schema instanceof StringProperty) {
return DATA_SHAPE_NONE;
}
final String reference = determineSchemaReference(schema);
final String title = Optional.ofNullable(schema.getTitle()).orElse(reference.replaceAll("^.*/", ""));
return createShapeFromReference(specification, title, reference);
}
示例4: getSchemaStructureFromResponse
import io.swagger.models.properties.MapProperty; //导入依赖的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;
}
示例5: createShapeFromProperty
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
static DataShape createShapeFromProperty(final String specification, final Property schema) {
if (schema instanceof MapProperty) {
try {
final String schemaString = Json.mapper().writeValueAsString(schema);
return new DataShape.Builder().kind("json-schema").specification(schemaString).build();
} catch (final JsonProcessingException e) {
throw new IllegalStateException(
"Unable to serialize given JSON specification in response schema: " + schema, e);
}
} else if (schema instanceof StringProperty) {
return DATA_SHAPE_NONE;
}
final String reference = determineSchemaReference(schema);
final String title = Optional.ofNullable(schema.getTitle()).orElse(reference.replaceAll("^.*/", ""));
return createShapeFromReference(specification, title, reference);
}
示例6: exampleMapForProperties
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
/**
* Generates a map of examples from a map of properties. If defined examples are found, those are used. Otherwise,
* examples are generated from the type.
*
* @param properties the map of properties
* @param definitions the map of definitions
* @param markupDocBuilder the markup builder
* @param refStack map to detect cyclic references
* @return a Map of examples
*/
private static Map<String, Object> exampleMapForProperties(Map<String, Property> properties, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder, Map<String, Integer> refStack) {
Map<String, Object> exampleMap = new LinkedHashMap<>();
if (properties != null) {
for (Map.Entry<String, Property> property : properties.entrySet()) {
Object exampleObject = property.getValue().getExample();
if (exampleObject == null) {
if (property.getValue() instanceof RefProperty) {
exampleObject = generateExampleForRefModel(true, ((RefProperty) property.getValue()).getSimpleRef(), definitions, definitionDocumentResolver, markupDocBuilder, refStack);
} else if (property.getValue() instanceof ArrayProperty) {
exampleObject = generateExampleForArrayProperty((ArrayProperty) property.getValue(), definitions, definitionDocumentResolver, markupDocBuilder, refStack);
} else if (property.getValue() instanceof MapProperty) {
exampleObject = generateExampleForMapProperty((MapProperty) property.getValue(), markupDocBuilder);
}
if (exampleObject == null) {
Property valueProperty = property.getValue();
exampleObject = PropertyAdapter.generateExample(valueProperty, markupDocBuilder);
}
}
exampleMap.put(property.getKey(), exampleObject);
}
}
return exampleMap;
}
示例7: makeProperty
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private Property makeProperty(PropertyDescription pd) {
switch (pd.typeName) {
case BOOLEAN:
return new BooleanProperty();
case BYTES:
return new BinaryProperty();
case COLLECTION:
return new ArrayProperty(makeProperty(pd.elementDescription));
case DATE:
return new DateTimeProperty();
case DOUBLE:
return new DoubleProperty();
case ENUM:
StringProperty prop = new StringProperty();
if (pd.enumValues != null) {
prop._enum(Arrays.asList(pd.enumValues));
}
return prop;
case InternetAddressV4:
return new StringProperty();
case InternetAddressV6:
return new StringProperty();
case LONG:
return new LongProperty();
case MAP:
return new MapProperty(new StringProperty());
case PODO:
return refProperty(pd);
case STRING:
return new StringProperty();
case URI:
return new StringProperty(Format.URI);
default:
throw new IllegalStateException("unknown type " + pd.typeName);
}
}
示例8: withResponseContainer
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
/**
* Response wrapper for list type
*
* @param type
* -type
* @param property
* - swagger property
* @return wrapped response
*/
private Property withResponseContainer(String type, Property property) {
if ("list".equalsIgnoreCase(type)) {
return new ArrayProperty(property);
}
if ("set".equalsIgnoreCase(type)) {
return new ArrayProperty(property).uniqueItems();
}
if ("map".equalsIgnoreCase(type)) {
return new MapProperty(property);
}
return property;
}
示例9: generateExampleForMapProperty
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private static Object generateExampleForMapProperty(MapProperty property, MarkupDocBuilder markupDocBuilder) {
if (property.getExample() != null) {
return property.getExample();
}
Map<String, Object> exampleMap = new LinkedHashMap<>();
Property valueProperty = property.getAdditionalProperties();
if (valueProperty.getExample() != null) {
return valueProperty.getExample();
}
exampleMap.put("string", PropertyAdapter.generateExample(valueProperty, markupDocBuilder));
return exampleMap;
}
示例10: processPropertyModelRefs
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private static void processPropertyModelRefs(Property property, Map<String, Integer> modelRefCount) {
if (property instanceof RefProperty) {
String ref = ((RefProperty) property).getSimpleRef();
Integer count = modelRefCount.get(ref);
modelRefCount.put(ref, count != null ? (count + 1) : 1);
} else if (property instanceof ArrayProperty) {
processPropertyModelRefs(((ArrayProperty) property).getItems(), modelRefCount);
} else if (property instanceof MapProperty) {
processPropertyModelRefs(((MapProperty) property).getAdditionalProperties(), modelRefCount);
}
}
示例11: withResponseContainer
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
Property withResponseContainer(String responseContainer, Property property) {
if ("list".equalsIgnoreCase(responseContainer)) {
return new ArrayProperty(property);
}
if ("set".equalsIgnoreCase(responseContainer)) {
return new ArrayProperty(property).uniqueItems();
}
if ("map".equalsIgnoreCase(responseContainer)) {
return new MapProperty(property);
}
return property;
}
示例12: doConvert
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
@Override
public JavaType doConvert(ClassLoader classLoader, String packageName, Swagger swagger, Object property) {
MapProperty mapProperty = (MapProperty) property;
Property valueProperty = mapProperty.getAdditionalProperties();
return findJavaType(classLoader, packageName, swagger, valueProperty);
}
示例13: testMap
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
private void testMap(Path path) {
Operation operation = path.getPost();
Property result200 = operation.getResponses().get("200").getSchema();
Assert.assertEquals(MapProperty.class, result200.getClass());
}
示例14: doWrap
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
@Override
protected Property doWrap(Property property) {
return new MapProperty(property);
}
示例15: doWrap
import io.swagger.models.properties.MapProperty; //导入依赖的package包/类
protected Property doWrap(Property property) {
return new MapProperty(property);
}