return true; case "string": return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null); case "ref": if (property instanceof RefProperty) {
private SerializableParameter complement(Property property, RouteParameter source, SerializableParameter param) { param.setType(property.getType()); param.setFormat(property.getFormat()); // array param: if (property instanceof ArrayProperty) { param.setItems(((ArrayProperty) property).getItems()); } // enum values: List<String> enums = source.enums(); if (enums.size() > 0) { param.setEnum(enums); } // default value: if (param instanceof AbstractSerializableParameter) { ((AbstractSerializableParameter) param).setDefault(source.defaultValue()); } return param; } }
@Override public String getFormat() { return property.getFormat(); }
private static void initTypeFormatMap() { try { for (Entry<Class<? extends Property>, JavaType> entry : PROPERTY_MAP.entrySet()) { Property property = entry.getKey().newInstance(); String key = genTypeFormatKey(property.getType(), property.getFormat()); TYPE_FORMAT_MAP.put(key, entry.getValue()); } } catch (Throwable e) { throw new Error(e); } }
private Parameter replaceArrayModelForOctetStream(Operation operation, Parameter parameter) { if (parameter instanceof BodyParameter && operation.getConsumes() != null && operation.getConsumes().contains("application/octet-stream")) { BodyParameter bodyParam = (BodyParameter) parameter; Model schema = bodyParam.getSchema(); if (schema instanceof ArrayModel) { ArrayModel arrayModel = (ArrayModel) schema; Property items = arrayModel.getItems(); if (items != null && items.getFormat() == "byte" && items.getType() == "string") { ModelImpl model = new ModelImpl(); model.setFormat("byte"); model.setType("string"); bodyParam.setSchema(model); } } } return parameter; }
@Override public String getFormat() { return property.getFormat(); }
private static void initTypeFormatMap() { try { for (Entry<Class<? extends Property>, JavaType> entry : PROPERTY_MAP.entrySet()) { Property property = entry.getKey().newInstance(); String key = genTypeFormatKey(property.getType(), property.getFormat()); TYPE_FORMAT_MAP.put(key, entry.getValue()); } } catch (Throwable e) { throw new Error(e); } }
private static String getPropertyType(Property property, boolean array) { String type = DataTypeManager.DefaultDataTypes.STRING; if (property != null) { type = SwaggerTypeManager.teiidType(property.getType(), property.getFormat(), array); } else if (array) { type += ARRAY_SUFFIX; } return type; }
@Override public String getTypeDeclaration(Property p) { if ("password".equals(p.getFormat())) { return "char[]"; } if (p instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) p; Property inner = ap.getItems(); if (inner == null) { // mimic super behavior log.warn("{} (array property) does not have a proper inner type defined", ap.getName()); return null; } String type = super.getTypeDeclaration(inner); if (!languageSpecificPrimitives.contains(type) && topLevelResources.contains(type)) { return type + "List"; } } return super.getTypeDeclaration(p); }
/** Returns the {@link TypeInfo} corresponding to the property. */ public TypeInfo getTypeInfo(Service.Builder serviceBuilder, Property prop) { if (prop == null) { // TODO(user): How do we handle such cases. May be schema validation at the beginning is // the solution. return null; } Property arrayItems = prop instanceof ArrayProperty ? ((ArrayProperty) prop).getItems() : null; return getTypeInfo(serviceBuilder, prop.getType(), prop.getFormat(), prop, arrayItems); }
/** Returns the {@link TypeInfo} corresponding to the property. */ public TypeInfo getTypeInfo(Service.Builder serviceBuilder, Property prop) { if (prop == null) { // TODO(user): How do we handle such cases. May be schema validation at the beginning is // the solution. return null; } Property arrayItems = prop instanceof ArrayProperty ? ((ArrayProperty) prop).getItems() : null; return getTypeInfo(serviceBuilder, prop.getType(), prop.getFormat(), prop, arrayItems); }
private static ObjectNode createSchemaFromProperty(final ObjectNode json, final String name, final Property schema) { if (schema instanceof MapProperty || schema instanceof ObjectProperty) { try { final String schemaString = Json.writer().writeValueAsString(schema); return JsonSchemaHelper.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) { final ObjectNode jsonSchema = JsonNodeFactory.instance.objectNode(); final String format = schema.getFormat(); if (format != null) { jsonSchema.put("format", format); } final String type = schema.getType(); if (type != null) { jsonSchema.put("type", type); } return jsonSchema; } final String reference = JsonSchemaHelper.determineSchemaReference(schema); final String title = determineTitleOf(name, schema); return JsonSchemaHelper.resolveSchemaForReference(json, title, reference); }
public static String javaTypeFor(final SerializableParameter parameter) { final String type = parameter.getType(); if ("array".equals(type)) { final Property items = parameter.getItems(); final String elementType = items.getType(); final String elementFormat = items.getFormat(); return javaTypeFor(elementType, elementFormat) + "[]"; } final String format = parameter.getFormat(); return javaTypeFor(type, format); }
public static String javaTypeFor(final SerializableParameter parameter) { final String type = parameter.getType(); if ("array".equals(type)) { final Property items = parameter.getItems(); final String elementType = items.getType(); final String elementFormat = items.getFormat(); return javaTypeFor(elementType, elementFormat) + "[]"; } final String format = parameter.getFormat(); return javaTypeFor(type, format); }
public static String javaTypeFor(final SerializableParameter parameter) { final String type = parameter.getType(); if ("array".equals(type)) { final Property items = parameter.getItems(); final String elementType = items.getType(); final String elementFormat = items.getFormat(); return javaTypeFor(elementType, elementFormat) + "[]"; } final String format = parameter.getFormat(); return javaTypeFor(type, format); }
public static String javaTypeFor(final SerializableParameter parameter) { final String type = parameter.getType(); if ("array".equals(type)) { final Property items = parameter.getItems(); final String elementType = items.getType(); final String elementFormat = items.getFormat(); return javaTypeFor(elementType, elementFormat) + "[]"; } final String format = parameter.getFormat(); return javaTypeFor(type, format); }
protected ModelImpl createModel(Property property) { return new ModelImpl().type(property.getType()).format(property.getFormat()) .description(property.getDescription()); }
private SerializableParameter complement(Property property, RouteParameter source, SerializableParameter param) { param.setType(property.getType()); param.setFormat(property.getFormat()); // array param: if (property instanceof ArrayProperty) { param.setItems(((ArrayProperty) property).getItems()); } // enum values: List<String> enums = source.enums(); if (enums.size() > 0) { param.setEnum(enums); } // default value: if (param instanceof AbstractSerializableParameter) { ((AbstractSerializableParameter) param).setDefault(source.defaultValue()); } return param; } }
public void setProperty(Property property) { setType(property.getType()); this.format = property.getFormat(); if (property instanceof StringProperty) { final StringProperty string = (StringProperty) property; setEnum(string.getEnum()); } else if (property instanceof IntegerProperty) { setEnumValue(((IntegerProperty) property).getEnum()); } else if (property instanceof LongProperty) { setEnumValue(((LongProperty) property).getEnum()); } else if (property instanceof FloatProperty) { setEnumValue(((FloatProperty) property).getEnum()); } else if (property instanceof DoubleProperty) { setEnumValue(((DoubleProperty) property).getEnum()); } else if (property instanceof ArrayProperty) { final ArrayProperty array = (ArrayProperty) property; setItems(array.getItems()); } }